DEV Community

AlterLab
AlterLab

Posted on • Originally published at alterlab.io

How to Migrate from Apify to AlterLab: Step-by-Step Guide (2026)

How to Migrate from Apify to AlterLab: Step-by-Step Guide (2026)

TL;DR

To migrate from Apify to AlterLab, install the AlterLab SDK, replace your Apify client with alterlab.Client using your AlterLab API key, and keep the same scrape calls. The response format is similar, so minimal code changes are needed.

Why migrate?

Apify’s actor marketplace and compute unit billing can make costs unpredictable for simple scraping tasks. AlterLab offers a pay‑as‑you‑go model with no subscription, so you only pay for the requests you make.

Prerequisites

  • An AlterLab account (free at free sign-up)
  • Your AlterLab API key from the dashboard
  • About five minutes to update your code

Step 1: Install the AlterLab SDK

You can use the REST API directly, but the Python SDK mirrors the Apify client pattern.

```bash title="Terminal — Install AlterLab"
pip install alterlab




See the [Getting started guide](/docs/quickstart/installation) for other language options.

## Step 2: Replace your API calls
Below is a side‑by‑side comparison of a basic scrape request.



```python title="before_apify.py"
# Apify (before migration)
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("actor_id").call(run_input={"url": "https://example.com"})
# Fetch results from the run's default dataset
Enter fullscreen mode Exit fullscreen mode

```python title="after_alterlab.py" {3-6}

AlterLab (after migration)

client = alterlab.Client("YOUR_ALTERLAB_API_KEY")
response = client.scrape("https://example.com")
print(response.text) # Same HTML, pay‑as‑you‑go pricing




The AlterLab `scrape` method returns an object with `text`, `html`, and `json` attributes, similar to Apify’s dataset items.

## Step 3: Handle response format differences
Apify returns data through a dataset that you must iterate over. AlterLab returns the scraped content directly in the response object.

- If you need JSON output, add `formats=['json']` to the scrape call.
- For raw HTML, use `response.html` (same as Apify’s HTML field).
- Metadata such as status code and headers are available via `response.status_code` and `response.headers`.

## Step 4: Update your error handling
AlterLab uses standard HTTP status codes:
- 200: Success
- 429: Rate limit – retry after the `Retry-After` header
- 500‑503: Temporary issues – exponential backoff works as before

Replace any Apify‑specific error checks with generic HTTP status handling. Retry logic from your existing Apify code can be reused unchanged.

## Cost comparison
For a typical workload of 10,000 requests per month:

<div data-infographic="stats">
  <div data-stat data-value="$0.0002" data-label="Per Request (AlterLab)"></div>
  <div data-stat data-value="$0" data-label="Monthly Minimum"></div>
  <div data-stat data-value="Never" data-label="Balance Expiry"></div>
</div>

- AlterLab: 10,000 × $0.0002 = $2.00, no monthly fee, balance never expires.
- Apify: Compute unit pricing varies; a similar volume often incurs a monthly subscription plus usage fees, making the total higher and less predictable.

See the full breakdown on the [AlterLab pricing](/pricing) page.

## Common issues and fixes
- **Missing API key**: Double‑check that you placed the AlterLab key in your environment variable or config file.
- **Unexpected response format**: Ensure you are accessing `response.text` or `response.json()` as needed; AlterLab does not wrap data in a dataset layer.
- **Rate limit headers**: AlterLab sends `Retry-After` seconds; adjust your backoff logic to read this header.
- **Proxy authentication**: AlterLab handles proxy rotation automatically; remove any manual proxy settings from your Apify code.

## You're done
Your migration is complete. Run your test suite to confirm everything works, then deploy. For more details, see the [detailed Apify comparison](/vs/apify) and the AlterLab documentation.

AlterLab // Web Data, Simplified.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)