Scraping AI Python SDK (scraping-ai)
A modern, type-safe Python SDK for interacting with the Scraping AI core service API endpoints. It supports both synchronous and asynchronous operations using httpx and pydantic.
This SDK focuses strictly on core service execution endpoints (v1 pipeline orchestration, data extraction, and v2 standalone modules), excluding account management, billing, payments, and administrative routes.
Installation
pip install scraping-ai
Core Service Usage
1. v1 Unified Pipeline Flow
from scraping_ai import ScrapingAIClient
# Initialize client using API Key
client = ScrapingAIClient(api_key="your_api_key_here")
# Create an InputState
state = client.input_states.create(
base_url="https://example.com",
user_instruction="dummy_user_instruction",
schema_instruction="dummy_schema_instruction"
)
print(f"Created input state ID: {state.id}")
# Trigger the auto-flow pipeline
flow = client.input_states.run_flow(state.id)
print(f"Flow started. First step: {flow.first_step}")
# Wait for extraction step to finish
state = client.input_states.wait_for_task(state.id, "extractor", poll_interval=5.0)
print(f"Extraction status: {state.extraction_status}")
# Fetch extracted data rows
data_res = client.data.get_by_state(state.id)
for row in data_res.results:
print(row.data)
2. v2 Standalone Async Modules
import asyncio
from scraping_ai import AsyncScrapingAIClient
async def main():
async with AsyncScrapingAIClient(api_key="your_api_key_here") as client:
# Start a v2 keyword generation run
run_info = await client.v2_keywords.run(context="dummy_context", num_keywords=10)
print(f"Accepted run for State ID {run_info.state_id}")
# Poll status
status_info = await client.v2_keywords.status(run_info.state_id)
print(f"Current status: {status_info.status}")
# Retrieve result when finished
res = await client.v2_keywords.result(run_info.state_id)
print(f"Keywords generated: {res.keywords}")
asyncio.run(main())
Core Service Operations Summary
The SDK exposes service operations under core namespaces:
v1 Pipeline & Data Operations
client.input_states: Create, list, retrieve, update, patch, triggerrun_flow, andwait_for_taskhelper.client.tasks: List available background tasks (list_available) and trigger tasks (run).client.task_entries: Create an InputState and run a task in one call (create), or query task status (get_status).client.data: Retrieve extracted rows (get_by_state) and download CSV exports (export_by_state).
v2 Standalone Service Modules
client.v2_keywords:run,status,resultfor standalone keyword generation.client.v2_finder:run,status,resultfor URL discovery.client.v2_crawler:run,status,resultfor page crawling.client.v2_extractor:run,status,resultfor LLM data extraction.client.v2_exports:create,list,getfor presigned S3 exports.client.v2_ranker:run,status,resultfor URL relevance ranking.client.v2_schema:run,status,resultfor JSON Schema generation.client.v2_search_url:run,status,resultfor search URL generation.client.v2_search_results:run,status,resultfor search results finder.
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 scraping_ai-0.2.1.tar.gz.
File metadata
- Download URL: scraping_ai-0.2.1.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8b90c239bec04f076b716490bd77429d9e11c23b8d8157e9be25fb3e6679dd1
|
|
| MD5 |
267d3f2f8c273c7c9b5e29690d3c7175
|
|
| BLAKE2b-256 |
905efebacfa708ee91784cad3fc65c67acbbd6e5d3a3df716655a71fb5bb0416
|
File details
Details for the file scraping_ai-0.2.1-py3-none-any.whl.
File metadata
- Download URL: scraping_ai-0.2.1-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
591113efa510543cf39bc4559df3af4eb993ea895910489dbb0d519a47f53826
|
|
| MD5 |
33418702ad9b18197ba0e342e998cf3c
|
|
| BLAKE2b-256 |
319736c5b24369063afd0de12a98d5e49a9dc1a1ab8225c3aa15fed5185a98db
|