# Instagram Stories API

> Get a public Instagram account's live stories (last 24 hours) as JSON: image or video URL, time posted and expiry. Look up one story by id. 1 credit per call.

**Get the live stories of a public Instagram account** (the last 24 hours) with image or video URLs, the time each was posted and when it expires. Viewing through the API never shows up in the account's viewer list.

```
GET https://api.klupt.io/v1/users/{user}/stories
GET https://api.klupt.io/v1/stories/{story}
```

- `GET /v1/users/{user}/stories`: All live stories of an account
- `GET /v1/stories/{story}`: One story by id (expired stories answer `404`)

**Cost:** 1 credit per successful call (0.5 from cache). Failed calls and private accounts are free.

## Parameters

| Parameter | In | Description |
|---|---|---|
| `user` | path | Username (`natgeo`) or numeric user id. Private accounts answer `403 private_account` (free). |
| `story` | path | Numeric story id (from a story URL or a stories list). |
| `fresh` | query | `true` skips the cache (full price). |

## Response

```json
{{SAMPLE_user_stories}}
```

## Examples

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

```python
import os, requests
r = requests.get("https://api.klupt.io/v1/users/natgeo/stories",
                 headers={"X-Api-Key": os.environ["KLUPT_API_KEY"]}, timeout=30)
r.raise_for_status()
for s in r.json()["data"]:
    print(s["media_type"], s["taken_at"], s["video_url"] or s["thumbnail_url"])
```

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

## FAQ

### Does the account see that I viewed their story?
No. Stories are fetched by Klupt, not by your Instagram account, so you never appear in the viewer list.

### How fresh are stories?
Stories are cached for 5 minutes. Pass `fresh=true` for a live fetch.
