> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.spyglass.so/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.spyglass.so/_mcp/server.

# Fetch Instagram or TikTok comments

POST https://api.spyglass.so/v2/comments
Content-Type: application/json

Return public comments for specific Instagram or TikTok posts.
Pass post URLs or the platform id. At least one of `instagramIds` or
`tiktokIds` is required (max 20 each). `limit` is comment pages
per post (default 1, max 20).

Instagram accepts a shortcode or a post URL:

- `C2xY9abcD1e`
- `https://www.instagram.com/p/C2xY9abcD1e/`
- `https://www.instagram.com/reel/C2xY9abcD1e/`

TikTok accepts a video id or a post URL:

- `7234567890123456789`
- `https://www.tiktok.com/@nike/video/7234567890123456789`

Recent posts may be scraped live; older posts with stored comments
are served from cache.

Limited to 20 requests per minute per user.
Costs $0.0050 per successful page of comments returned, charged against your plan's monthly credits.
Each comment page fetched live (`limit`, default 1) is one billed
unit. Cached posts do not scrape and are not billed.

Reference: https://docs.spyglass.so/api-reference/spyglass-api/search/get-comments

## Authentication

- `Authorization` header (bearer token, required) — An API key from Settings → API, prefixed sg_live_.

## Request

### Body (application/json)

This endpoint expects an object.

- `instagramIds` (list of string, optional) — Instagram post shortcodes or post URLs
- `tiktokIds` (list of string, optional) — TikTok video ids or post URLs
- `limit` (integer, optional) — Comment pages to fetch per post. Default 1.

## Response

### 200

Comments grouped by post.

- `count` (integer, required)
- `posts` (list of CommentsPostResponsesContentApplicationJsonSchemaPostsItems, required)

## Errors

### 400 Bad Request Error

The request body or query string failed validation. `details` lists the offending fields.

- `error` (ErrorError, required)

### 401 Unauthorized Error

The API key is missing, malformed, unknown, or revoked.

- `error` (ErrorError, required)

### 402 Payment Required Error

The team's monthly credits are exhausted.

- `error` (ErrorError, required)

### 403 Forbidden Error

The team's subscription is inactive, or your membership of it has ended.

- `error` (ErrorError, required)

### 405 Method Not Allowed Error

The HTTP method is not supported on this path. The Allow header lists what is. HEAD is refused on metered GET endpoints because it would be billed without returning data.

- `error` (ErrorError, required)

### 413 Content Too Large Error

The request body exceeds the 100 KB limit.

- `error` (ErrorError, required)

### 429 Too Many Requests Error

Too many requests for this user on this endpoint. Carries a Retry-After header. The per-minute limit is stated on the operation.

- `error` (ErrorError, required)

### 500 Internal Server Error

Something went wrong on our side.

- `error` (ErrorError, required)

## Types

### CommentsPostResponsesContentApplicationJsonSchemaPostsItems

- `platform` (string, required)
- `platformPostId` (string, required)
- `comments` (list of CommentsPostResponsesContentApplicationJsonSchemaPostsItemsCommentsItems, required)
- `error` (string, optional)

### ErrorError

- `code` (enum, required)
  - Allowed values: `invalid_request`, `invalid_api_key`, `payload_too_large`, `out_of_credits`, `membership_ended`, `subscription_inactive`, `brand_not_found`, `not_found`, `method_not_allowed`, `rate_limited`, `internal_error`
- `message` (string, required)
- `details` (list of ErrorErrorDetailsItems, optional)

### CommentsPostResponsesContentApplicationJsonSchemaPostsItemsCommentsItems

- `platformId` (string, required)
- `text` (string, required)
- `likeCount` (double, required)
- `replyCount` (double, required, nullable)
- `publishedAt` (string, required)
- `isPinned` (boolean, required, nullable)
- `username` (string, required)
- `displayName` (string, required)
- `isVerified` (boolean, required)

### ErrorErrorDetailsItems

- `path` (string, required)
- `message` (string, required)

## Examples

**Request**

```json
{
  "instagramIds": [
    "https://www.instagram.com/p/C2xY9abcD1e/"
  ],
  "tiktokIds": [
    "https://www.tiktok.com/@nike/video/7234567890123456789"
  ],
  "limit": 1
}
```

**Response**

```json
{
  "count": 1,
  "posts": [
    {
      "platform": "string",
      "platformPostId": "string",
      "comments": [
        {
          "platformId": "string",
          "text": "string",
          "likeCount": 1.1,
          "replyCount": 1.1,
          "publishedAt": "string",
          "isPinned": true,
          "username": "string",
          "displayName": "string",
          "isVerified": true
        }
      ],
      "error": "string"
    }
  ]
}
```

**SDK Code**

```python getComments_example
import requests

url = "https://api.spyglass.so/v2/comments"

payload = {
    "instagramIds": ["https://www.instagram.com/p/C2xY9abcD1e/"],
    "tiktokIds": ["https://www.tiktok.com/@nike/video/7234567890123456789"],
    "limit": 1
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript getComments_example
const url = 'https://api.spyglass.so/v2/comments';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"instagramIds":["https://www.instagram.com/p/C2xY9abcD1e/"],"tiktokIds":["https://www.tiktok.com/@nike/video/7234567890123456789"],"limit":1}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go getComments_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.spyglass.so/v2/comments"

	payload := strings.NewReader("{\n  \"instagramIds\": [\n    \"https://www.instagram.com/p/C2xY9abcD1e/\"\n  ],\n  \"tiktokIds\": [\n    \"https://www.tiktok.com/@nike/video/7234567890123456789\"\n  ],\n  \"limit\": 1\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby getComments_example
require 'uri'
require 'net/http'

url = URI("https://api.spyglass.so/v2/comments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"instagramIds\": [\n    \"https://www.instagram.com/p/C2xY9abcD1e/\"\n  ],\n  \"tiktokIds\": [\n    \"https://www.tiktok.com/@nike/video/7234567890123456789\"\n  ],\n  \"limit\": 1\n}"

response = http.request(request)
puts response.read_body
```

```java getComments_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.spyglass.so/v2/comments")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"instagramIds\": [\n    \"https://www.instagram.com/p/C2xY9abcD1e/\"\n  ],\n  \"tiktokIds\": [\n    \"https://www.tiktok.com/@nike/video/7234567890123456789\"\n  ],\n  \"limit\": 1\n}")
  .asString();
```

```php getComments_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.spyglass.so/v2/comments', [
  'body' => '{
  "instagramIds": [
    "https://www.instagram.com/p/C2xY9abcD1e/"
  ],
  "tiktokIds": [
    "https://www.tiktok.com/@nike/video/7234567890123456789"
  ],
  "limit": 1
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp getComments_example
using RestSharp;

var client = new RestClient("https://api.spyglass.so/v2/comments");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"instagramIds\": [\n    \"https://www.instagram.com/p/C2xY9abcD1e/\"\n  ],\n  \"tiktokIds\": [\n    \"https://www.tiktok.com/@nike/video/7234567890123456789\"\n  ],\n  \"limit\": 1\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift getComments_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "instagramIds": ["https://www.instagram.com/p/C2xY9abcD1e/"],
  "tiktokIds": ["https://www.tiktok.com/@nike/video/7234567890123456789"],
  "limit": 1
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.spyglass.so/v2/comments")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```