Skip to main content

Apify API documentation

Learn how to use the Apify platform programmatically.

REST API

The Apify API is built around HTTP REST, uses predictable resource-oriented URLs, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.

cURL
# Prepare Actor input and run it synchronously
echo '{ "searchStringsArray": ["Apify"] }' |
curl -X POST -d @- \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <YOUR_API_TOKEN>' \
-L 'https://api.apify.com/v2/actors/compass~crawler-google-places/run-sync-get-dataset-items'

OpenAPI schema

You can download the complete OpenAPI schema of the Apify API in the YAML or JSON formats. The source code is also available on GitHub.

API clients

The client libraries are a more convenient way to interact with the Apify platform than the HTTP REST API.
JavaScript
Python

JavaScript API client

For web browser, JavaScript/TypeScript applications, Node.js, Deno, or Bun.Star
npm install apify-client
// Easily run Actors, await them to finish using the convenient .call() method, and retrieve results from the resulting dataset.
const { ApifyClient } = require('apify-client');

const client = new ApifyClient({
token: 'MY-APIFY-TOKEN',
});

// Starts an actor and waits for it to finish.
const { defaultDatasetId } = await client.actor('john-doe/my-cool-actor').call();

// Fetches results from the actor's dataset.
const { items } = await client.dataset(defaultDatasetId).listItems();

Experimental API clients

Clients for other languages are official Apify projects, but they are experimental: they are generated automatically from the OpenAPI schema. Review the code before you rely on them in production, and report issues on their repositories.
Go
PHP
Java
.NET
Rust

Go API client

Client for Go 1.23 or newer, built almost entirely on the standard library.
go get github.com/apify/apify-client-go
package main

import (
"context"
"fmt"
"log"

apify "github.com/apify/apify-client-go"
)

func main() {
client := apify.NewClient(apify.WithToken("MY-APIFY-TOKEN"))
ctx := context.Background()

// Starts an Actor and waits for it to finish.
run, err := client.Actor("john-doe/my-cool-actor").Call(ctx, nil, apify.ActorStartOptions{}, nil)
if err != nil {
log.Fatal(err)
}

// Fetches results from the Actor's dataset.
page, err := client.Dataset(run.DefaultDatasetID).ListItems(ctx, apify.DatasetListItemsOptions{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Got %d items\n", page.Total)
}

Related articles