Scrapix API
Project description
Scrapix — Python SDK
Official Python client for Scrapix — an AI-powered web scraping and data extraction API. Fetch pages, collect URLs, crawl sites, and extract structured data from a single function call, with JS rendering, proxy rotation, captcha solving, and LLM-backed extraction handled server-side.
Table of contents
- Installation
- Authentication
- Quick start
- Endpoints
- Common input options
- Output formats
- Error handling
- Custom host / advanced configuration
- Links
- License
Installation
pip install scrapix
Requires Python 3.9 or newer.
Authentication
All requests require an API key. Get one at scrapix.promptcloud.com and either pass it explicitly or load it from an environment variable:
import os
from scrapix import create_client
api = create_client(os.environ["SCRAPIX_API_KEY"])
Quick start
from scrapix import create_client, ScrapeInput
api = create_client("YOUR_API_KEY")
result = api.scrape(ScrapeInput(url="https://example.com"))
print(result.data.data) # page content (HTML by default)
print(result.status_code) # upstream HTTP status
print(result.credits_used) # credits consumed by this call
create_client(api_key) targets https://api-scrapix.promptcloud.com by default. Override with create_client(api_key, host="https://your-host").
Endpoints
scrape — single page
Fetch one URL and return its content in the requested format.
from scrapix import create_client, ScrapeInput
api = create_client("YOUR_API_KEY")
result = api.scrape(ScrapeInput(
url="https://example.com",
output_format="markdown", # html | text | markdown | docx | pdf | base64
render=True, # execute JS before returning
))
print(result.data.format) # "markdown"
print(result.data.data) # rendered markdown
collect — URLs from a page
Extract outgoing links from a page. Useful as a first step before crawling.
from scrapix import create_client, CollectInput
result = api.collect(CollectInput(
url="https://example.com",
urls_limit=100,
include_paths=r"^/blog/", # regex filter — keep only matching paths
exclude_paths=r"/tag/|/author/",
include_sitemap_urls=True, # also harvest URLs from sitemap.xml
))
# result.links.data is a serialized string in result.links.format ("json" by default)
print(result.links.data)
crawl — collect + scrape
Collect URLs from a starting page and scrape each one in a single call.
from scrapix import create_client, CrawlInput
result = api.crawl(CrawlInput(
url="https://books.toscrape.com/",
urls_limit=10, # 1–25
output_format="markdown",
include_sitemap_urls=False,
))
for page in result.responses:
print(page.url, "->", len(page.data.data), "chars")
extract — structured data & summaries
Run an LLM over a page to answer a natural-language query or extract structured data.
from scrapix import create_client, ExtractInput
# Free-form answer
result = api.extract(ExtractInput(
url="https://example.com",
query="What is this website about? Answer in one sentence.",
))
print(result.result)
# Structured extraction — provide a JSON Schema
from scrapix import StructuredOutputSchema
result = api.extract(ExtractInput(
url="https://books.toscrape.com/",
query="Extract the first 5 books on this page.",
structured_schema=StructuredOutputSchema(
query="Extract the first 5 books.",
schema={
"type": "object",
"properties": {
"books": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {"type": "string"},
"price": {"type": "string"},
},
},
}
},
},
),
))
print(result.structured_output.data) # serialized in result.structured_output.format
Common input options
Every input model accepts the following fields in addition to its endpoint-specific ones:
| Field | Type | Default | Description |
|---|---|---|---|
url |
str |
— | Target URL (required). |
timeout |
int |
40 |
Request timeout in seconds (10–1000). |
max_retries |
int |
5 |
Max retries before the request fails. |
render |
bool |
False |
Execute JavaScript before capturing the page. |
premium_proxies |
bool |
False |
Route through premium residential/mobile proxies. |
auto_proxy |
bool |
False |
Escalate automatically: normal proxies → premium → render fallback. |
use_captcha_solver |
bool |
False |
Solve captchas when encountered. |
use_cache |
bool |
True |
Serve from the fresh-crawl cache when available. |
Output formats
| Format | Where it applies | Notes |
|---|---|---|
html |
scrape, crawl |
Default. |
text |
scrape, crawl |
Plain-text extraction. |
markdown |
scrape, crawl |
HTML → Markdown conversion. |
docx / pdf |
scrape, crawl |
Binary content, base64-encoded. |
base64 |
scrape, crawl |
Raw HTML as base64. |
json (default) |
collect, extract.structured_output |
Other structured formats also allowed. |
xml/yaml/toml |
collect, extract.structured_output |
Error handling
API errors raise scrapix.ApiException (and its subclasses BadRequestException, UnauthorizedException, NotFoundException, ServiceException, …):
from scrapix import create_client, ScrapeInput
from scrapix.exceptions import ApiException
try:
result = api.scrape(ScrapeInput(url="https://example.com"))
except ApiException as e:
print(f"HTTP {e.status}: {e.reason}")
print(e.body) # raw error body
print(e.headers) # response headers
Non-HTTP failures (network, timeout) raise the underlying urllib3 exception.
Custom host / advanced configuration
create_client wraps the common "Configuration + ApiClient + APIServicesApi" setup. When you need interceptors, per-request timeouts, or connection pooling, drop down to the raw client:
import scrapix
config = scrapix.Configuration(
host="https://api-scrapix.promptcloud.com",
api_key={"APIKeyHeader": "YOUR_API_KEY"},
)
config.retries = 3
with scrapix.ApiClient(config) as client:
api = scrapix.APIServicesApi(client)
result = api.scrape(
scrapix.ScrapeInput(url="https://example.com"),
_request_timeout=60,
)
Every endpoint method accepts per-call overrides via _request_timeout, _headers, and _host_index. See the API reference for the full list.
Links
- Home: https://scrapix.promptcloud.com
- API reference: https://docs-scrapix.promptcloud.com/api-reference/scrapix-api
- Docs: https://docs-scrapix.promptcloud.com
- Source: https://github.com/promptcloud/scrapix-sdk/tree/main/python
- Issues: https://github.com/promptcloud/scrapix-sdk/issues
- Changelog: https://github.com/promptcloud/scrapix-sdk/releases
License
Released under the terms of the LICENSE file shipped with this package.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scrapix-0.1.4.tar.gz.
File metadata
- Download URL: scrapix-0.1.4.tar.gz
- Upload date:
- Size: 40.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"11","id":"bullseye","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f26a10427018dffa7213ada65403121cccf60312eee3020d38eab8736fe0b078
|
|
| MD5 |
6f7834fa25311eb91504bee6225dad7b
|
|
| BLAKE2b-256 |
366c03f8f03f70d5960719ade15a82b39cf7c3d10864df346071bf23f64a9613
|
File details
Details for the file scrapix-0.1.4-py3-none-any.whl.
File metadata
- Download URL: scrapix-0.1.4-py3-none-any.whl
- Upload date:
- Size: 58.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"11","id":"bullseye","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a76467637ba095416b85a15bfb1d5d72eb8916fd864bfa64473424263f06ff2
|
|
| MD5 |
0fe6c4ddb30eef774227d922abe2c14b
|
|
| BLAKE2b-256 |
c341188b086d81d0b5e21cd943bd837b96ba28fa7217cfdd8b15401410bdeb4a
|