Callbacks & API Params

Callbacks

Using the statusURL is a convenient way to test the API or get started quickly. For environments that require more robust or automated response handling, callbacks are are available for streamlined and efficient response handling. Currently, only webhook callbacks are supported but we are planning to expand this in the future (e.g. direct database callbacks, AWS S3, etc).

Hint: Webhook.sitearrow-up-right is a free online service to test webhooks without requiring you to build a complex infrastructure.

When using a callback, you don’t need to call the statusURL (although you still can) to fetch the status and results of the job. Once the job is complete, our system will call the webhook URL you provide and send the response data.

An example of using a webhook callback:

curl --request POST \
  --url "https://async.scraperapi.com/jobs" \
  --header "Content-Type: application/json" \
  --data '{
    "apiKey": "API_KEY",
    "url": "https://example.com",
    "callback": {
      "type": "webhook",
      "url": "YYYYY"
    }
  }'
circle-exclamation

Example callback response for a failed request:

Note: The system will try to invoke the webhook URL 3 times, then it cancels the job. So please make sure that the webhook URL is available through the public internet and will be capable of handling the traffic that you need.

API Params

You can use the standard API parameters the same way you’d use them with our synchronous API. These parameters should go into an apiParams object inside the POST data:

Last updated