Forums

Using external API in the application

I have a problem with my application.

I am using apiadvisor for weather in my application. Localhost the request works, but in the host pythonanywhere it has error.

How can I solve this problem?

If you are a free user your outbound internet access is limited to a whitelist. If you show the API documentation for that site we can consider adding it to the whitelist.

Conrad

The api authentication is required and documentation is available only to users. I dont know if this help, but this is the link http://apiadvisor.climatempo.com.br/doc/index.html

thanks- I've been trying to figure out what apiadvisor is. Is it something that generates api documentation from api endpoints?

Conrad

Advisor is Weather forecast API, integrates high-quality meteorological data and accuracy into applications.

site: https://advisor.climatempo.com.br/

api documentation: http://apiadvisor.climatempo.com.br/doc/index.html

endpoint GET: "http://apiadvisor.climatempo.com.br/api/v1/weather/locale/{id}/current?token={token}".format()

I see! Great! We have added apiadvisor.climatempo.com.br to the whitelist for you.

Conrad

Thanks for this.

I too have such similar issues. I am using the Alphavantage API (It's a stock data API), documentation link as follows: https://www.alphavantage.co/documentation/

I am using a Hacker's account $5/month

It would be nice if anyone could help out too.

Thanks

And this is how I get the stock data using account API key (written in ak.txt):

In Python

with open('ak.txt', 'r') as myFile:
    keys=myFile.read()
    ts=TimeSeries(key=keys, output_format='pandas')

aapl_day, meta_data=ts.get_daily(symbol=tick_name, outputsize='full')

[edit by admin: formatting]

What error messages do you get when you run that code?

Django Version: 3.0.3 Exception Type: ValueError Exception Value:
max() arg is an empty sequence

But it works on local device (laptop), does'nt work when using pythonanywhere

Or is it that I have to write it similar to format below in order for it to work or it should work anyway: endpoint GET: "http://apiadvisor.climatempo.com.br/api/v1/weather/locale/{id}/current?token={token}".format() [example from previous post above]

Thanks

sorry- what is the full error stacktrace? not just the first / last line etc?

Please I am also facing this issue,

Could you also add Ipstack to the whitelist? Here is a link to the documentation. https://ipstack.com/documentation

Thank you. Babatunde.

It looks like api.ipstack.com, the documented endpoint, is already on the whitelist. Are you getting errors accessing it?

I didn't get any errors, the endpoint is supposed to return user location from their IP information, the hosted version just returns None. Works fine on my local.

Thank you.

What IP address are you passing in?

Ipstack has an option to just use a check keyword in the URL to indicate that it has to check user IP information on request. See below: here: http://api.ipstack.com/check?access_key={access_key}&fields=city,country_name,zip

Hi! It seems like I have the same issue with external API. I send a post request to link: http://smspro.nikita.kg/api/message for sending SMS verification code to the android client. But the log only shows me response 403. Can you please add the link to the whitelist

smspro.nikita.kg is not whitelisted. You need to provide official docs of the public API.

Here is a link for the docs of API

Thanks, we've whitelisted smspro.nikita.kg.

Hi, I need to call this api "https://cdn-api.co-vin.in/api/" , can this be whitelisted? API docs: https://apisetu.gov.in/public/marketplace/api/cowin

cdn-api.co-vin.in is already in the whitelist

can twilio-video api be used on pythonanywhere?

It would depend heavily on how it is implemented but, at a guess, I'd say probably not.

Hello PythonAnywhere, am having some issues on a Django Web app which is base on Crypto Currency.Am making use of the python requests library to get the data I want to scrape which doesn't violate their rights.

My point here is that am having some issues with Fetching those data with the requests library but this doesn't happen in development mode.I think the website am trying to fetch data doesn't appears on your whitelist.

The website are as follows: www.blockchain.com www.cryptowat.ch

Am on Free account, so if I can get pass the error with your support I promise to purchase a paid account.

I will be waiting for your feedbacks.

Thanks.

Send us a link to the API documentation for the sites that shows the URL where that API is available and we'll consider them for he whitelist.

They are not API but a Website, I scraped data from them.

You can do a little research about them. Although they provide consumable API's but web scraping was the easiest and preferable for me.

Here are their links

https://cryptowat.ch/

https://www.blockchain.com/btc/address/

Thanks.

Is web scraping supported on a Paid Account.

Paid accounts have unrestricted Internet access, which means that you can connect to any site that allows incoming connections from our servers. That means that in general, web scraping will work, but if the site that you are trying to scrape blocks connections from us, it will stop working.

thanks for the feedback.

Wow, it worked on a paid account.

To anyone that will need this information. If you face any issues concerning get data from other website in your python web app(and you don't see this issues in development) consider purchasing a paid plan.

Glad to hear that you made it work!

Hello, is it possible to whitelist the API for the Integrated Water Level System. This is a public API, free, offered by the Canadian Hydrographic Service.

Official documentation is here: https://www.qc.dfo-mpo.gc.ca/tides/en/web-services-offered-canadian-hydrographic-service

The swagger: https://api-iwls.dfo-mpo.gc.ca/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/data

Example for getting the water levels observed at a given station at a given time: https://api-iwls.dfo-mpo.gc.ca/api/v1/stations/5cebf1df3d0f4a073c4bbb38/data?time-series-code=wlo&from=2022-02-01T23:55:11Z&to=2022-02-02T23:54:11Z

Thank you in advance, Pierre

@pierrebourgault api-iwls.dfo-mpo.gc.ca is added now.

Awesome! Thank you so much for this and for the quick resolution!

Glad to hear that!

Hello pythonanywhere team <3 Loving your product so far! Deploying my first Django web application that I want to show off to my class, on live URL, not my local machine!

Can you add api.themoviedb.org or https://api.themoviedb.org to the whitelist because I am unable to send GET API requests to this API for my web app to show dynamic list of movies? This is the official documentation https://www.themoviedb.org/documentation/api This is a public free API being used for educational purposes registered as an application in their domain as well.

@alphasingh It's done.

Hi pythonanywhere team, do you mind whitelisting the following api as well. I use it to find find definition of Indonesian words in dictionary. http://kateglo.com Thank you!

OK, since API documentation is linked there, I added kateglo.com to our whitelist.

thank you team!

Hi There Pythonanywhere Team Can You Guys Whitelist nasa's open api's docs https://api.nasa.gov/ everything about the api's are there, by the way these are collection of api's, and whitelist this aswell if possible please https://mars-photos.herokuapp.com/ this is also one of nasa's open api but without the request limit which is 1000 per hour docs for this https://github.com/corincerami/mars-photo-api, example uses: https://api.nasa.gov/api/v1/manifests/rovers/curiosity/?api_key=DEMO_KEY it will Return rover data https://api.nasa.gov/planetary/apod/?api_key=DEMO_KEY it will return some text data and a link to an image https://mars-photos.herokuapp.com/api/v1/rovers/curiosity/latest_photos? to limit data we can add page=1 after the ? so this will return 25 record of data instead of hundreds of record this return some text date and an img link Thanks!

Hello @Marwan0

We added these URLs to the allowlist:

api.nasa.gov

mars-photos.herokuapp.com

Hello House. Please consider adding this api to your white list. https://developers.sendinblue.com/docs I'm on a free plan but the client I work for is on paid plan on python anywhere. I just want to get it to work before I push to their live code. Thanks a lot

@Drizzle Thank you for your message, can you please confirm the endpoint which you would like us to consider adding? Can you please also send us a direct link to the documentation which states the endpoint you would like us to add.

Thanks @hmalik for your quick reply it’s awesome. The Send in blue domain is actually whitelisted on Pythonanywhere but since they moved to a new version https://api.sendinblue.com/v3 I don’t know if that’s why. This is their documentation for version 3 https://github.com/sendinblue/APIv3-python-library and this is the error log I receive on my site logs

'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f7334336f10>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /v3/smtp/email 2022-12-08 03:06:44,344: Internal Server Error: /employees/api/v0/employees/request-password-change/ Traceback (most recent call last): File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn conn = connection.create_connection( File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/util/connection.py", line 95, in create_connection raise err File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection sock.connect(sa) OSError: [Errno 101] Network is unreachable NO MATCH During handling of the above exception, another exception occurred: NO MATCH Traceback (most recent call last): File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 386, in _make_request self._validate_conn(conn) File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn conn.connect() File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/connection.py", line 358, in connect self.sock = conn = self._new_conn() File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f73342bd460>: Failed to establish a new connection: [Errno 101] Network is unreachable NO MATCH During handling of the above exception, another exception occurred: NO MATCH Traceback (most recent call last): File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, callback_args, callback_kwargs) File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(args, kwargs) File "/home/Drizzle/kings_heart_edu_backend/./employees_app/views.py", line 247, in request_password_change Sendmail.send(subject="Reset password", content=email_body, receipients=receipients) File "/home/Drizzle/kings_heart_edu_backend/./utilities/emailer.py", line 41, in send api_response = api_instance.send_transac_email(send_smtp_email) File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/sib_api_v3_sdk/api/transactional_emails_api.py", line 1973, in send_transac_email (data) = self.send_transac_email_with_http_info(send_smtp_email, kwargs) # noqa: E501 File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/sib_api_v3_sdk/api/transactional_emails_api.py", line 2036, in send_transac_email_with_http_info return self.api_client.call_api( File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/sib_api_v3_sdk/api_client.py", line 329, in call_api return self.__call_api(resource_path, method, File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/sib_api_v3_sdk/api_client.py", line 161, in __call_api response_data = self.request( File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/sib_api_v3_sdk/api_client.py", line 371, in request return self.rest_client.POST(url, File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/sib_api_v3_sdk/rest.py", line 269, in POST return self.request("POST", url, File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/sib_api_v3_sdk/rest.py", line 162, in request r = self.pool_manager.request( File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/request.py", line 78, in request return self.request_encode_body( File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/request.py", line 170, in request_encode_body return self.urlopen(method, url, extra_kw) File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/poolmanager.py", line 376, in urlopen response = conn.urlopen(method, u.request_uri, kw) File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 815, in urlopen return self.urlopen( File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 815, in urlopen return self.urlopen( File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 815, in urlopen return self.urlopen( File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 787, in urlopen retries = retries.increment( File "/home/Drizzle/.virtualenvs/env/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.sendinblue.com', port=443): Max retries exceeded with url: /v3/smtp/email (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f73342bd460>: Failed to establish a new connection: [Errno 101] Network is unreachable'))

Hello @Drizzle according to the documentation, the base url for the api is "api.sendinblue.com" for v2 and for v3. Do you have a specific page which says that developers.sendinblue.com is the new base URL.

Hello can i have the discord api whitelisted

You'll find all the instructions for requesting allowlist additions here.

Hello! I've been working on movies and shows app with TMDb API, I want to use it to deploy my app as I cannot request TMDb for movies and shows data without API key. In VS Code I used to put the API key in environment variable and my app gets the API key from it but how to do this in pythonanywhere?

Here you go https://help.pythonanywhere.com/pages/environment-variables-for-web-apps/

Hi, I'm using tripadvisors API however I'm receiving the error that no information is being brought back, can It be added to the white list https://tripadvisor-content-api.readme.io/reference/overview

You'll find all the instructions for requesting allowlist additions here.

You legend, Thank you. I've sent in a request

Hi, I am using Leetcode graphql endpoint, https://leetcode.com/graphql/, Can you please whitelist this Api?

I've added leetcode to our api whitelist. Let us know how you get on

Hello, I am sending requests to "https://leetcode.com/graphql/", and I am getting "OSError('Tunnel connection failed: 403 Forbidden')". Is the endpoint still whitelisted?

Sorry I forgot to update this thread after my previous post. I didnt whitelist the Leetcode graphql api in the end. While people are using it and obviously isn't going to aid any malicious intent, it's clear the Leetcode haven't made it for public use. It has no publically accessible documentation and they've gone as far as disabling GraphQLs schema introspection feature.

Please I have same issues Can you add the binance-api to the whitelist to display current market prices. https://www.binance.com/en-NG/binance-api. That's the documentation

We already have api.binance.com, api.binance.je and api.binance.us on our allow-list -- do you need more endpoints?

But it works on local device (laptop), does'nt work when using pythonanywhere

Or is it that I have to write it similar to format below in order for it to work or it should work anyway: endpoint GET: "http://apiadvisor.climatempo.com.br/api/v1/weather/locale/{id}/current?token={token}".format() [example from previous post above] [Sapne Me Bail Dekhna]1

apiadvisor.climatempo.com.br is on the api whitelist so it will work. How are you making the request?

Hi there im havining problem with my API request too. It called fruity vice API. Website https://www.fruityvice.com/ and the documentation is: https://www.fruityvice.com/doc/index.html. Can it please be added to the allowlist.

@fruitFaxServer Please follow https://help.pythonanywhere.com/pages/RequestingAllowlistAdditions/

Hi, I need whitelisting of of these:

  1. https://soccervital.com
  2. https://tipster.bg
  3. https://www.whoscored.com

If this is not the right place to ask for this, could anyone please direct me to the correct way or documentation, Thanks!

@sporacles Please follow https://help.pythonanywhere.com/pages/RequestingAllowlistAdditions/

can you please add https://api.cquest.org/dvf to the whitelist this a public french government api to access to the past house prices. it's is explained here https://www.data.gouv.fr/en/reuses/micro-api-dvf-demande-de-valeurs-foncieres/ Many thanks

@spondei Please follow https://help.pythonanywhere.com/pages/RequestingAllowlistAdditions/

Hello, could you add https://eternium.pages.dev/api/v1/* to white list api?

@donkihote Please follow https://help.pythonanywhere.com/pages/RequestingAllowlistAdditions/

Hi Pythonanywhere team,

I am a paid user but my Flask service cannot access an external API. It works on my local and as the account features described, paid users have no limit of external Internet.

The API I am calling is https://forecast-v2.metoceanapi.com which is a weather forecast API and its document is https://forecast-docs.metoceanapi.com/swagger-ui/.

I tried to reload the web app, but it didn't help.

Can anyone help?

Thanks.

Looks like forecast-v2.metoceanapi.com is whitelisted. What error are you seeing in the web app logs?

Thank you @ sboyd for replying. I have solved it which missed a config but not a connectivity issue.

Nice!