ScraperCity logo

Developer SDK

ScraperCity SDK for Python and JavaScript

Pull B2B leads, local businesses and online stores into your own code. One package per language, the same tool list as the ScraperCity MCP server, and agent tools for LangChain, LangGraph, OpenAI and Claude.

pip install scrapercity
npm install scrapercity

When to use the SDK

Reach for the SDK when your own program makes the calls: a nightly job that pulls fresh leads into your CRM, a backend that enriches signups, a notebook that sizes a market, or an agent you are building yourself. If you want an AI assistant such as Claude Code or Cursor to pick the tools for you, connect the MCP server instead. If you prefer raw HTTP, every endpoint is in the API docs.

Both SDKs are generated from the same source as the API documentation. Each release rebuilds the tool list, publishes npm and PyPI at the same version, and keeps the arguments identical to what the MCP server accepts, so code you write against one tool keeps working as the catalog grows.

Python quick start

Python 3.9 or newer. The core client has no dependencies. Set SCRAPERCITY_API_KEY or pass the key to the constructor.

from scrapercity import ScraperCity

sc = ScraperCity()                     # reads SCRAPERCITY_API_KEY
print(sc.wallet())                     # credit balance and plan

# Instant database search ($149/mo plan and up)
leads = sc.query_leads(title="Head of Marketing", country=["United States"], hasEmail=True, limit=25)

# Unsure of the exact filter values? Describe the audience in plain English.
plan = sc.plan_search("dentists in Austin, Texas")

# Scrapers run in the background: start one, wait, save the CSV
run = sc.scrape_maps("plumbers", "Denver, CO", limit=200)
sc.poll_until_done(run["runId"])
sc.download(run["runId"], "plumbers.csv")

Every tool is also callable by name with the arguments shown in the tool list:

sc.call_tool("query_local_business_database", {"keyword": ["thai restaurant"], "location": ["Houston TX"], "hasEmail": True})
for tool in sc.tools():
    print(tool["name"], "-", tool["description"][:80])

JavaScript and Node.js quick start

Node 18 or newer, ES modules. The same package ships the scrapercity CLI and the scrapercity-mcp server.

import { configure, wallet, dbLocalBusinesses, callTool, TOOLS } from 'scrapercity'

configure({ apiKey: process.env.SCRAPERCITY_API_KEY })
console.log(await wallet())

const shops = await dbLocalBusinesses({ keyword: ['bike shop'], location: ['Portland OR'], hasEmail: 'true', limit: 50 })

// Any tool by name, exactly as an MCP client would call it
const plan = await callTool('plan_search', { query: 'CFOs at fintech companies in New York' })
console.log(TOOLS.map(t => t.name))

Agent frameworks

Hand the whole catalog, or a chosen few tools, to the framework you already use. Each tool carries its description and JSON schema, so the model knows what every argument means.

LangChain and LangGraph (Python)

# pip install "scrapercity[langchain]" langgraph
from scrapercity import langchain_tools
from langgraph.prebuilt import create_react_agent

tools = langchain_tools(include=["plan_search", "query_lead_database", "validate_emails"])
agent = create_react_agent(llm, tools)
agent.invoke({"messages": [("user", "Find 50 VPs of Sales at SaaS companies in Texas with work emails")]})

OpenAI Agents SDK and function calling (Python)

# pip install "scrapercity[openai]"
from agents import Agent, Runner
from scrapercity.openai_tools import get_tools

agent = Agent(name="Prospector", tools=get_tools())
Runner.run_sync(agent, "List 100 roofing companies in Phoenix that have a phone number")

# Plain function calling instead:
# tools=get_function_definitions(); then handle_tool_call(name, arguments) for each call

Claude and OpenAI tool calling (JavaScript)

import Anthropic from '@anthropic-ai/sdk'
import { anthropicTools, callTool } from 'scrapercity'

const client = new Anthropic()
const msg = await client.messages.create({ model: 'claude-sonnet-5-5', max_tokens: 2048, tools: anthropicTools(), messages })
for (const block of msg.content) {
  if (block.type === 'tool_use') {
    const result = await callTool(block.name, block.input)   // send back as a tool_result
  }
}
// OpenAI: tools: openaiTools(), then callTool(call.function.name, JSON.parse(call.function.arguments))

What the SDK can reach

Prices per tool are on the pricing page, and the full parameter reference for each endpoint is in the API docs.

Packages and source

FAQ

Get your API key and start building: