Before you start
- Get an API keySign up for 100 free credits, no card. Keys start with
gs_live_. - Put it in the environmentEvery example reads it from
GROUNDSOCIAL_API_KEY:export GROUNDSOCIAL_API_KEY=gs_live_… - Set up Go
go mod init example
Call Instagram popular search API from Go
GET /v1/instagram/search/popular. Save this as main.go and run go run main.go. It reads the items in items and prints caption.text and play_count for each.
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"net/url"
"os"
"time"
)
// The fields this program reads, as the recorded response has them.
type Page struct {
Items []struct {
Caption struct {
Text string `json:"text"`
} `json:"caption"`
PlayCount float64 `json:"play_count"`
} `json:"items"`
}
var client = &http.Client{Timeout: 60 * time.Second}
func fetch(q url.Values) (*Page, error) {
req, err := http.NewRequest("GET", "https://api.groundsocial.dev/v1/instagram/search/popular"+"?"+q.Encode(), nil)
if err != nil {
return nil, err
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("GROUNDSOCIAL_API_KEY"))
res, err := client.Do(req)
if err != nil {
return nil, err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
var e struct {
Error struct {
Code string `json:"code"`
Hint string `json:"hint"`
Retryable bool `json:"retryable"`
} `json:"error"`
}
json.NewDecoder(res.Body).Decode(&e)
return nil, fmt.Errorf("%s: %s", e.Error.Code, e.Error.Hint)
}
var page Page
if err := json.NewDecoder(res.Body).Decode(&page); err != nil {
return nil, err
}
return &page, nil
}
func main() {
q := url.Values{}
q.Set("query", "basketball")
page, err := fetch(q)
if err != nil {
log.Fatal(err)
}
for _, item := range page.Items {
fmt.Println(item.Caption.Text, item.PlayCount)
}
}The response
A real Instagram response to this call, recorded from the live API on 27 Nov 2026 and shortened for display: arrays keep their first items and … marks every cut. The recorded page had 24 items in items. Live calls return current data in the same shape.
{
"query": "basketball",
"slug": "basketball",
"description": "Basketball is a team sport played by two teams of five players on a rectangular court. The goal is to shoot the ball thr…",
"related_keywords": [
"the tallest basketball player",
"dylan schmidt illinois basketball",
"… 8 more"
],
"items": [
{
"pk": "3738278218404085157",
"id": "3738278218404085157_59411821286",
"code": "DPhCDu_jj2l",
"url": "https://www.instagram.com/p/DPhCDu_jj2l/",
"taken_at": 1759857516,
"media_type": 1,
"product_type": null,
"caption": {
"text": "These moves will make you SHIFTY. 🤝🎒 #basketball #sports #athlete #nba #hooper #trending #reels #viral #explore #explore…"
},
"like_count": null,
"comment_count": null,
"like_and_view_counts_disabled": false,
"user": {
"pk": "59411821286",
"username": "woahhelijah",
"profile_pic_url": "https://scontent-lax3-1.cdninstagram.com/v/t51.82787-19/610894561_17974982900981287_5001518987003621074_n.jpg?stp=dst-jp…",
"is_verified": true
},
"play_count": 714888,
"image_versions2": {
"candidates": [
{
"url": "https://scontent-lax7-1.cdninstagram.com/v/t51.82787-15/561460207_17965312502981287_577210961086174914_n.jpg?stp=dst-jpg…",
"width": null,
"height": null
}
]
},
"video_versions": [
{
"url": "https://scontent-lax3-2.cdninstagram.com/o1/v/t2/f2/m86/AQOL5CzApQ4By69Qu9wJuwXCS4kObfMwME4ecezKH0gC6Yg5MQjOpO8oXtg2SYFU…",
"width": null,
"height": null
},
{
"url": "https://scontent-lax3-2.cdninstagram.com/o1/v/t2/f2/m86/AQOL5CzApQ4By69Qu9wJuwXCS4kObfMwME4ecezKH0gC6Yg5MQjOpO8oXtg2SYFU…",
"width": null,
"height": null
},
"… 1 more"
]
},
{
"pk": "3983670629257431716",
"id": "3983670629257431716_61085633952",
"code": "DdI11S3C8qk",
"url": "https://www.instagram.com/p/DdI11S3C8qk/",
"taken_at": 1789110607,
"media_type": 1,
"product_type": null,
"caption": {
"text": "The kind of peace you can’t buy ♱\n\nHooping my way through life, follow my journey, same court tomorrow ♱\n\n#hoops #hooper…"
},
"like_count": null,
"comment_count": null,
"like_and_view_counts_disabled": false,
"user": {
"pk": "61085633952",
"username": "jmilyone",
"profile_pic_url": "https://scontent-lax3-1.cdninstagram.com/v/t51.82787-19/837858166_17997172263033953_8502340270251305704_n.jpg?stp=dst-jp…",
"is_verified": false
},
"play_count": 837519,
"image_versions2": {
"candidates": [
{
"url": "https://scontent-lax3-2.cdninstagram.com/v/t51.82787-15/930123953_18004943484033953_4777618756943601532_n.jpg?stp=dst-jp…",
"width": null,
"height": null
}
]
},
"video_versions": [
{
"url": "https://scontent-lax3-2.cdninstagram.com/o1/v/t2/f2/m86/AQMEEWQBr8hl9Qvxj2Vph7WrM4f2Pu9c5_wW-Plfs1q7JtUOxtQBK-NP5E7IDysL…",
"width": null,
"height": null
},
{
"url": "https://scontent-lax3-2.cdninstagram.com/o1/v/t2/f2/m86/AQMEEWQBr8hl9Qvxj2Vph7WrM4f2Pu9c5_wW-Plfs1q7JtUOxtQBK-NP5E7IDysL…",
"width": null,
"height": null
},
"… 1 more"
]
},
"… 22 more"
]
}Top-level fields
| Field | Type | Description |
|---|---|---|
query | string | – |
slug | string | The keyword page: instagram.com/popular/<slug>/. |
description | string | null | The summary Instagram shows on the keyword page, when it has one. |
related_keywords | string[] | – |
items | InstagramMedia[] | – |
Parameters
| Name | In | Type | Description |
|---|---|---|---|
query (required) | query | string | Topic. Example: basketball. |
Errors and retries
Every error is JSON with error.code (stable: branch on it), message, hint (what to do next), docs_url and retryable. A failed call is never charged. Retry only when retryable is true, after the Retry-After header.
// fetch returns the API error as "code: hint". To retry the retryable ones
// (rate_limited, upstream_timeout), wait for Retry-After and call again:
for attempt := 0; attempt < 3; attempt++ {
page, err = fetch(q)
if err == nil {
break
}
time.Sleep(2 * time.Second)
}| Status | Meaning |
|---|---|
200 | The topic page. |
400 | Invalid input. Nothing was charged. |
401 | Missing or invalid API key. |
402 | Not enough credits, a spend cap was reached, or payment is required. |
403 | The target is private, or the account is suspended. |
404 | The account or post does not exist, or was removed. |
429 | Too many requests. Wait for Retry-After seconds. |
503 | Instagram is temporarily unavailable. Retryable; nothing was charged. |
Every error code and what to do about it.
Pricing
| Cost | |
|---|---|
| Per call | 1 credit per call |
| 1,000 calls | $1.00 on the starter pack, $0.40 at volume |
| No key (MPP or x402) | $0.01 per call |
| Failed call | Refunded, never charged |
Every response has x-credits-charged and x-credits-remaining headers. Credits never expire. Packs and calculator.
From an AI agent (MCP)
The same call is the instagram_search_popular tool on the hosted MCP server, so Claude, Cursor or any MCP client can make it without code. Add the server once:
claude mcp add --transport http groundsocial https://api.groundsocial.dev/mcpThen ask for it in words (“Instagram’s popular-search page for a topic: top posts, summary, related searches”), or call the tool directly:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "instagram_search_popular",
"arguments": {
"query": "basketball"
}
}
}MCP setup for Claude Desktop, Cursor, VS Code and ChatGPT.
Find what a topic’s top posts look like
Compare play_count across the page’s reels.
Keep going
- This call in Python, JavaScript, TypeScript, PHP, cURL.
- Instagram popular search API reference: every field and status code.
- Instagram tutorials and all Go tutorials.
- Instagram API: every endpoint and price.
- How to scrape Instagram reels search with Go: Instagram reels about a keyword, with captions and counts.
- How to scrape Instagram hashtag search with Go: Instagram posts and reels carrying a hashtag.
- How to scrape Instagram profile search with Go: Instagram profiles matching a name or topic, with counts.
- How to scrape Instagram search with Go: Instagram accounts, hashtags and places matching a name.
- How to scrape Instagram mentions with Go: Instagram posts by others that mention an account.
- How to scrape Instagram profile with Go: A public Instagram profile: bio, links, follower and post counts, highlights, and its latest posts.
Run it on your own data
One key for Instagram and 76 more platforms, over REST or MCP. Free credits on signup, no card.
Instagram is a trademark of Instagram, LLC (Meta Platforms, Inc.). We are not affiliated with or endorsed by Instagram or Meta.