For the complete documentation index, see llms.txt. This page is also available as Markdown.

Push-Pull

Discover the Push-Pull integration method for the Oxylabs Web Scraper API. Submit a job, then poll the results endpoint later using JSON-formatted data.

Push-Pull is our recommended integration method for reliably handling large amounts of data.

Push-Pull is an asynchronous integration method. Upon job submission, you will promptly receive a JSON response containing all job details, including job parameters, ID, and URLs for result download and status checking. Once your job is processed, we will update you via a JSON payload sent to your server, if you provided a callback URL. Results remain available for retrieval for at least 24 hours after completion.

With Push-Pull, you can upload your results directly to your cloud storage (Google Cloud Storage, AWS S3, Alibaba Cloud OSS, or other S3-compatible storage).

If you prefer not to set up a service for incoming callback notifications, you can simply retrieve your results periodically (polling).

You can also explore how Push-Pull works using Postman.

Single Job

Endpoint

This endpoint accepts only a single query or URL value.

POST https://data.oxylabs.io/v1/queries

Input

Provide the job parameters in a JSON payload as shown in the examples below. Python and PHP examples include comments for clarity.

curl --user "USERNAME:PASSWORD" \
'https://data.oxylabs.io/v1/queries' \
-H "Content-Type: application/json" \
 -d '{"source": "universal", "url": "https://www.example.com", "geo_location": "United States", "callback_url": "https://your.callback.url", "storage_type": "s3", "storage_url": "s3://your.storage.bucket.url"}'
import requests
from pprint import pprint


# Structure payload.
payload = {
    "source": "universal", # Source you choose e.g. "universal"
    "url": "https://www.example.com", # Check the docs of the specific source to see whether you should use "url" or "query"
    "geo_location": "United States", # Some sources accept zip codes or coordinates
    #"render" : "html", # Uncomment if you want to render JavaScript within the page
    #"render" : "png", # Uncomment if you want to take a screenshot of a scraped web page
    #"parse" : True, # Check what sources support parsed data
    "callback_url": "https://your.callback.url", # Required if you use the callback listener
    "storage_type": "s3", 
    "storage_url": "s3://your.storage.bucket.url"
}

# Get response.
response = requests.request(
    'POST',
    'https://data.oxylabs.io/v1/queries',
    auth=('YOUR_USERNAME', 'YOUR_PASSWORD'), #Your credentials go here
    json=payload,
)

# Print prettified response to stdout.
pprint(response.json())

Output

The API will respond with a JSON containing the job information, similar to this:

Data dictionary

The table below describes the fields returned in the job response. For the input parameters you can send, refer to the documentation page of the source you are using.

Key
Description
Type

created_at

The datetime the job was created at.

String

client_id

The numerical ID associated with the username of the client making the request.

String

client_notes

Submitted notes by the client when sending a job.

String

content_encoding

The encoding of the returned content. Set it in your payload when downloading images; it is echoed back in the job response.

String

id

The unique ID of the job.

String

statuses

The status codes of the scraping or parsing job. You can see the status codes described here.

Integer

status

The status of the job. pending means the job is still being processed. done means we've completed the job. faulted means we came across errors while trying to complete the job -- and gave up at it.

String

subdomain

The subdomain of the website.

String

updated_at

The datetime the job was last updated at. For jobs that are finished (status is done or faulted), this datetime indicates when the job was finished.

String

_links

The list of links, related to the provided input.

JSON Array

_links:rel

The link type. self URL contains the metadata of the job, while results URL contains the job results.

String

_links:href

The URL to the resource.

String

_links:href_list

The list of URLs to the resource, one per page. Returned instead of href on entries whose rel starts with results-content. See Retrieve Job Content.

JSON Array

_links:method

The HTTP method that should be used to interact with a given URL.

String

Callback

The callback is a POST request we send to your machine, informing that the data extraction task is completed and providing a URL to download scraped content. This means that you don't need to check job status manually. Once the data is here, we will let you know, and all you need to do now is to retrieve it.

Input

Output

Check Job Status

If you provided a valid callback URL when submitting your job, we will notify you upon completion by sending a JSON payload to the specified callback URL. This payload will indicate that the job has been completed and its status set to done.

