# Instagram Post API

> Get one Instagram post or reel by shortcode, id or URL: caption, media, likes, comments, views, location and audio. Batch like, comment and view counts for 20 posts in one call.

**Get one Instagram post or reel by its URL, shortcode or id**: caption, images or video, carousel items, like, comment and view counts, location and audio. **Track engagement for up to 20 posts in a single call** with the stats route.

```
GET https://api.handlehaul.com/v1/posts/{post}
GET https://api.handlehaul.com/v1/posts/stats?ids=
```

- `GET /v1/posts/{post}`: One post or reel
- `GET /v1/posts/stats?ids=`: Like, comment and view counts for up to 20 posts (1 credit for the batch)

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

## Parameters

| Parameter | In | Description |
|---|---|---|
| `post` | path | Post shortcode (`C9xYzAbCdEf`), numeric id, or a URL-encoded instagram.com/p/… or /reel/… link. |
| `ids` | query | stats: 1 to 20 posts, comma-separated shortcodes or ids. |
| `fresh` | query | `true` skips the cache. |

## Response

```json
{
  "data": {
    "id": "3500000000000000123",
    "shortcode": "DCSf3TJ3gB7",
    "url": "https://www.instagram.com/p/DCSf3TJ3gB7/",
    "taken_at": "2026-11-28T11:59:43.000Z",
    "media_type": "photo",
    "caption": "bloom river · sample post 1",
    "counts": {
      "likes": 915,
      "comments": 148,
      "views": null
    },
    "thumbnail_url": "https://scontent.cdninstagram.com/…/8637327854758358242.jpg",
    "video_url": null,
    "duration_seconds": null,
    "owner": {
      "id": "6393149904",
      "username": "nomad.atelier17",
      "full_name": "Nomad Atelier",
      "is_private": false,
      "is_verified": false,
      "profile_pic_url": "https://scontent.cdninstagram.com/…/6393149904.jpg"
    },
    "location": {
      "id": "958349030",
      "name": "ivy Café"
    },
    "audio": null,
    "carousel": null
  },
  "meta": {
    "request_id": "req_…",
    "cached": false,
    "cache_age_seconds": 0,
    "credits_charged": 1,
    "credits_remaining": 26943
  }
}
```

## Examples

```bash
curl "https://api.handlehaul.com/v1/posts/C9xYzAbCdEf" -H "X-Api-Key: $HANDLEHAUL_API_KEY"
```

```python
import os, requests
r = requests.get("https://api.handlehaul.com/v1/posts/C9xYzAbCdEf",
                 headers={"X-Api-Key": os.environ["HANDLEHAUL_API_KEY"]}, timeout=30)
r.raise_for_status()
p = r.json()["data"]
print(p["media_type"], p["counts"], p["caption"][:80])
```

```javascript
const res = await fetch("https://api.handlehaul.com/v1/posts/C9xYzAbCdEf", {
  headers: { "X-Api-Key": process.env.HANDLEHAUL_API_KEY },
});
const { data: post } = await res.json();
```

```php
$ch = curl_init("https://api.handlehaul.com/v1/posts/C9xYzAbCdEf");
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER => ["X-Api-Key: " . getenv("HANDLEHAUL_API_KEY")],
    CURLOPT_RETURNTRANSFER => true,
]);
$body = json_decode(curl_exec($ch), true);
print_r($body["data"]);
```

```go
req, _ := http.NewRequest("GET", "https://api.handlehaul.com/v1/posts/C9xYzAbCdEf", nil)
req.Header.Set("X-Api-Key", os.Getenv("HANDLEHAUL_API_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
    log.Fatal(err)
}
defer res.Body.Close()
var body map[string]any
json.NewDecoder(res.Body).Decode(&body)
fmt.Println(body["data"])
```

## FAQ

### How do I get Instagram post data from a URL?
URL-encode the link and pass it as `{post}`, or pass the shortcode from the URL. The id is worked out locally, so there is no extra call.

### How do I track likes on many posts cheaply?
Use `GET /v1/posts/stats?ids=a,b,c` with up to 20 posts: one call, one credit, the like, comment and view counts of each.
