This API executes a single Apify Actor that gathers Instagram hashtag statistics and returns either the Actor run metadata, the Actor’s dataset items, or the Actor’s key-value OUTPUT. The three operations are variants of the same workflow: start the Actor with a given input (the body), authenticate with the token, and receive either the run record, dataset items, or the key-value OUTPUT. Understand that the domain here is: Actor run → produced artifacts (dataset, key-value store) → data you present to the user.
Key concepts and how they relate
- The
bodyargument is the Actor input: populate it with the hashtag(s), limits, time ranges, or other options the Actor expects. The input schema is the authoritative place to learn which fields are required for a particular run. - A single Actor run can produce two kinds of artifacts you typically care about: a dataset (multiple structured items) and a key-value store (single JSON blobs, often under
OUTPUT). Which artifact you need determines which operation to call. - Every call must include a valid
tokenwith permissions to start the Actor and read its artifacts. - The three operations differ only in what they return and whether they wait for the Actor to finish:
runs-sync-apify-instagram-hashtag-stats: starts the Actor and returns the run record (run metadata) about the initiated run. Use this when you only need the run id/status or want to inspect produced artifact identifiers without waiting for completion.run-sync-get-dataset-items-apify-instagram-hashtag-stats: starts the Actor and waits for it to finish, then returns the Actor’s dataset items inbody. Use this when you want the structured items the Actor writes to its dataset.run-sync-apify-instagram-hashtag-stats: starts the Actor and waits for it to finish, then returns the key-value storeOUTPUTobject inbody. Use this when the Actor writes an aggregated JSON underOUTPUTand you want that object directly.
What to call first (entry points)
Decide what the user wants to see first: a run record, dataset items, or an OUTPUT object. That determines which operation to call directly—there is no separate step required to discover an actor id or dataset id beforehand because the operation itself starts the Actor.
- If the user asks "run this Actor and give me structured rows/results", call
run-sync-get-dataset-items-apify-instagram-hashtag-statswith the Actor input inbody. - If the user asks "run the Actor and return the aggregated JSON/statistics", call
run-sync-apify-instagram-hashtag-stats(the key-value OUTPUT variant) with the Actor input inbody. - If the user wants to start the run and receive run metadata (run id, status, artifact ids) immediately so they can be inspected or polled later, call
runs-sync-apify-instagram-hashtag-stats.
There is no separate prerequisite call to list actors or find dataset IDs: these operations initiate runs for the specific Instagram-hashtag-stats Actor and return either the artifacts or the run metadata that identifies artifacts.
Typical user requests and how to fulfill them
-
"Get the latest dataset items for #sunset and summarize engagement."
- Build the Actor input
bodywith the hashtag and any limits/time filters the Actor supports. Inspect the input schema fields to know exact parameter names. - Call
run-sync-get-dataset-items-apify-instagram-hashtag-statswithtokenand thatbody. - Extract the dataset items from the operation response
body(the operation returns an object withstatusandbody; the items are insidebody). - Summarize or filter those items to answer the user’s question.
- Build the Actor input
-
"Produce a single aggregated JSON report for #travel and return it."
- Populate
bodywith the hashtag and aggregation options if available. - Call
run-sync-apify-instagram-hashtag-stats. - The response
bodywill contain the Actor’s key-value storeOUTPUT(the aggregated JSON). Return that object to the user or extract fields you need.
- Populate
-
"Start a run for several hashtags and give me run IDs so I can check them later."
- For each requested input, call
runs-sync-apify-instagram-hashtag-stats. - Collect the returned run record fields (look for
id,status, and any artifact identifiers such asdatasetIdorkeyValueStoreId) and present them to the user so they can be referenced later.
- For each requested input, call
Response shape and what to inspect
Each operation returns an object with status and body. Do not assume the same structure inside body across operations:
- For the dataset-items operation,
bodyholds the dataset items array (the structured rows the Actor produced). - For the OUTPUT operation,
bodyholds the key-valueOUTPUTobject (often a single JSON document with aggregated stats). - For the runs operation,
bodyis the run metadata (look inside it forid,status, and any artifact IDs or links such asdatasetIdorkeyValueStoreId). Use those fields to explain what artifacts were created.
Always inspect the body fields to determine whether the Actor produced data or whether arrays/objects are empty.
Non-obvious patterns and gotchas
-
Choose the operation by the artifact you need, not by whether you want the run started. The two "run-sync" variants wait for completion and return artifacts; the
runs-syncvariant returns the run record immediately without artifact contents. Confusing these will cause you to either block waiting for a run when you only needed the id, or to miss artifacts when you only started the run metadata. -
The
bodyyou pass is the Actor input. The exact field names and required parameters are defined in the input schema. Inspect the input schema before invoking: missing required input fields will cause the Actor run to fail or produce no data. The operations do not accept separate parameters for hashtags or limits outside ofbody. -
Long-running runs: the
run-syncvariants wait until the Actor finishes. Expect the call to take however long the Actor needs; plan accordingly when the user asks for quick answers. If you only want to kick off work and report back later, use theruns-syncvariant so you get the run id immediately. -
Empty artifacts: a successful run can still produce an empty dataset or no
OUTPUT. Check for an empty array in dataset responses or a missing/nullOUTPUTobject and surface that to the user rather than assuming data exists. -
Authentication matters every call: include
tokenon every request. The token must have the rights to start the Actor and read its artifacts. -
Response extraction: the operations return
{ status, body }. Inspectstatusfor high-level result info, but readbodyfor the actual data you need to present. Don’t assume the shape—confirm whetherbodyis an array (dataset items), an object (OUTPUT), or a run record.
Practical tips
- When the user’s request is to compare or aggregate multiple hashtags, run the Actor separately for each hashtag input and then combine results. Each run yields its own dataset/OUTPUT.
- If the user asks for the run id or artifact ids for later retrieval, return the run record fields from
runs-sync-apify-instagram-hashtag-statsso they can reference those identifiers. - If you need a concise summary rather than raw items, prefer the key-value
OUTPUTvariant if the Actor produces an aggregated report; otherwise request dataset items and compute the summary yourself.
Use the operation whose return value matches the artifact you need: dataset items for row-level data, key-value OUTPUT for single aggregated JSON, or runs metadata when you only need to start the run and record its id/status.