A simple Python SDK for seamlessly interacting with Oxylabs AI Studio API services, including AI-Scraper, AI-Crawler, AI-Browser-Agent and other data extraction tools.
Requirements
python 3.10 and above
API KEY
Installation
pip install oxylabs-ai-studio
Usage
Crawl (AiCrawler.crawl)
from oxylabs_ai_studio.apps.ai_crawler import AiCrawler
crawler = AiCrawler(api_key="<API_KEY>")
url = "https://oxylabs.io"
result = crawler.crawl(
url=url,
user_prompt="Find all pages with proxy products pricing",
output_format="markdown",
render_javascript=False,
return_sources_limit=3,
geo_location="United States",
)
print("Results:")
for item in result.data:
print(item, "\n")
Parameters:
url (str): Starting URL to crawl (required)
user_prompt (str): Natural language prompt to guide extraction (required)
output_format (Literal["json", "markdown", "csv", "toon"]): Output format (default: "markdown")
schema (dict | None): Json schema for structured extraction (required if output_format is "json", "csv" or "toon")
optimize_content (bool): Return cleaner markdown by focusing on the main page content. Output will be smaller in size when set to True (default: True)
browser_instructions (list[BrowserInstruction] | None): Browser actions to run before capture (click, input, wait, etc.). Requires render_javascript=True. Format follows Web Scraper API browser instructions.
Browser Agent (BrowserAgent.run)
from oxylabs_ai_studio.apps.browser_agent import BrowserAgent
browser_agent = BrowserAgent(api_key="<API_KEY>")
schema = browser_agent.generate_schema(
prompt="game name, platform, review stars and price"
)
print("schema: ", schema)
prompt = "Find if there is game 'super mario odyssey' in the store. If there is, find the price. Use search bar to find the game."
url = "https://sandbox.oxylabs.io/"
result = browser_agent.run(
url=url,
user_prompt=prompt,
output_format="json",
schema=schema,
)
print(result.data)
Parameters:
url (str): Starting URL to browse (required)
user_prompt (str): Natural language prompt for extraction (required)
return_content (bool): Whether to return markdown contents in results (default: True)
geo_location (string): ISO 2-letter format, country name, coordinate formats are supported. See more at SERP Localization.
Note: When limit <= 10 and return_content=False, the search automatically uses the instant endpoint (/search/instant) which returns results immediately without polling, providing faster response times.
Instant search supported parameters:
query (string): The search query.
limit (integer): The maximum number of search results to return. Maximum: 10.
geo_location (string): Google's canonical name of the location. See more at Google Ads GeoTargets.