# Instagram Tagged Posts (`instagram.tagged_posts`)

Posts in which a public Instagram account is tagged, newest first, with the posting author, caption and engagement counts.

Docs: https://primaryapi.com/docs/api-reference/instagram/tagged_posts

- Endpoint: `POST https://api.primaryapi.com/v1/run/instagram.tagged_posts`
- Category: Social · Platform: `instagram` · Kind: list · Status: live
- Price: 1 credit per call; up to 35 credits if a call is retried elsewhere. A quote’s `maxCredits` is the most a given call can cost.
- Billing unit: per successful call
- Reliability: routed to a healthy upstream and retried automatically when an attempt fails; live 30-day status: `GET https://api.primaryapi.com/v1/status/apis?sku=instagram.tagged_posts`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `handle` | string | yes |  | max 100 chars | Instagram username, with or without the leading @. |
| `userId` | string | no |  | pattern: ^\d{1,24}$ | Numeric Instagram user id (pk) of the same account, e.g. from instagram.profile. Optional; id-keyed sources need it. |
| `limit` | integer | no | 12 | 1–50 | Maximum number of results to return (1-50, default 12). |
| `cursor` | string | no |  |  | Opaque pagination cursor: pass the previous response's nextCursor. |

Unknown fields are rejected with `400 invalid_input`. The routing controls `preferLatencyUnderMs` and `maxCredits` may be sent in the same JSON body.

## Output

When `output.found` is `true`, `output.data` has this shape:

| Field | Type | Description |
|---|---|---|
| `posts` | object[] |  |
| `posts[].id` | string | Instagram media id (pk) |
| `posts[].shortcode` | string \| null | Shortcode used in the public URL |
| `posts[].url` | string \| null | Canonical public URL |
| `posts[].productType` | string \| null | feed \| clips \| igtv \| carousel_container |
| `posts[].mediaType` | enum \| null |  |
| `posts[].caption` | string \| null |  |
| `posts[].hashtags` | string[] | Hashtags in the caption, without # |
| `posts[].mentions` | string[] | Accounts mentioned in the caption, without @ |
| `posts[].createdUtc` | integer \| null | Creation time, unix seconds (UTC) |
| `posts[].likes` | integer \| null |  |
| `posts[].comments` | integer \| null |  |
| `posts[].views` | integer \| null | Play/view count; null when hidden or not returned by the source |
| `posts[].reshares` | integer \| null |  |
| `posts[].durationSeconds` | number \| null |  |
| `posts[].carouselCount` | integer \| null | Number of slides in a carousel |
| `posts[].media` | object[] | Photo/video URLs (temporary signed CDN links) |
| `posts[].media[].type` | enum |  |
| `posts[].media[].url` | string |  |
| `posts[].media[].width` | integer \| null |  |
| `posts[].media[].height` | integer \| null |  |
| `posts[].thumbnail` | string \| null |  |
| `posts[].videoUrl` | string \| null |  |
| `posts[].hasAudio` | boolean \| null |  |
| `posts[].countsHidden` | boolean \| null | Owner hides like/view counts |
| `posts[].isPinned` | boolean \| null |  |
| `posts[].paidPartnership` | boolean \| null |  |
| `posts[].userId` | string \| null | Numeric id of the posting account |
| `posts[].username` | string \| null | Username of the posting account |
| `posts[].displayName` | string \| null |  |
| `posts[].verified` | boolean \| null |  |
| `posts[].avatarUrl` | string \| null |  |
| `posts[].taggedUsers` | string[] | Usernames tagged in the media |
| `posts[].coauthors` | string[] | Collab co-author usernames |
| `posts[].locationId` | string \| null |  |
| `posts[].locationName` | string \| null |  |
| `posts[].locationLat` | number \| null |  |
| `posts[].locationLng` | number \| null |  |
| `posts[].audioId` | string \| null |  |
| `posts[].soundTitle` | string \| null |  |
| `posts[].soundAuthor` | string \| null |  |
| `posts[].author` | string \| null | Username of the account that published the post and tagged this user |
| `nextCursor` | string \| null |  |

When the thing you asked about does not exist (or a search matches nothing) the call still succeeds: `output.found` is `false`, `output.data` is `null` and `output.reason` says why (`not_found`, `private`, `no_results`, …). Misses are free unless the notes below say misses are billed.

Pagination: pass the previous response’s `nextCursor` as `cursor` to get the next page; `nextCursor: null` means there are no more results.

## Example request

```bash
curl -sS -X POST "https://api.primaryapi.com/v1/run/instagram.tagged_posts" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"handle":"nasa","userId":"528817151"}'
```

## Example response

_Values are placeholders that follow the output schema; `credits` is what this call would cost at the usual price._

```json
{
  "output": {
    "found": true,
    "data": {
      "posts": [
        {
          "id": "string",
          "shortcode": "string",
          "url": "https://example.com",
          "productType": "string",
          "mediaType": "image",
          "caption": "string",
          "hashtags": [
            "string"
          ],
          "mentions": [
            "string"
          ],
          "createdUtc": 0,
          "likes": 0,
          "comments": 0,
          "views": 0,
          "reshares": 0,
          "durationSeconds": 0,
          "carouselCount": 0,
          "media": [
            {
              "type": "image",
              "url": "https://example.com",
              "width": 0,
              "height": 0
            }
          ],
          "thumbnail": "string",
          "videoUrl": "https://example.com",
          "hasAudio": true,
          "countsHidden": true,
          "isPinned": true,
          "paidPartnership": true,
          "userId": "528817151",
          "username": "string",
          "displayName": "string",
          "verified": true,
          "avatarUrl": "https://example.com",
          "taggedUsers": [
            "string"
          ],
          "coauthors": [
            "string"
          ],
          "locationId": "string",
          "locationName": "string",
          "locationLat": 0,
          "locationLng": 0,
          "audioId": "string",
          "soundTitle": "string",
          "soundAuthor": "string",
          "author": "string"
        }
      ],
      "nextCursor": null
    }
  },
  "provider": "PrimaryAPI",
  "credits": 1,
  "items": 1,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z",
  "nextCursor": null
}
```

## Pricing and reliability

- Usual price: 1 credit per call
- Price ceiling: up to 35 credits if a call is retried elsewhere. A quote’s `maxCredits` is the most a given call can cost; the `maxCredits` routing control caps it per call
- Live 30-day status, success rate, uptime and latency: `GET https://api.primaryapi.com/v1/status/apis?sku=instagram.tagged_posts`

## Errors to handle

`invalid_input`, `unauthorized`, `insufficient_balance`, `key_limit_reached`, `trial_cap_reached`, `forbidden`, `not_found`, `idempotency_conflict`, `rate_limited`, `all_sources_failed`, `service_unavailable`, `timeout`. See https://primaryapi.com/docs/errors.

## Notes

Tagged posts expose third parties: pass through, do not retain beyond cache TTL.

