# Instagram Video Downloader - Reels & IGTV, Pay-Per-Video (`epctex/instagram-video-downloader`) Actor

Downloads videos from Instagram posts, reels, and IGTV by URL and re-hosts them to Apify, AWS S3, Google Cloud, DigitalOcean, or Azure. $0.02 per video, no subscription, carousel-aware, with automatic dedup across duplicate URLs.

- **URL**: https://apify.com/epctex/instagram-video-downloader.md
- **Developed by:** [epctex](https://apify.com/epctex) (community)
- **Categories:** Social media, Videos
- **Features:** Limited permissions
- **Stats:** 1,377 total users, 83 monthly users, 100.0% runs succeeded, 71 bookmarks
- **User rating**: 4.91 out of 5 stars

## Pricing

$20.00 / 1,000 download videos

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Instagram Video Downloader

Instagram Video Downloader is an Apify actor that extracts and re-hosts videos from Instagram post, reel, and IGTV URLs. Each downloaded video costs $0.02, or $20.00 per 1,000 videos, billed only on successful delivery to your chosen storage.

The Instagram Video Downloader runs one operating mode across 3 Instagram content types, accepts 28 input fields covering 4 storage providers, and returns 9 output fields per video through 1 pay-per-event charge type. Every price on this page is a per-event charge with no subscription and no monthly minimum.

### What Does the Instagram Video Downloader Extract?

The Instagram Video Downloader extracts every video attached to an Instagram feed post, reel, or IGTV entry, including every video inside a multi-media carousel post. The table below lists the 4 source types it covers.

| Source | How to Target It | What It Covers |
|---|---|---|
| Feed posts | Post URLs (`/p/{shortcode}/`) in `startUrls` | Every video attached to a standard feed post, including carousels |
| Reels | Reel URLs (`/reel/{shortcode}/` or `/reels/{shortcode}/`) in `startUrls` | The reel video |
| IGTV | IGTV URLs (`/tv/{shortcode}/`) in `startUrls` | The IGTV video |
| Carousel posts | Any of the above URL types pointing at a multi-media post | Every video in the carousel, one result per video, numbered by its position |

### Which Instagram URLs Does the Instagram Video Downloader Accept?

The Instagram Video Downloader accepts 4 URL path patterns inside `startUrls`, listed below.

- **`/p/{shortcode}/`** targets a standard feed post.
- **`/reel/{shortcode}/`** targets a reel.
- **`/reels/{shortcode}/`** targets the same reel under Instagram's alternate path.
- **`/tv/{shortcode}/`** targets an IGTV entry.

Every URL is matched against the same shortcode. A post entered as `/p/{shortcode}/`, `/reel/{shortcode}/`, and `/tv/{shortcode}/` in one run resolves once and is downloaded, and charged, once.

### Who Uses the Instagram Video Downloader?

Listed below are the 5 roles that run the Instagram Video Downloader against Instagram video content.

- **Social media and content teams** pull campaign or influencer videos into `downloadUrl` for repurposing or cross-platform reposting, instead of relying on Instagram's own short-lived media links.
- **Marketing and brand monitoring functions** re-host UGC, branded content, or competitor posts by feeding `startUrls` from a tracked list and reading `storageType` back to confirm delivery.
- **Agencies and freelancers** batch a client's `startUrls` list against the client's own `s3Bucket`, `googleCloudBucketName`, `digitalOceanBucketName`, or `azureContainerName` as part of a deliverable pipeline.
- **Product and dev teams building on Apify** call the actor through the Apify API, budgeting runs against the fixed `$0.02` `video-download` event instead of a variable proxy cost.
- **Researchers and archivists** collect a reproducible set of public Instagram video content, defined by an explicit `startUrls` list, and use `jobId` and `inputSource` to trace each result back to its query.

### What Does the Instagram Video Downloader Cost?

The Instagram Video Downloader charges 1 event type. **Each `video-download` event costs $0.02, or $20.00 per 1,000 videos.**

| Event Type | Price | What's Included |
|---|---|---|
| `video-download` | $0.02 | Charged once per video successfully downloaded and re-hosted to your storage |

> **When you're charged:** You only pay for data you receive. Failed requests, aborted runs and results beyond your maximum items or maximum cost are never charged. Free-plan runs that are rejected by plan limits, or that can't start within the plan's budget, are charged a small fee.

#### Instagram Video Downloader Cost Examples

The table below prices 5 scenarios against the rate card above.

| Scenario | Charge Events | Calculation | Total Cost |
|---|---|---|---|
| 1 post, 1 video | 1 `video-download` | $0.02 x 1 | $0.02 |
| 1 carousel post, 6 videos | 6 `video-download` | $0.02 x 6 | $0.12 |
| 1 image-only post | none | n/a | $0.00 |
| 1 private or deleted post | none | n/a | $0.00 |
| 1 malformed or non-Instagram URL | none | n/a | $0.00 |

#### Instagram Video Downloader Unit Economics

The 4 figures below are derived from the rate card above. None of them include a subscription or platform fee, because the Instagram Video Downloader has neither.

| Metric | Value |
|---|---|
| Cost per video | $0.02 |
| Videos per $1 | 50 |
| Cost per 1,000 videos | $20.00 |
| Videos per $10 | 500 |

#### How Does the Instagram Video Downloader Free Plan Work?

The Instagram Video Downloader checks, before starting, whether its run's cost ceiling can cover even 1 `video-download` event. When it cannot and the account is not on a paid plan, the actor charges for a small number of `video-download` events, 10 by default in the actor's configuration, and returns that many placeholder items shaped `{ "demo": true }` instead of downloading real videos. This lets a Free-plan account see the output shape before subscribing. On the Free plan, `maxItems` is fixed by the plan's own configuration; the value entered in the input is ignored. For unrestricted use, subscribe to a paid plan.

### How Is the Instagram Video Downloader Configured?

The Instagram Video Downloader exposes 28 input fields: 4 core fields, 4 delivery fields and 20 storage-provider fields split across 4 providers.

| Field | Type | Required | Description | Default |
|---|---|---|---|---|
| `startUrls` | array | Yes | Instagram post, reel, or IGTV URLs to download videos from. | `[]` |
| `storageType` | string | Yes | Target storage provider: `apify`, `gcp`, `aws`, `digitalocean`, or `azure`. Fill the matching configuration section below. | `apify` |
| `maxItems` | integer | No | Maximum number of items to output (minimum `1`). Leave empty for no limit. | no limit |
| `customMapFunction` | string | No | Function that takes each output object as an argument and returns the mapped data, e.g. `(object) => { return {...object} }`. Must be synchronous; it runs in a sandbox with plain JavaScript only (no network requests, `require` or `console`) and about 1 second per item. Not intended for filtering. Leave empty to keep the output as-is; an unusable function is ignored and the original items are saved instead. | `null` |
| `outputConnector` | string | No | MCP connector to deliver the results to — pick one (see [How Do You Send Instagram Video Downloader Results to Notion, Todoist and More?](#how-do-you-send-instagram-video-downloader-results-to-notion-todoist-and-more)). | `null` |
| `deliverTarget` | string | No | Where the connector writes — paste the URL or ID (Notion example: `https://www.notion.so/My-Posts-24f8a1b2c3d44e5f8a9b0c1d2e3f4a5b`); some services need none. | `null` |
| `deliverMode` | string | No | `perPost` (one record per item) or `summary` (one roll-up per run). | `perPost` |
| `deliverMaxItems` | integer | No | Optional cap on how many records `perPost` delivers (ignored in `summary`). | `null` |

#### Which Storage Configuration Fields Does the Instagram Video Downloader Use?

Fill in the section matching your `storageType`. Fields marked **Secret** are masked in the Apify Console and never logged.

**AWS S3 Configuration** (`storageType: "aws"`), 5 fields

| Field | Type | Secret | Description |
|---|---|---|---|
| `s3AccessKeyId` | string | No | AWS access key ID. |
| `s3SecretAccessKey` | string | Yes | AWS secret access key. |
| `s3Region` | string | No | AWS region. |
| `s3Bucket` | string | No | Target S3 bucket name. |
| `s3Path` | string | No | Optional folder path in the S3 bucket. |

**Google Cloud Storage Configuration** (`storageType: "gcp"`), 4 fields

| Field | Type | Secret | Description |
|---|---|---|---|
| `googleCloudProjectId` | string | No | GCP project ID. |
| `googleCloudServiceKeyJson` | object | Yes | Service account credentials JSON. |
| `googleCloudBucketName` | string | No | Target Google Cloud Storage bucket name. |
| `googleCloudPath` | string | No | Optional folder path in the GCS bucket. |

**DigitalOcean Spaces Configuration** (`storageType: "digitalocean"`), 7 fields

| Field | Type | Secret | Description |
|---|---|---|---|
| `digitalOceanAccessKeyId` | string | No | DigitalOcean Spaces access key ID. |
| `digitalOceanSecretAccessKey` | string | Yes | DigitalOcean Spaces secret access key. |
| `digitalOceanRegion` | string | No | DigitalOcean Spaces region (e.g. `nyc3`). |
| `digitalOceanBucketName` | string | No | DigitalOcean Spaces bucket name. |
| `digitalOceanEndpoint` | string | No | Optional Spaces endpoint URL. |
| `digitalOceanAcl` | string | No | Optional ACL value (defaults to private). |
| `digitalOceanPath` | string | No | Optional folder path in the Spaces bucket. |

**Azure Storage Configuration** (`storageType: "azure"`), 4 fields

| Field | Type | Secret | Description |
|---|---|---|---|
| `azureAccountName` | string | No | Azure storage account name. |
| `azureAccountKey` | string | Yes | Azure storage account key. |
| `azureContainerName` | string | No | Azure container name. |
| `azurePath` | string | No | Optional folder path in the Azure container. |

### Which Input Rules Does the Instagram Video Downloader Enforce?

The Instagram Video Downloader enforces 7 input rules covering URL validation, deduplication, and storage credentials.

| Rule | What It Means |
|---|---|
| `startUrls` is required and cannot be empty | A missing or empty `startUrls` fails the run with "Instagram start URLs must be provided" before it starts. |
| Only `/p/`, `/reel/`, `/reels/`, and `/tv/` URLs are accepted | Any other Instagram URL, or a non-Instagram URL, is reported with `invalidUrl` status and never sent to the resolver. |
| Duplicate shortcodes are deduplicated | The same post entered under more than one of `/p/`, `/reel/`, `/reels/`, or `/tv/` resolves once, by shortcode; only the first occurrence is processed. |
| `storageType` defaults to `apify` | An input saved without `storageType` runs against Apify's key-value store instead of failing. |
| Missing storage credentials fail the run | A `storageType` of `aws`, `gcp`, `digitalocean`, or `azure` without its required fields, for example `s3Bucket` for AWS, fails the run before any video is downloaded. |
| `maxItems` has a minimum of 1 | A `maxItems` value below 1 is rejected by the input schema. |
| `maxItems` is ignored on the Free plan | The Free plan's item limit comes from its own plan configuration regardless of the `maxItems` value entered. |

### How Do You Run the Instagram Video Downloader with Apify Storage?

The Instagram Video Downloader defaults `storageType` to `apify`, so a run needs only `startUrls` to deliver videos into Apify's built-in key-value store.

```json
{
  "startUrls": [
    "https://www.instagram.com/p/CuKHeY_PLbZ/",
    "https://www.instagram.com/reel/DdBT6qbjGaQ/"
  ],
  "storageType": "apify"
}
```

### How Do You Run the Instagram Video Downloader with Your Own Cloud Storage?

The Instagram Video Downloader re-hosts every video to `aws`, `gcp`, `digitalocean`, or `azure` when `storageType` and that provider's credential fields are filled in. The example below targets an AWS S3 bucket.

```json
{
  "startUrls": ["https://www.instagram.com/p/CuKHeY_PLbZ/"],
  "storageType": "aws",
  "s3AccessKeyId": "AKIA...",
  "s3SecretAccessKey": "...",
  "s3Region": "us-east-1",
  "s3Bucket": "my-video-archive",
  "s3Path": "instagram/"
}
```

### How Do You Cap an Instagram Video Downloader Run's Volume?

The Instagram Video Downloader stops adding items once `maxItems` is reached, on paid plans. The example below caps a 3-URL run at 2 output items.

```json
{
  "startUrls": [
    "https://www.instagram.com/p/CuKHeY_PLbZ/",
    "https://www.instagram.com/reel/DdBT6qbjGaQ/",
    "https://www.instagram.com/tv/Cp1a2B3cD4e/"
  ],
  "storageType": "apify",
  "maxItems": 2
}
```

### How Do You Send Instagram Video Downloader Results to Notion, Todoist and More?

Skip the manual exports — the Instagram Video Downloader can deliver its results directly into the tools you already work in, through [Apify MCP Connectors](https://apify.com/store/collections/mcp-connectors):

1. Authorize a connector (Notion, Todoist, or any service whose MCP server offers non-destructive write tools) once in [Console → Settings → API & Integrations → MCP connectors](https://console.apify.com/settings/integrations).
2. Pick it from the **Send results to Notion, Todoist, …** dropdown.
3. Fill in where and how to write:
   - **Destination target** — paste the URL or ID (Notion example: `https://www.notion.so/My-Posts-24f8a1b2c3d44e5f8a9b0c1d2e3f4a5b`); share it with your connector first via Notion's **•••  → Connections** menu. For structured columns use a **page** URL (the Actor builds the database for you) or a database that **already has columns** — an empty database only receives titles. (Some services need no target.)
   - **Write mode** — `perPost` writes one record per video; `summary` writes a single roll-up for the run.
   - **Max records to deliver** *(optional)* — cap on how many records `perPost` delivers.

Each video becomes one record with its status, source URL and download link. Failed downloads are delivered too, with their status and error, so the destination doubles as a download log. Links to Apify storage stay valid for as long as the run's storage is retained; use your own cloud storage for permanent links.

**Notion, structured like a spreadsheet:** for a table of typed columns, point the target at a Notion **page** — the Actor auto-creates a database from the data, one matching, correctly-typed column per field (URL, number, date, text). Pointing at an **existing database** fills the columns it already has (matched by name); an **empty database** receives only the title, and the rest of each record goes to the row body — the connector can't add columns to an existing database without destructive access it never requests. Nested fields are flattened into columns too — an `inputSource` object becomes `inputSource.url` and `inputSource.queryIndex` — so everything is sortable and filterable in the grid. Fields that don't fit a column go to the row's page body, so nothing is lost.

Your credentials stay yours: the Actor talks to your services exclusively through your own authorized connector and only ever uses non-destructive write tools — it cannot delete or overwrite anything you already have. Delivery is best-effort and runs after the scrape: if a connector is misconfigured or a delivery fails, your run still finishes normally with all results intact — the failure is reported in the run log, never by failing the run. If the run is about to hit its timeout, delivery stops early so the run still succeeds, and the log tells you how many records were delivered.

### Which Fields Does the Instagram Video Downloader Output?

The Instagram Video Downloader outputs 9 fields per video, covering source tracking, delivery, and status. Every item is stored as one JSON object per video found, per input URL.

```json
{
  "sourceUrl": "https://www.instagram.com/p/DdBT6qbjGaQ/",
  "videoPosition": 1,
  "downloadUrl": "https://api.apify.com/v2/key-value-stores/xxx/records/ig-DdBT6qbjGaQ-1.mp4",
  "thumbnailUrl": "https://scontent.cdninstagram.com/...",
  "storageType": "apify",
  "status": "succeeded",
  "jobId": "a1b2c3d4",
  "error": null,
  "inputSource": {
    "queryIndex": 0,
    "url": "https://www.instagram.com/p/DdBT6qbjGaQ/"
  }
}
```

| Field | Description |
|---|---|
| `sourceUrl` | The input URL that produced this item. |
| `videoPosition` | 1-based position of this video among all the post's media. A carousel whose videos are its 2nd and 4th items yields 2 and 4. |
| `downloadUrl` | The re-hosted video in your chosen storage. `null` unless `status` is `succeeded`. |
| `thumbnailUrl` | Instagram's own thumbnail link. Passed through as-is, and it will eventually expire. |
| `storageType` | Which storage the video was delivered to. |
| `status` | One of 6 values, listed below. |
| `jobId` | Identifier of the download job, for support requests. `null` if no job was created. |
| `error` | Why this item is not a download, or `null`. |
| `inputSource` | Which `startUrls` entry produced this item, as `queryIndex` and `url`. |

### Which Statuses Does the Instagram Video Downloader Report?

The Instagram Video Downloader reports 6 status values on every output item. 1 status is charged.

| Status | Meaning | Charged |
|---|---|---|
| `succeeded` | The video was downloaded and re-hosted. | Yes |
| `invalidUrl` | The URL is not a post, reel, or IGTV URL. | No |
| `unavailable` | The post does not exist, or it is private or deleted. | No |
| `noVideoContent` | The post exists but contains no video. | No |
| `failed` | The download or the upload to your storage failed. | No |
| `timedOut` | The run ran out of time before this video was downloaded. | No |

The 5 non-charged statuses split into 2 recovery behaviors: 4 statuses (`invalidUrl`, `unavailable`, `noVideoContent`, `failed`) report a problem with one video while the run continues to the next `startUrls` entry, and 1 status (`timedOut`) reports a video the run did not finish before its deadline. Wait time for one download scales with the video's own length; a job whose backend heartbeat or phase freezes past that scaled threshold is reported as `failed`, and a video still in progress when the run's own deadline arrives is reported as `timedOut` instead of stalling the whole run.

### Which Instagram Video Downloader Questions Come Up Most Often?

#### What can the Instagram Video Downloader collect?

Videos attached to Instagram posts, reels, and IGTV entries, including every video inside a carousel post, sourced from the URLs supplied in `startUrls`.

#### Can the Instagram Video Downloader download a carousel post?

Yes. Every video in the post is returned as its own result, numbered by its position in the post.

#### Does the Instagram Video Downloader need my own cloud storage account?

No. The default `storageType` is `apify`, which saves videos to Apify's built-in key-value store with no extra setup. An AWS S3, Google Cloud, DigitalOcean Spaces, or Azure account is optional.

#### What happens if I enter the same Instagram Video Downloader post as a `/p/` and a `/reel/` URL?

The Instagram Video Downloader deduplicates it by shortcode and downloads, and charges, it once.

#### How do I cap the volume of an Instagram Video Downloader run?

`maxItems` sets the maximum number of items returned, on paid plans. On the Free plan it is fixed by the plan configuration regardless of what is entered.

#### Can I customize the Instagram Video Downloader output?

Yes. `customMapFunction` takes each output object and returns a mapped object. It must be a synchronous function and finish within about 1 second per item. If it is not a usable function, or it throws, returns a non-object or runs too long, it is ignored for the rest of the run and the original items are saved unchanged.

#### Is there a free way to try the Instagram Video Downloader?

Yes. A Free-plan account can start a run and see a small number of placeholder items without a subscription. For unrestricted use, subscribe to a paid plan.

#### Am I charged by the Instagram Video Downloader for a private or deleted post?

No. Nothing is charged for a URL that is not a valid post, reel, or IGTV link, or for a post that is private, deleted, or contains no video.

#### Does a failed Instagram Video Downloader download cost anything?

No. A `failed` or `timedOut` item is not charged.

#### Can I fetch Instagram Video Downloader results via the API?

Yes, in any language, including Python, PHP, and Node.js, via the [Apify API](https://docs.apify.com/api/v2).

### Where Do You Get Instagram Video Downloader Support?

The Instagram Video Downloader is published by epctex, reachable at [epctex.com](https://epctex.com) for all available products. Custom integrations go through the chat box on [epctex.com](https://epctex.com). Support requests go to <business@epctex.com>.

# Actor input Schema

## `startUrls` (type: `array`):

Instagram post, reel, or IGTV URLs to download videos from.

## `maxItems` (type: `integer`):

Maximum number of items to output. Leave empty for no limit.

## `storageType` (type: `string`):

Target storage provider. Fill the matching configuration section below.

## `customMapFunction` (type: `string`):

Function that takes each of the objects as argument and returns data that will be mapped by the function itself. This function is not intended for filtering, please don't use it for filtering purposes or you will get banned automatically. Must be a single synchronous function, e.g. (object) => { return {...object} }. It runs in a sandbox with plain JavaScript only (no network or require) and about 1 second per item. Leave empty if you do not need to transform the output - an unusable function is ignored and the original items are saved instead.

## `s3AccessKeyId` (type: `string`):

Fill in the following fields if you want to upload the video to an S3 bucket

## `s3SecretAccessKey` (type: `string`):

Fill in the following fields if you want to upload the video to an S3 bucket

## `s3Bucket` (type: `string`):

Fill in the following fields if you want to upload the video to an S3 bucket

## `s3Region` (type: `string`):

Fill in the following fields if you want to upload the video to an S3 bucket

## `s3Path` (type: `string`):

Optional folder path in the S3 bucket.

## `googleCloudProjectId` (type: `string`):

GCP project ID.

## `googleCloudServiceKeyJson` (type: `object`):

Service account credentials JSON.

## `googleCloudBucketName` (type: `string`):

Target Google Cloud Storage bucket name.

## `googleCloudPath` (type: `string`):

Optional folder path in the GCS bucket.

## `digitalOceanAccessKeyId` (type: `string`):

DigitalOcean Spaces access key ID.

## `digitalOceanSecretAccessKey` (type: `string`):

DigitalOcean Spaces secret access key.

## `digitalOceanRegion` (type: `string`):

DigitalOcean Spaces region (e.g. nyc3).

## `digitalOceanBucketName` (type: `string`):

DigitalOcean Spaces bucket name.

## `digitalOceanEndpoint` (type: `string`):

Optional Spaces endpoint URL.

## `digitalOceanAcl` (type: `string`):

Optional ACL value (defaults to private).

## `digitalOceanPath` (type: `string`):

Optional folder path in the Spaces bucket.

## `azureAccountName` (type: `string`):

Azure storage account name.

## `azureAccountKey` (type: `string`):

Azure storage account key.

## `azureContainerName` (type: `string`):

Azure container name.

## `azurePath` (type: `string`):

Optional folder path in the Azure container.

## `outputConnector` (type: `string`):

Pick an MCP connector you authorized in Console → Settings → API & Integrations → MCP connectors (e.g. Notion, Todoist — any service whose MCP server offers non-destructive write tools works best-effort). The scraped results are written through your own connector — the Actor never sees your third-party credentials. Only non-destructive write tools are used; it can never delete or overwrite your existing data.

## `deliverTarget` (type: `string`):

Where to write into the connector — paste the URL or ID. Notion example: https://www.notion.so/My-Posts-24f8a1b2c3d44e5f8a9b0c1d2e3f4a5b. Leave empty for services that need no target (e.g. Todoist Inbox, Slack). For Notion, share the page or database with your connector first (Notion's ••• → Connections menu), and point at a PAGE for structured columns (the Actor builds the database for you) — an empty database receives only the title (the rest of each record goes to the row's body).

## `deliverMode` (type: `string`):

perPost writes one record per scraped item; summary writes a single roll-up for the run.

## `deliverMaxItems` (type: `integer`):

Cap on how many records perPost mode writes to the connector; ignored in summary mode. Leave empty to deliver everything scraped.

## Actor input object example

```json
{
  "startUrls": [
    "https://www.instagram.com/p/CuKHeY_PLbZ/"
  ],
  "storageType": "apify",
  "customMapFunction": "(object) => { return {...object} }",
  "deliverMode": "perPost"
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        "https://www.instagram.com/p/CuKHeY_PLbZ/"
    ],
    "customMapFunction": (object) => { return {...object} }
};

// Run the Actor and wait for it to finish
const run = await client.actor("epctex/instagram-video-downloader").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "startUrls": ["https://www.instagram.com/p/CuKHeY_PLbZ/"],
    "customMapFunction": "(object) => { return {...object} }",
}

# Run the Actor and wait for it to finish
run = client.actor("epctex/instagram-video-downloader").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    "https://www.instagram.com/p/CuKHeY_PLbZ/"
  ],
  "customMapFunction": "(object) => { return {...object} }"
}' |
apify call epctex/instagram-video-downloader --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,epctex/instagram-video-downloader"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/OWBUCWZK5MEeO5XiC/builds/wT75ciEyzB73LrqRD/openapi.json
