# 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.klupt.io/v1/hashtags/{tag}
GET https://api.klupt.io/v1/hashtags/{tag}/posts
GET https://api.klupt.io/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 (0.5 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 (full price). |

## Response

```json
{{SAMPLE_hashtag_posts}}
```

## Examples

```bash
curl "https://api.klupt.io/v1/hashtags/coffee/posts" -H "X-Api-Key: $KLUPT_API_KEY"
```

```python
import os, requests
r = requests.get("https://api.klupt.io/v1/hashtags/coffee/posts",
                 headers={"X-Api-Key": os.environ["KLUPT_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.klupt.io/v1/hashtags/coffee/posts", {
  headers: { "X-Api-Key": process.env.KLUPT_API_KEY },
});
const { data: posts } = await res.json();
```

## FAQ

### How many posts does an Instagram hashtag have?
Call `GET /v1/hashtags/{tag}`: `post_count` is the number Instagram shows.
