showdev**
I recently built , and this project was a good opportunity for me to learn more about working with REST APIs and processing JSON data in Python.
My stack for this project was .
The basic idea was straightforward: fetch Instagram data through an API and then use that data as part of my tool's workflow.
Why I Built It
I wanted to build .
Instead of trying to build the entire data-fetching infrastructure myself, I experimented with HikerAPI, a REST Instagram API. According to its pricing information, requests start from $0.001 per request, and it offers 100 free requests.
Fetching the Data
Here is the basic Python code I used to fetch a user's information and then retrieve their highlights:
import requests
headers = {"x-access-key": "YOUR_KEY"}
user = requests.get(
"https://api.hikerapi.com/v2/user/by/username?username=instagram",
headers=headers
).json()
r = requests.get(
f"https://api.hikerapi.com/v2/user/highlights?user_id={user['pk']}",
headers=headers
)
print(r.json())
The workflow is fairly simple:
- Import the
requestslibrary. - Create the request headers containing the API key.
- Fetch information about a username.
- Extract the user's
pkvalue from the response. - Use that ID to request the user's highlights.
- Print the JSON response so the tool can process it.
One Thing That Was Harder Than Expected
One thing that was harder than I expected was .
Making the API request itself was relatively straightforward, but understanding the structure of the returned JSON and figuring out exactly which fields my tool needed took more time.
It was also a useful reminder that API calls can fail, responses may not always have the structure I expect, and production code needs proper error handling.
For example, one improvement I would make is checking the HTTP response before immediately processing the JSON:
response = requests.get("<API_ENDPOINT>", headers=headers)
if response.ok:
data = response.json()
print(data)
else:
print(f"Request failed: {response.status_code}")
What's Next?
The current version of is still small, but I would like to improve it by adding:
- Better error handling
- Configuration through environment variables
Building this was a useful small project because it connected several things I have been learning: Python, HTTP requests, REST APIs, JSON, and .
If you've built a small API-powered CLI, Discord bot, or Telegram bot, I'd love to hear what features or improvements you would add to this project.
Top comments (0)