# Instagram Profile API

> Get a public Instagram profile as JSON with one call: bio, website, category, verified status, profile picture, and follower, following and post counts. 1 credit per successful call.

**Get a public Instagram profile as JSON**: bio, website, category, verified status, HD profile picture, and follower, following and post counts.

```
GET https://api.klupt.io/v1/users/by-username/{username}
GET https://api.klupt.io/v1/users/by-id/{id}
GET https://api.klupt.io/v1/users/{user}            # username or id
```

All three return the same profile. Use **by-id** when you stored ids (ids survive renames), **by-username** when you have a handle, and `{user}` when you accept either.

**Cost:** 1 credit per successful call (0.5 from cache). Profiles are cached for 15 minutes.

## Parameters

| Parameter | In | Description |
|---|---|---|
| `username` | path | by-username: an Instagram username (`natgeo`), always read as a username. |
| `id` | path | by-id: a numeric Instagram user id (`787132`). |
| `user` | path | `{user}` route: a username or a numeric id. |
| `fresh` | query | `true` skips the cache (full price). Same as the header `Cache-Control: no-cache`. |

## Response

```json
{
  "data": {
    "id": "787132",
    "username": "natgeo",
    "full_name": "National Geographic",
    "is_private": false,
    "is_verified": true,
    "profile_pic_url": "https://scontent.cdninstagram.com/…",
    "biography": "Experience the world through the eyes of our photographers.",
    "external_url": "https://www.nationalgeographic.com",
    "category": "Media/news company",
    "is_business": true,
    "profile_pic_url_hd": "https://scontent.cdninstagram.com/…",
    "counts": { "followers": 280000000, "following": 160, "posts": 30500 }
  },
  "meta": { "request_id": "req_Zt0q…", "cached": true, "cache_age_seconds": 141, "credits_charged": 0.5, "credits_remaining": 26948.5 }
}
```

Private accounts return their public profile fields with `is_private: true`; their lists and posts are not available.

## Examples

```bash
curl "https://api.klupt.io/v1/users/by-username/natgeo" -H "X-Api-Key: $KLUPT_API_KEY"
curl "https://api.klupt.io/v1/users/by-id/787132" -H "X-Api-Key: $KLUPT_API_KEY"
```

```python
import os, requests
p = requests.get("https://api.klupt.io/v1/users/natgeo",
                 headers={"X-Api-Key": os.environ["KLUPT_API_KEY"]}, timeout=30).json()["data"]
print(p["counts"]["followers"])
```

```javascript
const { data } = await (await fetch("https://api.klupt.io/v1/users/natgeo", {
  headers: { "X-Api-Key": process.env.KLUPT_API_KEY },
})).json();
```

## FAQ

### How do I get someone's Instagram follower count with an API?
Call `GET /v1/users/by-username/{username}`. The follower count is in `data.counts.followers`, next to `following` and `posts`.

### How fresh is the profile data?
Answers are cached for 15 minutes and `meta.cache_age_seconds` tells you the age. Pass `fresh=true` for a live fetch.


### Can I get an Instagram profile by user id?
Yes: `GET /v1/users/by-id/{id}` returns the same profile for a numeric user id.
