Skip to main content

ApifyRequestQueueClient

Request queue client for the Apify platform.

This client provides access to request queues stored on the Apify platform, supporting both single-consumer and multi-consumer scenarios. It manages local caching, request fetching, and state synchronization with the platform's API.

Index

Methods

__init__

  • __init__(*, api_client, metadata, access): None
  • Initialize a new instance.

    Preferably use the ApifyRequestQueueClient.open class method to create a new instance.


    Parameters

    • keyword-onlyapi_client: RequestQueueClientAsync
    • keyword-onlymetadata: RequestQueueMetadata
    • optionalkeyword-onlyaccess: Literal[single, shared] = 'single'

    Returns None

add_batch_of_requests

  • async add_batch_of_requests(requests, *, forefront): AddRequestsResponse
  • Parameters

    • requests: Sequence[Request]
    • optionalkeyword-onlyforefront: bool = False

    Returns AddRequestsResponse

drop

  • async drop(): None
  • Returns None

fetch_next_request

  • async fetch_next_request(): Request | None
  • Returns Request | None

get_metadata

  • Retrieve current metadata about the request queue.

    This method fetches metadata from the Apify API and merges it with local estimations to provide the most up-to-date statistics. Local estimations are used to compensate for potential delays in API data propagation (typically a few seconds).


    Returns ApifyRequestQueueMetadata

get_request

  • async get_request(unique_key): Request | None
  • Parameters

    • unique_key: str

    Returns Request | None

is_empty

  • async is_empty(): bool
  • Returns bool

mark_request_as_handled

  • async mark_request_as_handled(request): ProcessedRequest | None
  • Parameters

    • request: Request

    Returns ProcessedRequest | None

open

  • Open an Apify request queue client.

    This method creates and initializes a new request queue client instance, handling authentication, storage lookup or creation, metadata retrieval, and initialization of internal caching structures.


    Parameters

    • keyword-onlyid: str | None

      ID of an existing request queue to open. Mutually exclusive with name and alias.

    • keyword-onlyname: str | None

      Name of the request queue to open or create (persists across Actor runs). Mutually exclusive with id and alias.

    • keyword-onlyalias: str | None

      Alias for the request queue (scoped to current Actor run, creates unnamed storage). Mutually exclusive with id and name.

    • keyword-onlyconfiguration: Configuration

      Configuration object containing API credentials (token, api_base_url) and optionally a default_request_queue_id for fallback when no identifier is provided.

    • optionalkeyword-onlyaccess: Literal[single, shared] = 'single'

      Access mode controlling the client's behavior:

      • single: Optimized for single-consumer scenarios (lower API usage, better performance).
      • shared: Optimized for multi-consumer scenarios (more API calls, guaranteed consistency).

    Returns ApifyRequestQueueClient

purge

  • async purge(): None
  • Returns None

reclaim_request

  • async reclaim_request(request, *, forefront): ProcessedRequest | None
  • Parameters

    • request: Request
    • optionalkeyword-onlyforefront: bool = False

    Returns ProcessedRequest | None