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.
# 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.
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)Things to know
Section titled “Things to know”- Stored copies. The SDK sends
maxAgeof 4 hours unless you setmax_age, so a scrape can be served from a copy up to 4 hours old. Passmax_age=0for 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_UNREACHABLEandGATED. To send it once, create the client withmax_retries=1.
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
Documentmodel drops the top-levelindicatorsandresourceslists. It keeps DarkCrawl’smetadataadditions, for exampledoc.metadata.model_extra["evidence"]. For indicators, call the HTTP API directly. Its search result model dropscaptureIdandfetchedAt, and its agent status dropssources,pagesRead,stepsandwarning: read those from the raw reply. - Monitors.
create_monitorandupdate_monitortake fixed keyword arguments, so they cannot sendchannelIds. A search target’ssourcesdoes pass. - Parse.
firecrawl.parsesends the file you name. Withoptions=, the SDK also sends its scrape defaults, and/v2/parseaccepts them.
doc = firecrawl.parse("./report.pdf")- Agent. The blocking
agent()returns on itstimeoutwith the last status it read, which can still beprocessing. Pollget_agent_status. A cancelled job readsfailedwitherror: "Agent was cancelled", and a second cancel once it has stopped raises with409.start_agentwith awebhookraises with400 NOT_IMPLEMENTED. - Extract.
start_extractraises with the501refusal. Use the agent.
The codes DarkCrawl answers with are on Errors.