HonestHook

RankingsSign in

Tutorials

Instagram profile in Python

One authenticated call to /api/v1/instagram/profile?handle=nasa, the response it returned, and the line that reads one field out of it.

What you need

Standard library only — urllib and json ship with Python 3. There is nothing to pip install.

The call

import json
import os
import urllib.request

url = "https://honesthook.com/api/v1/instagram/profile?handle=nasa"

request = urllib.request.Request(
    url,
    headers={"Authorization": "Bearer " + os.environ["HH_KEY"]},
)

with urllib.request.urlopen(request, timeout=30) as response:
    envelope = json.load(response)

print(envelope["success"], envelope["platform"], envelope["endpoint"])

What came back

{
  "success": true,
  "platform": "instagram",
  "endpoint": "instagram/profile",
  "data": {
    "author": {
      "id": "17841401474538262",
      "handle": "nasa",
      "name": "NASA",
      "followers": 104357600,
      "following": 91,
      "posts_count": 4923,
      "verified": true,
      "is_private": false
    }
  },
  "error": null,
  "cached": true
}

Recorded response, captured 15 Sep 2026. A live call returns the value at the moment you ask, not this one.

Every field in that capture

In PythonType in this capture
envelope["success"]boolean
envelope["platform"]string
envelope["endpoint"]string
envelope["data"]["author"]["id"]string
envelope["data"]["author"]["handle"]string
envelope["data"]["author"]["name"]string
envelope["data"]["author"]["followers"]number
envelope["data"]["author"]["following"]number
envelope["data"]["author"]["posts_count"]number
envelope["data"]["author"]["verified"]boolean
envelope["data"]["author"]["is_private"]boolean
envelope["error"]null
envelope["cached"]boolean

A field we cannot read comes back null, never 0. A zero would be a claim about the account; null is a fact about our collection.

Reading one field

print(envelope["data"]["author"]["followers"])

envelope is the dict from the block above. os.environ raises if the key is not set, which is better than sending the word None as a bearer token.

Instagram's own API asks for a login and an app review before it tells you how many followers a public account has. This endpoint does not: you send one authenticated GET, and you get the eight normalised fields back in the same envelope every other platform here returns.

What you are calling

You are calling our endpoint, not Instagram's. The request goes to honesthook.com, carries your key in an Authorization header, and comes back as JSON. Whatever Instagram requires on its side — the public page, the path that changes without notice — happens behind that one call and is not your problem.

The handle in the example is the one that produced the response below. If you change it, you get a different account's numbers; the shape stays identical.

Before you copy the block

Put your key in an environment variable rather than in the file. Every example on this page reads HH_KEY, and the free tier needs no card, so there is nothing to protect except the key itself.

Read the response section carefully before you build on a field. Instagram publishes some things on a logged-out profile page and not others — a field we cannot read comes back null, never 0.

The endpoint itself

Parameters, the handle format and what a call costs: instagram-api/profile.

The same call in curl · JavaScript.

Free key, 1,000 credits a month

Every example above runs against the real endpoint as soon as you have a key. No card, and the key arrives in seconds.

Get a key →

← Tutorials · instagram-api · Pricing