How to Migrate from ZenRows to AlterLab: Step-by-Step Guide (2026)
TL;DR
To migrate from ZenRows to AlterLab, install the AlterLab SDK, replace your ZenRows client with alterlab.Client, update your API key, and keep the same request structure. The response format is nearly identical, so most of your scraping code remains unchanged.
Why migrate?
ZenRows uses a flat-rate subscription model where credits reset monthly, which can lead to wasted spend if you don’t use your full quota. AlterLab offers a pure pay‑as‑you-go model: you pay only for the requests you make, your balance never expires, and there are no monthly minimums. Both APIs are capable — this guide is for developers prioritizing pay-as-you-go pricing and no subscription requirements.
Prerequisites
- An AlterLab account (sign up free at [/signup])
- Your AlterLab API key (found in the dashboard)
- About 5 minutes to install the SDK and swap a few lines of code
Step 1: Install the AlterLab SDK
If you were using the ZenRows Python package, replace it with the AlterLab SDK. The install command is the same style.
```bash title="Terminal — Install AlterLab"
pip install alterlab
For full setup details, see the [Getting started guide](/docs/quickstart/installation).
## Step 2: Replace your API calls
ZenRows and AlterLab share a similar REST API shape. Below is a direct before‑and‑after comparison.
```python title="before_zenrows.py"
# ZenRows (before migration)
from zenrows import ZenRowsClient
client = ZenRowsClient("YOUR_ZENROWS_API_KEY")
response = client.get("https://example.com", params={"js_render": true})
html = response.text
```python title="after_alterlab.py" {3-7}
AlterLab (after migration)
client = alterlab.Client("YOUR_ALTERLAB_API_KEY")
response = client.scrape("https://example.com", js_render=True)
html = response.text # Same data, pay‑as‑you-go pricing
If you prefer to call the REST endpoint directly, the URL pattern is also compatible:
- ZenRows: `https://api.zenrows.com/v1/?apikey=KEY&url=URL&js_render=true`
- AlterLab: `https://api.alterlab.io/v1/?apikey=KEY&url=URL&js_render=true`
## Step 3: Handle response format differences
AlterLab returns a response object that mirrors ZenRows in the most common fields:
- `response.text` – the raw HTML (or selected format)
- `response.status_code` – HTTP status
- `response.headers` – response headers
The only notable difference is that AlterLab nests error details under `response.error` when `status_code >= 400`, whereas ZenRows includes them directly in the JSON body. For successful scrapes, you can treat the objects interchangeably.
## Step 4: Update your error handling
Adjust any try/except blocks to check for AlterLab’s error structure.
```python title="error_handling.py"
try:
response = client.scrape(url)
if response.status_code != 200:
raise Exception(f"AlterLab error: {response.error}")
process(response.text)
except Exception as e:
# retry logic or alerting
logger.error(f"Scrape failed: {e}")
Both libraries use standard HTTP status codes (429 for rate limiting, 5xx for server issues), so existing retry logic based on status codes works unchanged.
Cost comparison
To illustrate the financial impact, consider 10,000 scraping requests per month.
- AlterLab: 10,000 × $0.0002 = $2.00 per month. No subscription, no minimum spend, and unused balance carries over indefinitely.
- ZenRows: Their lowest flat‑rate plan is $49/month for 10,000 requests (≈ $0.0049/request). If you use fewer than 10,000 requests, you still pay the full $49; unused requests do not roll over.
See the latest pricing on the AlterLab pricing page for volume discounts and tier details.
Common issues and fixes
-
Missing
js_renderflag – AlterLab uses the same parameter name as ZenRows (js_render=true). If you previously usedrender_js, rename it. -
API key environment variable – Rename
ZENROWS_API_KEYtoALTERLAB_API_KEYin your.envor CI secrets. -
Response encoding – AlterLab always returns UTF‑8 decoded text; if you relied on
response.contentfor binary data, useresponse.raw_contentinstead. -
Rate‑limit headers – AlterLab sends
X-RateLimit-RemainingandX-RateLimit-Reset(same as ZenRows), so your throttling code needs no change.
You're done
Your migration is complete. Run your test suite to confirm everything works, then deploy. For more advanced features like scheduling, webhooks, or Cortex AI extraction, visit the full documentation. If you hit any snags, hit reply if you have questions.
AlterLab // Web Data, Simplified.
Top comments (0)