Skip to main content
The Python SDK is the gofetch-client package on PyPI. You import it as gofetch. It keeps the interface of apify-client, so code written for Apify runs with two changed lines (Migrate from Apify). This page describes version 0.8.0.
It needs Python 3.9 or later. pip install "gofetch-client[async]" adds HTTP/2 for the async client.

The client

AsyncGoFetchClient takes the same arguments; its methods are awaited, and it is used with async with.

Run a scraper

client.actor(scraper_type) picks a scraper. It also takes Apify actor names such as apify/instagram-scraper.
run_input is sent to the API unchanged as the job’s config: use the field names in each scraper’s guide.

The run

Read results

  • iterate_items(offset=0, limit=None) yields every result, fetching pages as it goes.
  • list_items(offset=0, limit=None) returns them as a list that also has items, total, offset, limit and desc.
  • Each item gets a runId key with the job’s id.
  • get_info() returns the job’s id, item count and dates. delete() does nothing: results are deleted after 5 days.

Webhooks

Event names are Apify’s: ACTOR.RUN.SUCCEEDED, ACTOR.RUN.FAILED, ACTOR.RUN.TIMED_OUT, ACTOR.RUN.ABORTED. The API’s own names (job.completed, …) are accepted too. To receive them:
  • verify_webhook_signature(raw_body, signature, secret) checks X-Webhook-Signature (Webhooks).
  • transform_webhook_payload(payload, event_type) turns a delivery into Apify’s webhook shape, with eventType (pass the X-Event-Type header) and resource.usageTotalUsd.

Errors

HTTP problems raise; a job that fails does not (check run["status"]).

Scraper names

client.actor() takes every scraper_type in the scraper guides. Version 0.8.0 does not list tiktok_search and tiktok_profile yet: they work, and Python prints a UserWarning you can ignore. These Apify actor names resolve to a scraper: