DEV Community

Cover image for How to Migrate from ScraperAPI to AlterLab: Step-by-Step Guide (2026)
AlterLab
AlterLab

Posted on • Originally published at alterlab.io

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

The primary drivers for developers migrating from ScraperAPI to AlterLab are the removal of monthly subscription fees and the elimination of credit expiry. ScraperAPI requires a $49 monthly minimum spend, and unused credits disappear at the end of each billing cycle. AlterLab moves this to a pure pay-as-you-go model where your balance never expires.

Both APIs are capable tools for web data extraction. This guide is for developers prioritizing pay-as-you-go pricing and no subscription requirements. For a deep dive into feature differences, read our detailed ScraperAPI comparison.

Prerequisites

You only need three things to complete this migration:

  1. An AlterLab account. Sign up for free here.
  2. Your AlterLab API key from the dashboard.
  3. Access to your existing scraping codebase.

The migration typically takes 5 to 10 minutes for simple scripts and under an hour for complex production pipelines.

Step 1: Install the AlterLab SDK

If you currently use the ScraperAPI Python library, you can switch to the AlterLab SDK. This handles proxy rotation, retries, and browser rendering automatically. For more installation options, see our Getting started guide.

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




If you prefer using the REST API directly via `requests` or `curl`, the transition is even simpler as the endpoint structure is almost identical.

## Step 2: Replace your API calls

AlterLab's Python SDK is designed to be familiar. You initialize a client with your API key and call the `scrape` method.

Compare the before and after examples below.



```python title="before_scraperapi.py"

# Initializing ScraperAPI
client = scraperapi.ScraperAPIClient('YOUR_SCRAPER_API_KEY')

# Performing a scrape
response = client.get(url='https://example.com', render=True)

# Accessing content
print(response.text)
Enter fullscreen mode Exit fullscreen mode

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

Initializing AlterLab

client = alterlab.Client("YOUR_ALTERLAB_API_KEY")

Performing a scrape

min_tier=3 enables JavaScript rendering

response = client.scrape("https://example.com", min_tier=3)

Accessing content

print(response.text)




### Parameter Mapping

When migrating, you may need to map specific ScraperAPI flags to AlterLab parameters.

*   **JavaScript Rendering**: In ScraperAPI, you use `render=true`. In AlterLab, use `min_tier=3`. Tiers 3 through 5 use headless browsers.
*   **Country Targeting**: ScraperAPI uses `country_code=us`. AlterLab uses `country='us'`.
*   **Premium Proxies**: ScraperAPI uses `premium=true`. AlterLab handles this via tiers. Use `min_tier=2` for residential proxies or `min_tier=5` for advanced anti-bot bypass including CAPTCHA solving.

## Step 3: Handle response format differences

The core content of the response remains the same. If you are scraping HTML, `response.text` gives you the raw source. However, if you are using JSON output, there is a slight structural difference in the return object.

AlterLab allows you to request multiple formats in a single request, such as JSON and Markdown.



```python title="response_handling.py"
# AlterLab can return structured data directly
response = client.scrape(
    "https://example.com/product",
    formats=["json", "markdown"]
)

# Accessing specific formats
data = response.json()
markdown_content = data.get("markdown")
Enter fullscreen mode Exit fullscreen mode

ScraperAPI typically returns the raw HTML body. AlterLab provides a cleaner data structure, especially when using Cortex AI to extract specific fields without CSS selectors.

Step 4: Update your error handling

ScraperAPI and AlterLab both use standard HTTP status codes.

  • 200: Success.
  • 403: Invalid API key or exhausted balance.
  • 429: Rate limit exceeded.
  • 500: Remote server error or scraping failure.

The AlterLab SDK includes an internal circuit breaker and automatic retry logic for 429 and 500 errors. You can usually remove manual retry loops from your ScraperAPI implementation.

```python title="error_handling.py"
try:
response = client.scrape("https://target-site.com")
response.raise_for_status()
except Exception as e:
print(f"Scrape failed: {e}")




## Cost Comparison

ScraperAPI uses a monthly subscription model. If you do not use your credits, they expire. If you need more credits, you must upgrade to a higher monthly tier.

AlterLab uses a flat rate per request. You pay for what you use. If you scrape 100 pages this month and 10,000 next month, your costs scale exactly with your usage. There are no monthly fees to keep your account active.

<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>

For a full breakdown of request costs across different tiers, visit [AlterLab pricing](/pricing).

## Common issues and fixes

### 1. JavaScript not loading
If your ScraperAPI code used `render=true` and the page isn't loading correctly in AlterLab, ensure you are using `min_tier=3` or higher. Tier 1 and Tier 2 are for static HTML (curl-based) and do not execute JavaScript.

### 2. API Key environment variables
Ensure you update your `.env` or CI/CD secrets. Developers often replace the library but forget to update the `SCRAPERAPI_KEY` environment variable to `ALTERLAB_API_KEY`.

### 3. Header handling
ScraperAPI often requires custom headers to be passed as `headers={...}`. AlterLab does the same, but it automatically manages User-Agents and browser headers by default to maximize success rates. You can usually remove your custom User-Agent strings.

## You're done

Migrating to AlterLab gives you more control over your scraping costs without sacrificing technical capabilities. You now have access to features like Cron-based scheduling, change monitoring, and AI-powered extraction.

If you have specific edge cases or need help with a large-scale migration, check the full documentation or reach out to our engineering team.

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

Top comments (0)