{
  "openapi": "3.0.1",
  "info": {
    "title": "Instagram Post Scraper & Comment Replies",
    "description": "Instagram Post Scraper & Comment Replies — Scrape Instagram posts with captions, media details, likes, timestamps, and comments, including comment replies. Extract structured engagement data for content research, audience analysis, and social media insights.",
    "version": "0.2",
    "x-build-id": "X2tdd2la2OOcclhv1"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/api-empire~instagram-post-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-api-empire-instagram-post-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/api-empire~instagram-post-scraper/runs": {
      "post": {
        "operationId": "runs-sync-api-empire-instagram-post-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/api-empire~instagram-post-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-api-empire-instagram-post-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "username"
        ],
        "properties": {
          "username": {
            "title": "🎯 Profiles or post links to scrape",
            "type": "array",
            "description": "📋 **One target per row.** Mix freely:\n\n• 👤 Username — `natgeo`\n• 🔗 Profile URL — `https://www.instagram.com/natgeo/`\n• 🖼️ Post URL — `https://www.instagram.com/p/SHORTCODE/`\n• 🎬 Reel / TV URL — `https://www.instagram.com/reel/SHORTCODE/`\n\n💡 Duplicates are collapsed automatically (`natgeo`, `@natgeo` and the profile URL count as one target).",
            "items": {
              "type": "string"
            }
          },
          "resultsLimit": {
            "title": "🔢 How many posts per profile",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "🧮 **Maximum posts saved for each profile target.** Ignored for single post URLs (one URL = one row).\n\n⏱️ Instagram serves a **server-fixed 12 posts per feed request**, so 100 posts ≈ 9 feed calls before any comment work starts. Large numbers are slow, not blocked.",
            "default": 10
          },
          "maxComments": {
            "title": "💬 Comments to collect per post",
            "minimum": 0,
            "maximum": 5000,
            "type": "integer",
            "description": "🎯 **Hard cap on top-level comments per post.**\n\n📄 Instagram serves roughly **13 comments per request** and ignores any larger page size, so:\n• `13` ≈ free (already inside the post page)\n• `50` ≈ 3 extra requests\n• `500` ≈ 38 extra requests\n• `5000` ≈ 380 extra requests\n\n↪️ With a session cookie the thread is filled from Instagram's **threaded** listing first (~15 comments per request, and it reports each comment's reply count) and topped up from the logged-out connection afterwards. Same cap, better data.\n\n🧊 Set to **0** to skip comments entirely and scrape posts only.\n🔍 Only applies when *Post detail level* is **Detailed** — basic runs never fetch comments.",
            "default": 50
          },
          "onlyCommentsNewerThan": {
            "title": "🕐 Only comments newer than",
            "type": "string",
            "description": "📆 **Keep only comments posted after this moment (UTC).**\n\n✅ Absolute tab → `2026-07-20` or a full ISO timestamp.\n✅ Relative tab → `6 hours`, `3 days`, `1 week`, `2 months`, `1 year`.\n\n⚡ **Why this is cheap:** Instagram serves comments strictly newest-first (verified in this build: **0 out-of-order pairs across 629 consecutive comments**), so the scraper stops the moment it crosses your cutoff instead of paging to the end. On a 4,000-comment post a 24-hour window is a handful of requests instead of hundreds.\n\n🔕 Leave empty to collect up to *Comments to collect per post* regardless of age.",
            "default": null
          },
          "emitCommentsDataset": {
            "title": "🗂️ Also write a flat comments table",
            "type": "boolean",
            "description": "📊 **On** → every comment is additionally written to a second dataset named `ig-comments-<runId>`, **one row per comment**, ready for a spreadsheet or a BI tool without unnesting the `latestComments` array.\n\n📌 The main dataset is unchanged either way — this is an extra, not a replacement. These extra rows are **not charged**; only saved posts are.",
            "default": true
          },
          "includeReplies": {
            "title": "↪️ Try to collect replies under each comment",
            "type": "boolean",
            "description": "✅ **On** → when a session cookie is supplied, every comment's real reply count is read and the replies underneath it are fetched into `latestComments[].replies[]`.\n🔕 **Off** → replies are never attempted; `replies` stays `[]` and `repliesCount` stays `null`.\n\n📊 Two counters are always published side by side: `repliesDeclared` (what Instagram says is there) and `repliesCollected` (what came back). **Collected is normally ~78-86% of declared** — deleted, hidden and spam-filtered replies stay inside Instagram's own count. We publish both instead of implying completeness.\n\n🧭 Either way the run continues and every post row reports a `replyAccessStatus` column, so you always know which of the two happened.",
            "default": true
          },
          "maxRepliesPerComment": {
            "title": "🔢 Max replies per comment",
            "minimum": 0,
            "maximum": 1000,
            "type": "integer",
            "description": "🎯 **Cap on replies fetched under a single comment.** Requests are only spent on comments Instagram actually reports as having replies — comments it reports as having none cost nothing.\n\n📄 Replies arrive **6-9 per request** and the page size cannot be raised, so a 116-reply thread costs about 13 requests. The largest thread measured on this build: **declared 116 → 99 fetched over 13 pages**.\n\n0️⃣ Set to **0** to disable reply fetching entirely (same as turning the switch above off).",
            "default": 50
          },
          "sessionId": {
            "title": "🔑 Your Instagram `sessionid` cookie (optional)",
            "type": "string",
            "description": "🍪 **Paste the `sessionid` cookie from a logged-in instagram.com browser tab.** Either form is accepted: the **bare cookie value**, or the **whole cookie string** (`sessionid=...; csrftoken=...`). The log tells you which one was read — never the value itself.\n\n🔐 Stored encrypted by Apify. It is never written to the dataset, never written to the log, and never sent anywhere except Instagram.\n\n✅ **Verified end to end on this build**, not inherited from a spec: the session is proved alive once at the start of the run (and the account id is derived from it at runtime); a live session then returned **239 real replies out of 293 declared on a single post**, deepest thread 116 → 99.\n\n⚠️ If Instagram rejects the cookie the scraper says so once, **drops it and finishes the run logged out** — it never retries in a loop, never fails the run, and never turns an unknown reply count into a zero.\n\n💡 Everything except replies works perfectly without this field."
          },
          "skipPinnedPosts": {
            "title": "📌 Leave out pinned posts",
            "type": "boolean",
            "description": "📌 **On** → posts pinned to the top of the profile grid are dropped.\n\n🛠️ **Fixed in this build:** the pin flag is now matched against **the profile you are scraping**. The original logic matched it against the post's owner, so collaboration posts that were pinned on *somebody else's* grid were silently deleted from your results (measured precision 1 in 3 over 200 posts).",
            "default": false
          },
          "onlyPostsNewerThan": {
            "title": "🗓️ Only posts newer than",
            "type": "string",
            "description": "📆 **Keep only posts published after this moment (UTC).**\n\n✅ Absolute tab → `2026-07-20` or a full ISO timestamp.\n✅ Relative tab → `12 hours`, `3 days`, `1 week`, `2 months`, `1 year`.\n\n🛠️ **Fixed in this build:** week / hour / minute values used to be discarded and the filter simply switched itself off without telling you. They now work, and an unreadable value stops the run with a clear message instead of silently returning unfiltered data. Instagram's feed is also not perfectly chronological, so paging continues a short way past the cutoff rather than stopping on the very first older post.\n\n🔕 Leave empty for no cutoff.",
            "default": null
          },
          "dataDetailLevel": {
            "title": "🔬 Post detail level",
            "enum": [
              "detailedData",
              "basicData"
            ],
            "type": "string",
            "description": "⚡ **Basic** → posts only, straight from the feed. 2 requests per 12 posts. No comments, no alt text.\n🔬 **Detailed** → adds the comment thread, alt text, carousel child links, music info and paid-partnership flag. Costs one extra page request per post plus the comment paging you asked for.\n\n💵 **Both levels cost exactly the same per saved row** — the difference is speed and completeness, not price.",
            "default": "detailedData"
          },
          "proxyConfiguration": {
            "title": "🌐 Proxy configuration",
            "type": "object",
            "description": "🛡️ **Which proxy the run goes through.** Defaults to Apify Residential.\n\n💰 Measured on this base: an Apify **datacenter** group returned exactly the same 36 of 36 rows as residential on the profile feed, so switching to datacenter is a legitimate cost saving rather than a downgrade.",
            "default": {
              "useApifyProxy": true,
              "apifyProxyGroups": [
                "RESIDENTIAL"
              ]
            }
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}