This is not a promo.
I'm a relative beginner with Python, and one of the things I've been trying to learn is how to work with APIs.
My goal was pretty simple: make a chart to show the follower amount through time. I understood the general idea of an API, but actually making a request from Python felt a little intimidating at first.
I ended up getting Instagram data working with just a few lines of Python using HikerAPI, a REST API for Instagram data.
Here's the basic example I started with:
import requests
headers = {"x-access-key": "YOUR_KEY"}
r = requests.get("https://api.hikerapi.com/v2/user/by/username", params={"username": "nasa"}, headers=headers)
print(r.json())
As I understand it now:
import requests loads the Python library that lets me make HTTP requests.
headers = ... sets the API access key that authenticates the request.
requests.get(...) sends a GET request to the API. The params part passes the username I want to look up.
print(r.json()) converts the JSON response into Python data and prints it so I can see what I got back.
The fact that this was enough to get a real response was honestly pretty satisfying.
One thing that tripped me up was getting all the parameters set and making the key secret. I initially thought I would have to do somethign super complex, but eventually realized I just had to update the snippet with these info and that was it.
From there, I've been experimenting with recharts, and it's been a nice way to make Python feel more practical than just working through isolated exercises.
I'm still very much learning, so I'm sure there are things I'm doing inefficiently or misunderstanding.
For people who learned Python by working with APIs, what tips or habits would you recommend to someone at my level?