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

# How do I continue from an Instagram post or Reel link to text, engagement and comments?

> Fetch Instagram post or Reel details from a URL via instagram.v2.fetch_post_info or instagram.v3.get_post_info, verify the shortcode, and extract string pk as media_id for instagram.fetch_post_comments_v2.

Pass the Instagram post or Reel URL as `code_or_url` to `instagram.v2.fetch_post_info`. Verify the shortcode and account in the detail response before reading `caption.text` and engagement fields. For comments, pass the string `pk` from the same detail response as `media_id` to `instagram.fetch_post_comments_v2`.

For example, for a launch Reel a colleague shared, one detail response supplies both the engagement snapshot and the `media_id` needed for the comment request.

## How do I request details from the link?

Pass the full URL or the shortcode as `code_or_url` to `data:instagram.v2.fetch_post_info`:

```bash
curl --fail-with-body -sS https://api.beatapi.io/v1/social-data/call \
  -H "Authorization: Bearer $BEATAPI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"action":"instagram.v2.fetch_post_info","params":{"code_or_url":"<post_url_or_shortcode>"}}' \
  -o instagram-post.json
```

The alternative detail action `data:instagram.v3.get_post_info` accepts a URL or a numeric `media_id`; the `url` parameter supports `/p/`, `/reel/`, `/reels/`, and `/tv/` paths. Pass the single target input you already have, and do not combine values that point to different posts.

## What do I confirm in the detail response?

Check the success status, shortcode, account, and caption. The v2 post object is at `data.data`. For v3, find the item whose `code` matches in `data.items[]`; do not assume the first item is your target. `caption.text` is the post caption, not a verbatim video transcript.

For engagement, use the [snapshot workflow](/guides/instagram-post-snapshot). For comments, `comment_handoff.py` below extracts `pk` from the matching post object. Keep the saved detail response and provenance metadata so later snapshot and comment steps reuse the saved response instead of repeating the detail request.

## I have a Reel URL, but the comment exporter needs media_id

`instagram.v2.fetch_post_info` and `instagram.v3.get_post_info` accept a URL, whereas `instagram.fetch_post_comments_v2` requires a numeric string `media_id`. Reuse a saved successful detail response, match the requested shortcode, and read the matched item's `pk`: `data.data.pk` in v2, or `data.items[].pk` on the single item with the matching `code` in v3. Do not use a user ID, a composite item `id`, the shortcode itself, or an ID that passed through a floating-point number.

If you already saved details for the metric-snapshot guide, do not pay for details again just to get `pk`. Create `detail-meta.json` beside the saved detail response, recording the actual request and collection time:

```json
{"action":"instagram.v2.fetch_post_info","params":{"code_or_url":"https://www.instagram.com/reel/ExampleCode/"},"http_status":200,"collected_at":"2026-11-17T03:45:00+08:00","response_file":"instagram-post.json"}
```

The URL is illustrative; use the exact shortcode or URL you requested. For v3, record `action` as `instagram.v3.get_post_info` and put the URL in `params.url`. Save the script below as `comment_handoff.py` and run `python3 comment_handoff.py detail-meta.json reel-comments`. The script writes the unchanged detail evidence and a first-page comment request into `reel-comments/` without sending the request.

```python
import hashlib,json,pathlib,re,sys
from datetime import datetime
from urllib.parse import urlsplit
meta_path,target=map(pathlib.Path,sys.argv[1:3])
m=json.loads(meta_path.read_text(encoding='utf-8'));action=m['action'];p=m['params']
if type(m.get('http_status')) is not int or m['http_status']!=200: raise ValueError('Require successful recorded HTTP status')
if action=='instagram.v2.fetch_post_info' and set(p)=={'code_or_url'}:
    supplied=p['code_or_url']
elif action=='instagram.v3.get_post_info' and not set(p)-{'url','media_id'} and p.get('media_id') in (None,''):
    supplied=p.get('url')
else: raise ValueError('Use one URL/shortcode detail input; do not mix identifiers')
if not isinstance(supplied,str) or not supplied: raise ValueError('Missing source target')
if action=='instagram.v2.fetch_post_info' and re.fullmatch(r'[A-Za-z0-9_-]+',supplied):
    code=supplied
else:
    u=urlsplit(supplied);match=re.fullmatch(r'/(?:p|reel|reels|tv)/([A-Za-z0-9_-]+)/?',u.path)
    if u.scheme!='https' or u.hostname not in ('instagram.com','www.instagram.com') or u.username or u.password or u.port not in (None,443) or not match:
        raise ValueError('Require supported Instagram post URL')
    code=match.group(1)
t=datetime.fromisoformat(m['collected_at'].replace('Z','+00:00'))
if t.tzinfo is None: raise ValueError('Use collection time with timezone')
raw=(meta_path.parent/m['response_file']).read_bytes();r=json.loads(raw)
if r.get('status')!='succeeded' or r.get('action')!=action or r.get('error'): raise ValueError('Failed or mismatched detail response')
rid=r.get('request_id')
if not isinstance(rid,str) or not rid.strip(): raise ValueError('Missing request ID')
if action=='instagram.v2.fetch_post_info':
    rows=[r['data']['data']]
else:
    rows=r['data']['items']
if not isinstance(rows,list) or not all(isinstance(x,dict) for x in rows): raise ValueError('Unexpected detail object structure')
matched=[x for x in rows if x.get('code')==code]
if len(matched)!=1: raise ValueError('Exactly one detail object must match the requested shortcode')
pk=matched[0].get('pk')
if not isinstance(pk,str) or not re.fullmatch(r'[1-9][0-9]*',pk):
    raise ValueError('Require original numeric-string pk; do not repair rounded numbers or split id')
request={'action':'instagram.fetch_post_comments_v2','params':{'media_id':pk,'sort_order':'recent'}}
evidence={'code':code,'media_id':pk,'detail_action':action,'detail_request_id':rid,'requested_target':supplied,
 'collected_at':m['collected_at'],'source_sha256':hashlib.sha256(raw).hexdigest(),'comments_requested':False}
target.mkdir(parents=True,exist_ok=False)
(target/'detail-source.json').write_bytes(raw)
for name,value in [('comments-request.json',request),('identity-evidence.json',evidence)]:
    (target/name).write_text(json.dumps(value,ensure_ascii=False,indent=2),encoding='utf-8')
print(json.dumps({'code':code,'comments_requested':False}))

```

Inspect `comments-request.json`: `media_id` must equal the original string `pk` of the code-matched item, and page one has no `min_id`. Keep `identity-evidence.json` and `detail-source.json` with the later comment archive. Send the `comments-request.json` body only within the comments budget, then save the actual response with the [root-comment export guide](/guides/instagram-comment-export). The saved detail proves which returned media ID you used; the saved detail does not prove that comments are available or that all replies were retrieved.

New details and new comments are charged separately at the current [pricing](https://beatapi.io/pricing). Reuse existing details and pay only for the selected comment step. When required fields are missing or the item match is ambiguous, review the source response before going further.

`comment_handoff.py` accepts `pk` only as the documented numeric string. `comment_handoff.py` refuses a bare JSON number even when Python can hold the integer, because a local script cannot repair precision loss introduced by an earlier numeric conversion. `comment_handoff.py` also does not derive `pk` by splitting a generic `id` field.