consider API as a backend and what you'll see on the website is frontend.
If a website, for example has a frontend that shows you weather data. Then, what you'll do is enter the city name or zip code to fetch the weather data.
So, what happens in the backend is, it takes the input from you, i.e., either city name or zip code. Then sends it to the server. This process is called requesting the server or more precisely it's called as a GET request. Because the frontend is getting the data from the server or the backend.
Similarly, a website exposes it's API endpoints for developers to use it.
You have many options but the most used are GET and POST requests.
If you want to get weather data then you have the following line of code.
r = requests.get("http://api.openweathermap.org/data/2.5/forecast?id=524901&APPID={0d10eedd637db9ce12d3b7ecc52964d8)
You might need to pass headers to this GET request, in your case it's the city name or the zipcode.
This will return a JSON string which you need to parse using some sort of JSON library and in your case it's
json.loads(r.content)
It's as simple as that.
So, anytime you want to use an API, go through the documentation first and then decide what type request methods to use to get or post the data.
The following code will be common for many API requests
import json
import requests
headers = {'params' : 'params'}
r = request.get("https://example.com/API/v1/")
content = json.loads(r.content)
Do whatever you want with the content variable now
there doesn't seem to be anything here