# Instagram Hashtag API

> Get an Instagram hashtag's post count and top posts, and search hashtags, as JSON. 1 credit per call.

**Get a hashtag's post count and its top posts**, and **search for hashtags** by keyword.

```
GET https://api.handlehaul.com/v1/hashtags/{tag}
GET https://api.handlehaul.com/v1/hashtags/{tag}/posts
GET https://api.handlehaul.com/v1/search/hashtags?q=
```

- `GET /v1/hashtags/{tag}`: A hashtag and its post count
- `GET /v1/hashtags/{tag}/posts`: Top posts for a hashtag
- `GET /v1/search/hashtags?q=`: Find hashtags

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

## Parameters

| Parameter | In | Description |
|---|---|---|
| `tag` | path | Hashtag, with or without `#` (URL-encode `#` as `%23`). |
| `q` | query | search: what to look for. |
| `cursor` | query | `pagination.next_cursor` from the previous page. |
| `fresh` | query | `true` skips the cache. |

## Response

```json
{
  "data": [
    {
      "id": "1417859427809275745",
      "shortcode": "BOtP6MwAq9h",
      "url": "https://www.instagram.com/p/BOtP6MwAq9h/",
      "taken_at": "2026-11-28T11:56:42.000Z",
      "media_type": "photo",
      "caption": "cedar sage · sample post 1",
      "counts": {
        "likes": 1889,
        "comments": 32,
        "views": null
      },
      "thumbnail_url": "https://scontent.cdninstagram.com/…/1417859427809275745.jpg",
      "video_url": null,
      "duration_seconds": null,
      "owner": {
        "id": "2664388851",
        "username": "pixel.kai4",
        "full_name": "Pixel Kai",
        "is_private": false,
        "is_verified": false,
        "profile_pic_url": "https://scontent.cdninstagram.com/…/2664388851.jpg"
      },
      "location": {
        "id": "870424359",
        "name": "river Café"
      },
      "audio": null,
      "carousel": null
    }
  ],
  "pagination": {
    "next_cursor": "Ym9v…sealed…",
    "has_more": true,
    "page_size": 12
  },
  "meta": {
    "request_id": "req_…",
    "cached": false,
    "cache_age_seconds": 0,
    "credits_charged": 1,
    "credits_remaining": 26943
  }
}
```

## Examples

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

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

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

```php
$ch = curl_init("https://api.handlehaul.com/v1/hashtags/coffee/posts");
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/hashtags/coffee/posts", 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 many posts does an Instagram hashtag have?
Call `GET /v1/hashtags/{tag}`: `post_count` is the number Instagram shows.
