docs.apify.com

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'

JavaScript

Python

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();

Go
PHP
Java
.NET
Rust

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)

}

Read the original on docs.apify.com ↗