Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Access an API
#2
You most give more info about the API.
(Dec-23-2022, 11:29 AM)TheGr8Schwazoli Wrote: Where do I place the DLL in my project folder and how do I code in my program to and use this API?
This is strange question that is usally not askes at all when try to acess a API.
To show a normal way to access access a API,eg can use OpenWeather.
So use Requests and then use the Json respone that API give back.
import requests

api_key = 'xxxxxxxxxxxxxxxx'
city = 'london'
celsius = 'metric'
url = f'http://api.openweathermap.org/data/2.5/weather?q={city}&units={celsius}&APPID={api_key}'
response = requests.get(url).json()

print(response.get('name'))
print(response['main'].get('temp'))
Output:
London 11.34
Reply


Messages In This Thread
How to Access an API - by TheGr8Schwazoli - Dec-23-2022, 11:29 AM
RE: How to Access an API - by snippsat - Dec-23-2022, 03:55 PM
RE: How to Access an API - by TheGr8Schwazoli - Dec-23-2022, 04:37 PM
RE: How to Access an API - by snippsat - Dec-23-2022, 05:24 PM
RE: How to Access an API - by TheGr8Schwazoli - Dec-23-2022, 06:32 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020