ApifyClient.API.RequestQueues.Requests (apify_client v1.0.0)

Copy Markdown View Source

Provides API endpoints related to api/request queues/requests

Summary

Functions

Add request to request queue

Delete request from request queue

Get request from request queue

List requests in request queue

Unlock requests in request queue

Update request in request queue

Functions

create(queue_id, body, opts \\ [])

@spec create(
  queue_id :: String.t(),
  body :: map() | ApifyClient.Schemas.RequestWithoutId.t(),
  opts :: keyword()
) ::
  {:ok, ApifyClient.Schemas.RequestRegistration.t()}
  | {:error, ApifyClient.Error.t()}

Add request to request queue

Adds request to the queue. Response contains ID of the request and info if request was already present in the queue or handled.

If request with same uniqueKey was already present in the queue then returns an ID of existing request.

Options

  • client_key: A unique identifier of the client accessing the request queue. It must be a string between 1 and 32 characters long. This identifier is used to determine whether the queue was accessed by multiple clients. If clientKey is not provided, the system considers this API call to come from a new client. For details, see the hadMultipleClients field returned by the Get request queue head endpoint.

  • forefront: Determines if request should be added to the head of the queue or to the end. Default value is false (end of queue).

Request Body

Content Types: application/json

delete(queue_id, request_id, opts \\ [])

@spec delete(queue_id :: String.t(), request_id :: String.t(), opts :: keyword()) ::
  :ok | {:error, ApifyClient.Error.t()}

Delete request from request queue

Deletes given request from queue.

Options

  • client_key: A unique identifier of the client accessing the request queue. It must be a string between 1 and 32 characters long. This identifier is used to determine whether the queue was accessed by multiple clients. If clientKey is not provided, the system considers this API call to come from a new client. For details, see the hadMultipleClients field returned by the Get request queue head endpoint.

get(queue_id, request_id, opts \\ [])

@spec get(queue_id :: String.t(), request_id :: String.t(), opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.RequestResource.t()}
  | {:error, ApifyClient.Error.t()}

Get request from request queue

Returns request from queue.

list(queue_id, opts \\ [])

@spec list(queue_id :: String.t(), opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.ListOfRequests.t()}
  | {:error, ApifyClient.Error.t()}

List requests in request queue

Returns a list of requests. This endpoint is paginated using cursor (pagination by exclusiveStartId is deprecated) and limit parameters.

Options

  • client_key: A unique identifier of the client accessing the request queue. It must be a string between 1 and 32 characters long. This identifier is used to determine whether the queue was accessed by multiple clients. If clientKey is not provided, the system considers this API call to come from a new client. For details, see the hadMultipleClients field returned by the Get request queue head endpoint.

  • exclusive_start_id: All requests up to this one (including) are skipped from the result. (Deprecated, use cursor instead.)

  • limit: Number of keys to be returned. Maximum value is 10000.

  • cursor: A cursor string for pagination, returned in the previous response as nextCursor. Use this to retrieve the next page of requests.

  • filter: Filter requests by their state. Possible values are locked and pending. You can combine multiple values separated by commas, which will mean the union of these filters – requests matching any of the specified states will be returned. (Not compatible with deprecated exclusiveStartId parameter.)

unlock(queue_id, opts \\ [])

@spec unlock(queue_id :: String.t(), opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.UnlockRequestsResult.t()}
  | {:error, ApifyClient.Error.t()}

Unlock requests in request queue

Unlocks requests in the queue that are currently locked by the client.

  • If the client is within an Actor run, it unlocks all requests locked by that specific run plus all requests locked by the same clientKey.
  • If the client is outside of an Actor run, it unlocks all requests locked using the same clientKey.

Options

  • client_key: A unique identifier of the client accessing the request queue. It must be a string between 1 and 32 characters long. This identifier is used to determine whether the queue was accessed by multiple clients. If clientKey is not provided, the system considers this API call to come from a new client. For details, see the hadMultipleClients field returned by the Get request queue head endpoint.

update(queue_id, request_id, body, opts \\ [])

@spec update(
  queue_id :: String.t(),
  request_id :: String.t(),
  body :: map() | ApifyClient.Schemas.RequestWithoutId.t(),
  opts :: keyword()
) ::
  {:ok, ApifyClient.Schemas.RequestRegistration.t()}
  | {:error, ApifyClient.Error.t()}

Update request in request queue

Updates a request in a queue. Mark request as handled by setting request.handledAt = new Date(). If handledAt is set, the request will be removed from head of the queue (and unlocked, if applicable).

Options

  • forefront: Determines if request should be added to the head of the queue or to the end. Default value is false (end of queue).

  • client_key: A unique identifier of the client accessing the request queue. It must be a string between 1 and 32 characters long. This identifier is used to determine whether the queue was accessed by multiple clients. If clientKey is not provided, the system considers this API call to come from a new client. For details, see the hadMultipleClients field returned by the Get request queue head endpoint.

Request Body

Content Types: application/json