Site icon DataForSEO

Best practices for handling SERP API requests

Handling low-volume SERP API payload

From the user perspective, a low-volume payload means a relatively periodic usage of an API with a few thousand requests a day or one-time data collection.

Setting API tasks

Retrieving API task results

A single-threaded worker service should be launched on your server. It can make requests to the Tasks Ready endpoint, obtain the id of the completed tasks, collect and process the results. Set the frequency for launching the worker:

Handling high-volume SERP API payload

High-volume payload means frequent usage of an API with many thousands of requests a day, or periodic usage with big volumes of collected data.

Setting API tasks

Retrieving API task results

A worker service that communicates with a database has to be launched on your server.

If you are using pingbacks:

  1. Your web server obtained a get GET request where the id parameter is the id of the completed task.
  2. Completed tasks should be appropriately labeled.
  3. Worker identifies completed tasks continuously or periodically, depending on the capabilities of your server. Completed tasks are collected through the Task Get endpoint using the id parameters of these tasks. You can regulate the workload of the server by setting up the appropriate frequency of launching the worker.
  4. After all the previous steps are completed, you can process the retrieved results.

If you are using postbacks:

  1. Your web server obtained a POST that contains the results of the completed task (note that data is sent in the compressed .gz format and thus requires decoding).
  2. After the previous step is completed, you can process the results.

Additional recommendations for using webhooks

Exit mobile version