However, if you submitted a job without using callback service, you can check the job status manually. Retrieve the URL from the href field in the rel:self section of the response message received after job submission. The URL for checking the job status will resemble the following: http://data.oxylabs.io/v1/queries/12345678900987654321. Querying this URL will return the job information, including its current status.

Endpoint

Input

Output

Upon completion of the job, the API will respond with query information in JSON format. The job status will be changed to done, indicating that the job is finished. You can retrieve the content by querying one of the provided links. Additionally, the response will include the timestamp of when the job was last updated, allowing you to track its processing time.

Status values

Parameter
Description

pending

The job is still being processed and has not been completed.

done

The job is completed. You can retrieve the result by querying the URL provided in the href field under the rel:results section, for example: http://data.oxylabs.io/v1/queries/12345678900987654321/results.

faulted

There was an issue with the job, and we couldn't complete it. You are not charged for any faulted jobs.

Retrieve Job Content

Once the job is ready to be retrieved, you can use the URL provided in the response under the rel:results section. The URL will look like this: http://data.oxylabs.io/v1/queries/12345678900987654321/results.

The _links URLs are returned with an http:// scheme. Replace it with https:// before calling them, so that your credentials are not sent unencrypted.

Endpoints

You can retrieve different results types by using the following endpoints:

You may also retrieve multiple result types in a single response, for instance:

To get one page on its own as raw content rather than inside a JSON object, use the content endpoint, where {n} is the page number starting at 1. The same type values apply.

Input

Below are code examples demonstrating how to use the /results endpoint:

Output

This table explains the default result type based on the parameters included in the payload of the API request.

Render parameter
Parse parameter
XHR parameter
Default output

-

-

-

html

html

-

-

html

html

-

true

xhr

html

true

true

parsed

png

-

-

png

-

true

-

parsed

html

true

-

parsed

png

true

-

png

By default, the /results endpoint returns only the default output for your payload. To receive additional result types, add the type query parameter shown under Endpoints above. Each requested type is returned as a separate entry in the results array. This is the multiple result types feature, and it works the same way in Push-Pull and Realtime.

Below is a sample response of the /results endpoint. Alongside results, it returns a job object holding the same job details described in the Data dictionary, abbreviated here. Some sources also return _request, _response and session_info on each result.

The results can be automatically retrieved without periodically checking job status by setting up Callback service. To do that, specify the URL of a server that is able to accept incoming HTTP(S) requests while submitting a job. When our system completes the job, it will POST a JSON payload to the provided URL, and the Callback service will download the results as described in the Callback implementation example.

Batch Query

Scraper APIs supports submitting up to 5,000 query or url parameter values within a single batch request.

Endpoint

The system will handle every query or url submitted as a separate job. If you provide a callback URL, you will get a separate call for each keyword. Otherwise, our initial response will contain job ids for all keywords. For example, if you sent 50 keywords, we will return 50 unique job ids.

IMPORTANT: With /batch endpoint, you can only submit lists of queryor urlparameter values (depending on the source you use). All other parameters should have singular values.

Input

You need to post query parameters as a JSON payload. Here is how you submit a batch job:

You may notice that the code example above doesn't explain how the JSON payload should be formatted and points out to a pre-made JSON file. Below is the content of keywords.json file, containing multiple query parameter values:

...and here is a keywords.json batch input file, containing multiple URLs:

Output

The API will respond with a JSON object, containing the job information for each job created. The response will be similar to this:

Each entry carries the same fields as a single job response; {...} marks fields omitted here for brevity.

Get Notifier IP Address List

You may want to whitelist the IPs sending you callback messages or get the list of these IPs for other purposes. You can do this by GETting this endpoint:

Endpoint

Input

The code examples below show how you can access the /callbacker_ips endpoint:

Output

The API will return the list of IPs making callback requests to your system:

Scheduler

Scheduler is a service that you can use to schedule recurring scraping jobs.

It extends the functionality of Push-Pull integration and is best used together with the Cloud integration functionality.

Visit this page to learn how to use Scheduler feature:

Scheduler

Last updated

Was this helpful?