Skip to content

SDKs

Python

Copy page

Use the Firecrawl Python SDK with DarkCrawl, and what it drops or sends for you.

Works with Python

Install the Firecrawl Python SDK, then point it at DarkCrawl. Tested with firecrawl==4.54.0.

Python
# pip install firecrawl
import os
from firecrawl import Firecrawl

firecrawl = Firecrawl(
    api_key=os.environ["DARKCRAWL_API_KEY"],
    api_url="https://api.darkcrawl.dev",
)
doc = firecrawl.scrape("http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice", formats=["markdown"])
print(doc.markdown)

The same client does the rest of Firecrawl’s calls. The crawl waits for the job to finish. The agent is started and read as two calls.

Python
site = "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice"
job = firecrawl.crawl(site, limit=10)  # starts the crawl and waits for it
links = firecrawl.map(site).links
started = firecrawl.start_agent([site], prompt="Where did the mirror list move?")
status = firecrawl.get_agent_status(started.id)
  • Stored copies. The SDK sends maxAge of 4 hours unless you set max_age, so a scrape can be served from a copy up to 4 hours old. Pass max_age=0 for a fresh page.
  • Retries. The SDK sends a request again when it gets a 502, up to 3 times by default, and DarkCrawl uses 502 for ONION_UNREACHABLE and GATED. To send it once, create the client with max_retries=1.
Python
import os
from firecrawl import Firecrawl

firecrawl = Firecrawl(
    api_key=os.environ["DARKCRAWL_API_KEY"],
    api_url="https://api.darkcrawl.dev",
    max_retries=1,
)

doc = firecrawl.scrape("http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice", formats=["markdown"], max_age=0)
  • No timeout. The SDK sets no HTTP timeout of its own. DarkCrawl ends every scrape by its own timeout (120 seconds by default), which includes any wait for a fetch slot.
  • Dropped fields. The SDK’s Document model drops the top-level indicators and resources lists. It keeps DarkCrawl’s metadata additions, for example doc.metadata.model_extra["evidence"]. For indicators, call the HTTP API directly. Its search result model drops captureId and fetchedAt, and its agent status drops sources, pagesRead, steps and warning: read those from the raw reply.
  • Monitors. create_monitor and update_monitor take fixed keyword arguments, so they cannot send channelIds. A search target’s sources does pass.
  • Parse. firecrawl.parse sends the file you name. With options=, the SDK also sends its scrape defaults, and /v2/parse accepts them.
Python
doc = firecrawl.parse("./report.pdf")
  • Agent. The blocking agent() returns on its timeout with the last status it read, which can still be processing. Poll get_agent_status. A cancelled job reads failed with error: "Agent was cancelled", and a second cancel once it has stopped raises with 409. start_agent with a webhook raises with 400 NOT_IMPLEMENTED.
  • Extract. start_extract raises with the 501 refusal. Use the agent.

The codes DarkCrawl answers with are on Errors.