Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.lobstr.io/llms.txt

Use this file to discover all available pages before exploring further.

Installation

pip install lobstrio-sdk

Sync & Async

Both LobstrClient and AsyncLobstrClient with identical API surfaces.

Typed Models

Dataclass models for every response — no raw dicts in the public API.

Auto-Pagination

Lazy PageIterator streams all pages on demand with .iter() method.

Automatic Auth

Token resolved from explicit param, LOBSTR_TOKEN env, or ~/.config/lobstr/config.toml.

Authentication

The SDK resolves your API token in this order:
  1. Explicit parameterLobstrClient(token="your_token")
  2. Environment variableLOBSTR_TOKEN=your_token
  3. CLI config file~/.config/lobstr/config.toml (written by the lobstr CLI on login)
If LOBSTR_TOKEN is not set, the SDK silently falls back to the CLI config file — which may belong to a different account. There is no warning when the env var is absent. Always set LOBSTR_TOKEN explicitly in production environments.
export LOBSTR_TOKEN=your_api_key

Quick Start

import time
from lobstrio import LobstrClient

# Token resolved from LOBSTR_TOKEN env var, then ~/.config/lobstr/config.toml.
# Set LOBSTR_TOKEN explicitly in production — misnamed env vars fail silently.
client = LobstrClient()

# 1. Resolve crawler slug → id (create() requires the hash, not the slug)
crawlers = client.crawlers.list()
crawler = next(c for c in crawlers if c.slug == "google-maps-leads-scraper")

# 2. Create a squid
squid = client.squids.create(crawler=crawler.id, name="Restaurants Paris")

# 3. Configure squid-level params — required before runs.start(), even when all
#    params are optional. Pass None for params you don't need to set.
client.squids.update(squid.id, params={"language": "English (United States)", "max_results": 50})

# 4. Add tasks
client.tasks.add(squid=squid.id, tasks=[
    {"url": "https://www.google.com/maps/search/restaurants/@48.8566,2.3522,14z"}
])

# 5. Start run and stream progress
def on_progress(stats):
    print(f"  {stats.percent_done}{stats.total_results} results, ETA {stats.eta}")

run = client.runs.start(squid=squid.id)
print(f"Run {run.id} started")
run = client.runs.wait(run.id, callback=on_progress)
print(f"Run complete — {run.total_results} results, {run.credit_used} credits used")

# 6. Wait for export to be ready before fetching results
while not run.export_done:
    time.sleep(3)
    run = client.runs.get(run.id)

# 7. Iterate results (PageIterator yields one dict per result)
for place in client.results.iter(squid=squid.id):
    print(f"{place['name']}{place.get('score', 'N/A')}{place.get('phone', '')}")

# 8. Clean up — delete the squid to free the slot
client.squids.delete(squid.id)

API Reference

User

SDK MethodHTTPEndpointDescription
client.me()GET/v1/meGet authenticated user profile
client.balance()GET/v1/user/balanceGet current credit balance
Balance.available is your plan’s total allotment, not credits remaining. Remaining credits = available − consumed. Example: Balance(available=100, consumed=64) means 36 credits left.

Crawlers

SDK MethodHTTPEndpointDescription
client.crawlers.list()GET/v1/crawlersList all available crawlers
client.crawlers.get(hash)GET/v1/crawlers/{hash}Get crawler details by hash
client.crawlers.params(hash)GET/v1/crawlers/{hash}/paramsGet supported parameters for a crawler
client.crawlers.attributes(hash)GET/v1/crawlers/{hash}/attributesGet output attributes for a crawler

Squids

SDK MethodHTTPEndpointDescription
client.squids.create(crawler, name)POST/v1/squidsCreate a new squid for a crawler
client.squids.list()GET/v1/squidsList all squids in your account
client.squids.get(hash)GET/v1/squids/{hash}Get squid details by hash
client.squids.update(hash, ...)POST/v1/squids/{hash}Update squid settings or parameters
client.squids.empty(hash)POST/v1/squids/{hash}/emptyRemove all tasks from a squid
client.squids.delete(hash)DELETE/v1/squids/{hash}Permanently delete a squid

Tasks

SDK MethodHTTPEndpointDescription
client.tasks.add(squid, tasks)POST/v1/tasksAdd one or more tasks to a squid
client.tasks.list(squid)GET/v1/tasksList tasks for a squid
client.tasks.get(hash)GET/v1/tasks/{hash}Get a single task by hash
client.tasks.upload(squid, file)POST/v1/tasks/uploadBulk upload tasks from a file
client.tasks.upload_status(id)GET/v1/tasks/upload/{id}Check status of a bulk upload
client.tasks.delete(hash)DELETE/v1/tasks/{hash}Delete a task by hash

Runs

SDK MethodHTTPEndpointDescription
client.runs.start(squid)POST/v1/runsStart a new run for a squid
client.runs.list(squid)GET/v1/runsList all runs for a squid
client.runs.get(hash)GET/v1/runs/{hash}Get run details by hash
client.runs.stats(hash)GET/v1/runs/{hash}/statsGet statistics for a run
client.runs.tasks(hash)GET/v1/runtasksList tasks executed in a run
client.runs.abort(hash)POST/v1/runs/{hash}/abortAbort an in-progress run
client.runs.download_url(hash)GET/v1/runs/{hash}/downloadGet S3 download URL for run results
client.runs.download(hash, dest)GET/v1/runs/{hash}/downloadDownload run results to a local file
client.runs.wait(hash, callback=None)Poll until run completes; optional callback(RunStats) for progress

Results

SDK MethodHTTPEndpointDescription
client.results.list(squid)GET/v1/resultsGet first page of results for a squid
client.results.iter(squid)GET/v1/resultsLazily iterate all result pages for a squid

Accounts

SDK MethodHTTPEndpointDescription
client.accounts.list()GET/v1/accountsList all connected accounts
client.accounts.get(hash)GET/v1/accounts/{hash}Get account details by hash
client.accounts.types()GET/v1/accounts/typesList supported account types
client.accounts.sync(type, cookies)POST/v1/accounts/cookiesSync an account using cookies
client.accounts.delete(hash)DELETE/v1/accounts/{hash}Delete a connected account

Delivery

SDK MethodHTTPEndpointDescription
client.delivery.email(squid, ...)POST/v1/deliveryConfigure email delivery for a squid
client.delivery.google_sheet(squid, ...)POST/v1/deliveryConfigure Google Sheets delivery
client.delivery.s3(squid, ...)POST/v1/deliveryConfigure Amazon S3 delivery
client.delivery.webhook(squid, ...)POST/v1/deliveryConfigure webhook delivery
client.delivery.sftp(squid, ...)POST/v1/deliveryConfigure SFTP delivery