Forums

BTCJam API Request: Different output while running locally and pythonanywhere

Code:

1
2
3
4
5
6
7
#!/usr/bin/python3.5
import requests, time, json

link = 'https://btcjam.com/payment_types.json'
r = requests.get(link)
data = json.loads(r.text)
print(data)

Above code is producing different outputs when it is executed on my local machine (located at India) and on pythonanywhere. While running on my local machine, i have ensured that i didnt log into BTCJam. Is there any specific reason why i am getting different outputs? Can you suggest any solution to resolve the issue?

Output after executing above code on pythonanywhere:

{'error': 'You need to log in or sign up before continuing.'}

Output after executing above code on my Local Machine (India):

[{'enabled': True, 'id': 4, 'name': '1st of the month', 'translated_name': '1st of the month', 'days_of_interval': 30}, {'enabled': True, 'id': 5, 'name': '5th of the month', 'translated_name': '5th of the month', 'days_of_interval': 30}, {'enabled': True, 'id': 6, 'name': '10th of the month', 'translated_name': '10th of the month', 'days_of_interval': 30}, {'enabled': True, 'id': 3, 'name': 'Weekly', 'translated_name': 'Weekly', 'days_of_interval': 7}, {'enabled': True, 'id': 7, 'name': 'Monthly', 'translated_name': 'Monthly', 'days_of_interval': 30}]

According to btcjam api docs, you do need to signup for an account. Are you already signed in locally?

Locally i didnt log into my account. Without logging in when i visit "https://btcjam.com/payment_types.json" link, i am not getting any error.

It looks to me, from a few quick experiments, like btcjam may have some sort of block on AWS IPs, or something like that. I can GET that URL without trouble from my desktop, but any attempt from one of our PythonAnywhere machines gets a 403 response.