Cannot reach external API with simple flask app
Sorry if its a dumb question but im new and testing out railway.
I made a simple flask app to pull some data from the binance:
def get_funding_rate():
url = 'https://fapi.binance.com/fapi/v1/fundingRate?symbol=BTCUSDT&limit=100'
response = requests.get(url)
if response.status_code == 200:
return response.json()
return None
Run locally its fine, but whenever i deploy to railway, it cannot communicate with the api, what do i need to do to communicate with an external api?
9 Replies
Project ID:
98f82854-e5c9-41ce-95da-70487e296839
Project ID: 98f82854-e5c9-41ce-95da-70487e296839
I can't see any errors in your logs so far. Everything looks fine.
So, can you provide more deets on what you mean by it can't communicate with an external api?
yes, i added some simple code to ping the api:
@app.route('/section2/test_api')
def test_api():
response = requests.get('https://api.binance.com/api/v3/ping')
if response.status_code == 200:
return "API is reachable", 200
else:
return "Error reaching API", response.status_code
When run locally i get this: API is reachable
When run on railway i get this: Error reaching API
binance is known to block GCP IP addresses, we run a large portion of workloads on GCP by default.
Please try switching to one of our two metal regions in your service settings.
hmm ok unfortunately same issue with the two metal regions
what status code do you get
451
that's not something we could help with unfortunately