Session ID

Use the same IP for each API Request by using&session_id=12345. ZenRows will maintain a session for each ID for 10 minutes.

You will need to keep track of them on your side by storing each Session ID so you can reuse them.

# pip install zenrows
from zenrows import ZenRowsClient

client = ZenRowsClient("YOUR_ZENROWS_API_KEY")
url = "https://httpbin.io/anything"
params = {
    "session_id": 12345
}

response = client.get(url, params=params)

print(response.text)

Original HTTP Code

ZenRows API returns HTTP Codes depending on the result of the request. If you want to return the status code provided by the website, enable &original_status=true.

# pip install zenrows
from zenrows import ZenRowsClient

client = ZenRowsClient("YOUR_ZENROWS_API_KEY")
url = "https://httpbin.io/anything"
params = {
    "original_status": "true"
}

response = client.get(url, params=params)

print(response.text)

Return content on error

When you need to debug errors or work with resources that display errors 404 (Not Found), 500 (Internal Server Error), or 503 (Service Unavailable), the response may still have valuable data. To help with this, you can use the allowed_status_codes parameter.

This feature will allow you to obtain the content where you would get an error, enhancing the API’s debugging capabilities and overall utility. These requests will be charged.

To use it, you can include the allowed_status_codes parameter in your requests. You can send several status codes separated by commas.

# pip install zenrows
from zenrows import ZenRowsClient

client = ZenRowsClient("YOUR_ZENROWS_API_KEY")
url = "https://httpbin.io/anything"
params = {
    "allowed_status_codes": "404,500,503",
}

response = client.get(url, params=params)

print(response.text)

CAPTCHA Solver

This feature is deprecated, please use JS Instructions’ solve_captcha.

ZenRows already bypasses CAPTCHAs that get in your way to prevent you from accessing web pages. But you can integrate a paid solver (2Captcha) if you encounter an in-page CAPTCHA, like for submitting a form. You will need to add your solver’s API Key on the integrations section.

Add &resolve_captcha=true to the request for this feature.

Requires javascript rendering (&js_render=true).

# pip install zenrows
from zenrows import ZenRowsClient

client = ZenRowsClient("YOUR_ZENROWS_API_KEY")
url = "https://httpbin.io/anything"
params = {
    "js_render": "true",
    "resolve_captcha": "true"
}

response = client.get(url, params=params)

print(response.text)

POST / PUT Requests

Send POST / PUT requests as usual with your chosen language. ZenRows will transparently forward the data to the target site.

The return value will be the original response’s content. Headers and cookies will also be part of the response. The way to access them will depend on the manner of calling.

# pip install zenrows
from zenrows import ZenRowsClient

client = ZenRowsClient("YOUR_ZENROWS_API_KEY")
url = "https://httpbin.io/anything"
data = {
	"key1": "value1",
	"key2": "value2",
}

response = client.post(url, data=data)

print(response.text)

Credits Usage

Check credits consumption programmatically by calling the endpoint /usage. Usage calls will not count for concurrency, and results are available in real-time.

# pip install requests
import requests

response = requests.get('https://api.zenrows.com/v1/usage?apikey=YOUR_ZENROWS_API_KEY')
print(response.text)