# Instagram Post and Reel Search API

> Search public Instagram posts and reels by keyword as JSON, in the order Instagram's top search ranks them, about 10 per page with cursor paging. Same post object as every route. 1 credit a page.

`GET /v1/instagram/search/posts?q=` returns public Instagram posts and reels for a keyword, in the order Instagram's own top search ranks them, about 10 per page. Each result is the same post object as everywhere else in the API: `shortcode`, `url`, `taken_at`, `media_type` (`reel` for Reels), `caption`, `counts`, media URLs, `owner`, and `location` and `audio` when the post has them.

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

**Cost:** 1 credit per page read live. Cached pages (15 minutes) and failed calls are free.

## Why this route exists

Instagram no longer offers a separate keyword search for Reels, and hashtag pages now show only their Top tab. The blended top search is the one place Instagram still answers "posts about this word", so this route reads it and keeps only the posts and reels, in its order.

- **Trend and content research:** what is ranking for a product name, a place or a topic right now.
- **Creator discovery:** the `owner` of each result is a ready lead for the [Profile API](/docs/instagram-profile-api).
- **Brand monitoring** for words that are not hashtags.

## What it is, and is not

Results are Instagram's ranking for the query, not every post that contains the word, and not newest first. Running the same search later can return different posts as Instagram's ranking moves. For posts under one tag use the [Hashtag API](/docs/instagram-hashtag-api); for the newest posts at one spot, the [Location API](/docs/instagram-location-api) with `sort=recent`.

## Parameters

| Parameter | In | Description |
|---|---|---|
| `q` | query | Required. The keyword or phrase (1 to 64 characters). |
| `cursor` | query | Optional. `pagination.next_cursor` from the previous page, when `has_more` is true. |
| `fresh` | query | Optional. `true` bypasses the cache and is billed as a live call. |

## Response

Sandbox-key sample, live schema:

```json
{
  "data": [
    {
      "id": "6617279840443177993",
      "shortcode": "FvVTPR8-BwJ",
      "url": "https://www.instagram.com/reel/FvVTPR8-BwJ/",
      "taken_at": "2026-11-28T11:56:49.000Z",
      "media_type": "reel",
      "caption": "olive nomad · sample post 1",
      "counts": {
        "likes": 7492,
        "comments": 142,
        "views": 16752
      },
      "thumbnail_url": "https://scontent.cdninstagram.com/…/6617279840443177993.jpg",
      "video_url": "https://scontent.cdninstagram.com/…/6617279840443177993.mp4",
      "duration_seconds": 7,
      "owner": {
        "id": "5961534293",
        "username": "studio.luna12",
        "full_name": "Studio Luna",
        "is_private": false,
        "is_verified": false,
        "profile_pic_url": "https://scontent.cdninstagram.com/…/5961534293.jpg"
      },
      "location": {
        "id": "640596002",
        "name": "atelier Café"
      },
      "audio": {
        "id": "7215008767397414",
        "title": "olive atelier",
        "artist": "studio ivy"
      },
      "carousel": null
    }
  ],
  "pagination": {
    "next_cursor": "Ym9v…sealed…",
    "has_more": true,
    "page_size": 10
  },
  "meta": {
    "request_id": "req_…",
    "cached": false,
    "cache_age_seconds": 0,
    "credits_charged": 1,
    "credits_remaining": 26943
  }
}
```

## Examples

```bash
curl "https://api.handlehaul.com/v1/instagram/search/posts?q=matcha%20latte" -H "X-Api-Key: $HANDLEHAUL_API_KEY"
```

```javascript
const url = new URL("https://api.handlehaul.com/v1/instagram/search/posts");
url.searchParams.set("q", "matcha latte");
const res = await fetch(url, { headers: { "X-Api-Key": process.env.HANDLEHAUL_API_KEY } });
const { data, pagination } = await res.json();
for (const post of data) console.log(post.media_type, post.owner?.username, post.counts.views ?? post.counts.likes, post.url);
console.log("more:", pagination.has_more);
```

```python
import os, requests

r = requests.get(
    "https://api.handlehaul.com/v1/instagram/search/posts",
    params={"q": "matcha latte"},
    headers={"X-Api-Key": os.environ["HANDLEHAUL_API_KEY"]},
)
reels = [p for p in r.json()["data"] if p["media_type"] == "reel"]
print(len(reels), "reels on the first page")
```

```php
$ch = curl_init("https://api.handlehaul.com/v1/instagram/search/posts?q=matcha%20latte");
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/instagram/search/posts?q=matcha%20latte", 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"])
```

## On TikTok

`GET /v1/tiktok/search?q=&type=videos` searches TikTok videos in the same envelope. See the [TikTok Search API](/docs/tiktok-search-api).

## Errors

| Status | Code | When |
|---|---|---|
| 400 | `invalid_request` | `q` is missing or too long |
| 400 | `invalid_cursor` | The cursor came from another search |

## FAQ

### Can I search Instagram Reels by keyword with an API?
Yes. Call `/v1/instagram/search/posts?q=` and keep the results whose `media_type` is `reel`. Instagram mixes Reels and posts in its top search, and most results for popular words are Reels.

### Is it every post that mentions the word?
No. It is Instagram's ranked top results for the query, about 10 per page, which is what the Instagram app shows when you search a word.

### Are the results newest first?
No, they are in Instagram's ranking order. Use `taken_at` to sort or filter by date on your side.

### How is it different from hashtag search?
`/v1/instagram/search/hashtags` finds hashtags; `/v1/instagram/hashtags/{tag}/posts` lists top posts under one tag. This route searches a free-text keyword across posts and reels.
