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

# Quickstart

> Run your first job and read its results in five minutes.

This page collects the latest 10 posts of the public Instagram account @nasa.

**1. Get an API key**

Sign in at [go-fetch.io](https://go-fetch.io/app/login), open **API keys** and create a key with the **read**
and **write** scopes. The key is shown once: copy it now.

Jobs spend prepaid credits from your organization's balance. If your balance is empty, write to
[support@go-fetch.io](mailto:support@go-fetch.io) and we'll add credits to your organization.

Keep the key in an environment variable, never in code:

```bash theme={null}
export GOFETCH_API_KEY="sk_..."
```

**2. Install the SDK (Python)**

```bash theme={null}
pip install gofetch-client
```

It needs Python 3.9 or later. With cURL or JavaScript, skip this step.

**3. Run a job**

A job runs in the background. The SDK's `call()` waits until it finishes; with the REST API you create it, then
check on it.

```python Python theme={null}
import os

from gofetch import GoFetchClient

client = GoFetchClient(api_key=os.environ["GOFETCH_API_KEY"])

run = client.actor("instagram").call(
    run_input={"usernames": ["nasa"], "limit": 10},
)
print(run["status"], run["usageTotalUsd"])

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    if item.get("type") in ("Image", "Video", "Sidecar"):
        print(item["url"], item["likesCount"])
```

```bash cURL theme={null}
curl https://go-fetch.io/api/v1/jobs/create/ \
  -H "X-API-Key: $GOFETCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scraper_type": "instagram", "config": {"usernames": ["nasa"], "limit": 10}}'
```

```javascript JavaScript theme={null}
const api = 'https://go-fetch.io/api/v1';
const headers = { 'X-API-Key': process.env.GOFETCH_API_KEY, 'Content-Type': 'application/json' };

const job = await fetch(`${api}/jobs/create/`, {
  method: 'POST',
  headers,
  body: JSON.stringify({ scraper_type: 'instagram', config: { usernames: ['nasa'], limit: 10 } }),
}).then((res) => res.json());

let current = job;
while (!current.is_terminal) {
  await new Promise((resolve) => setTimeout(resolve, 5000));
  current = await fetch(`${api}/jobs/${job.id}/`, { headers }).then((res) => res.json());
}
console.log(current.status, current.actual_cost);

const page = await fetch(`${api}/jobs/${job.id}/results/?limit=100`, { headers })
  .then((res) => res.json());
for (const item of page.results) {
  if (['Image', 'Video', 'Sidecar'].includes(item.type)) console.log(item.url, item.likesCount);
}
```

The create call answers `201` with the job. Keep its `id`.

**4. Wait for it to finish (REST API)**

Check the job until `is_terminal` is `true`. Every few seconds is enough; a [webhook](https://docs.go-fetch.io/webhooks.md) saves you the
polling.

```bash theme={null}
curl https://go-fetch.io/api/v1/jobs/$JOB_ID/ \
  -H "X-API-Key: $GOFETCH_API_KEY"
```

A finished job reads `"status": "completed"`, with `items_scraped` (the billed result count) and `actual_cost`
(what it was charged, in USD).

**5. Read the results (REST API)**

Results come a page at a time, up to 100 per page.

```bash theme={null}
curl "https://go-fetch.io/api/v1/jobs/$JOB_ID/results/?offset=0&limit=100" \
  -H "X-API-Key: $GOFETCH_API_KEY"
```

The answer is `{"total", "offset", "limit", "count", "results"}`. Each item in `results` is one row; for
Instagram, one post. The first row for each profile is a `profile_info` summary row; posts have `type` `Image`,
`Video` or `Sidecar`. `total` also counts \$0 status rows, such as `profile_error`, so it can exceed `items_scraped`.

## Next steps

> **[Jobs and results](https://docs.go-fetch.io/jobs-and-results.md)**
>
> Statuses, retries, paging and retention.

> **[Instagram guide](https://docs.go-fetch.io/scrapers/instagram.md)**
>
> Every input and output field of this scraper.

> **[Webhooks](https://docs.go-fetch.io/webhooks.md)**
>
> Get told when a job finishes, instead of polling.

> **[Billing](https://docs.go-fetch.io/billing.md)**
>
> How a job's cost is worked out, and how to cap it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.