> ## Documentation Index
> Fetch the complete documentation index at: https://docs.influship.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Download Instagram Videos

> How to retrieve fresh, downloadable URLs for Instagram video posts via the raw endpoints.

# Download Instagram Videos

The raw Instagram endpoints return fresh signed CDN URLs you can download directly. Cached endpoints like `GET /v1/posts` do not expose video URLs — those would be stale by the time you fetch them.

## Single video

Call `GET /v1/raw/instagram/post/:shortcode` (1 credit, \$0.01). The response includes `video_url` (single best stream) and `video_versions[]` (multi-bitrate variants).

```bash theme={null}
SHORTCODE="CXY123abc"
curl -s "https://api.influship.com/v1/raw/instagram/post/$SHORTCODE" \
  -H "X-API-Key: $INFLUSHIP_API_KEY" \
  | jq -r '.data.video_url' \
  | xargs -I{} wget -O "$SHORTCODE.mp4" "{}"
```

Use `video_versions[]` if you need a specific bitrate or resolution — each entry includes a `url` and a `type` field identifying the stream quality.

## All recent videos from a creator (bulk)

Call `GET /v1/raw/instagram/profile/:username` (0.5 credits, \$0.005). The `posts[]` array returns up to 12 recent posts with `video_url` for each video post.

This is the cheapest bulk-download path — a single profile call covers up to 12 posts, significantly cheaper than calling the single-post endpoint per shortcode.

```bash theme={null}
USERNAME="creator"
curl -s "https://api.influship.com/v1/raw/instagram/profile/$USERNAME" \
  -H "X-API-Key: $INFLUSHIP_API_KEY" \
  | jq -r '.data.posts[] | select(.is_video) | "\(.shortcode)\t\(.video_url)"' \
  | while IFS=$'\t' read -r sc url; do
      wget -O "${sc}.mp4" "$url"
    done
```

## Carousel posts with videos

For carousel posts that contain video items, each slide is exposed in `carousel_items[]`. Filter by `is_video` to isolate the video items:

```bash theme={null}
SHORTCODE="CXY456def"
curl -s "https://api.influship.com/v1/raw/instagram/post/$SHORTCODE" \
  -H "X-API-Key: $INFLUSHIP_API_KEY" \
  | jq -r '.data.carousel_items[] | select(.is_video) | "\(.index)\t\(.video_url)"' \
  | while IFS=$'\t' read -r idx url; do
      wget -O "${SHORTCODE}_${idx}.mp4" "$url"
    done
```

## URL lifetime

`video_url` and `video_versions[].url` are signed Instagram CDN URLs valid for approximately 24 hours from the moment of the API call. Download promptly. If you need to retain videos long-term, store them on your own infrastructure — re-requesting the same shortcode after the URLs expire costs an additional credit.

## Cost summary

| Pattern                          | Endpoint                                   | Credits |    Cost |
| -------------------------------- | ------------------------------------------ | ------: | ------: |
| Single video                     | `GET /v1/raw/instagram/post/{shortcode}`   |       1 |  \$0.01 |
| Up to 12 videos from one creator | `GET /v1/raw/instagram/profile/{username}` |     0.5 | \$0.005 |
| Carousel (per post)              | `GET /v1/raw/instagram/post/{shortcode}`   |       1 |  \$0.01 |

## Implementation advice

* **Prefer the profile endpoint for bulk work.** If you want the recent video content from a specific creator, one profile call is cheaper than calling the post endpoint per shortcode.
* **Download before storing the URL.** Don't cache the signed URL itself — it expires. Either download the file immediately or re-fetch the URL when you need it.
* **Check `is_video` before downloading.** Both profile `posts[]` and carousel `carousel_items[]` contain mixed photo and video items. Filtering on `is_video: true` avoids requesting video fields that aren't present on photo posts.

## Terms of service

Instagram's terms of service govern downloaded content. Use videos in accordance with applicable law and Instagram's ToS.
