Repository navigation
Releases
v0.0.13
maxun v0.0.13 (Python SDK)
This release rebuilds the Python SDK around a single entry point, with simpler calls and cleaner output, and fixes several features that did not work in 0.0.12.
pip install --upgrade maxun
⚠️ Please upgrade to the latest version 0.0.13 for the best experience.
Highlights
One entry point: Maxun()
Every feature hangs off one object. Each call takes the robot name first, then a URL, query or file, then keyword arguments.
import asyncio from maxun import Maxun
async def main():
async with Maxun(api_key="your-api-key") as maxun:
robot = await maxun.scrape("Maxun home", "https://maxun.dev", formats=["markdown", "html"])
result = await robot.run()
print(result.markdown)
asyncio.run(main())
| Call | Creates |
|---|---|
| maxun.scrape(name, url, ...) | A robot that turns a page into Markdown, HTML, text, links, a summary or screenshots |
| maxun.extract(name, url, prompt=...) | A robot that extracts data described in plain English |
| maxun.extract(name, url) | A selector robot builder: chain capture_text, capture_list, click... then .build() |
| maxun.crawl(name, url, ...) | A robot that crawls a website |
| maxun.search(name, query, ...) | A robot that searches the web |
| maxun.documents.extract(name, file, prompt) / .parse(name, file) | A robot that reads PDF, DOCX, XLSX, CSV, JPG and PNG files |
| maxun.robots | Lists, finds and deletes robots of any type |
Each resource can also list its robots: maxun.scrape.list(), maxun.crawl.list(), maxun.robots.list(type="search"), maxun.robots.find("Pricing page").
No async needed: MaxunSync
MaxunSync has the same API without await, so it works in plain scripts and in Jupyter:
from maxun import MaxunSync
with MaxunSync() as maxun:
robot = maxun.scrape("Example", "https://example.com")
print(robot.run().markdown)
Keyword arguments, no config classes
Options are plain keyword arguments with defaults that work out of the box:
await maxun.crawl("Docs", "https://docs.example.com", limit=100, include_paths=["/guides/*"])
await robot.schedule(run_every=6, run_every_unit="HOURS", timezone="Asia/Kolkata")
await robot.add_webhook("https://your-app.com/hook", events=["run_failed"], retry_attempts=5)
Clean results
robot.run()returns only the run id, the status and the outputs the run produced:{'runId': 'b05cea93-…', 'status': 'success', 'markdown': '# Example Domain…'}- Each output is an attribute:
result.markdown,result.list_data,result.crawl_data,result.search_data,result.document_dataand so on. - Robots are plain dicts of
{"id", "name", "type"}, soprint()andjson.dumpsshow just that. - Runs are plain dicts of
{"id", "runId", "robotId", "name", "status", "startedAt", "finishedAt"}, with ISO UTC times. - The API key never appears when a robot, run or config is printed.
Change monitoring for scrape, crawl and extract
Pass monitor=True and every run is compared with the previous successful run:
robot = await maxun.scrape("Pricing watch", "https://example.com/pricing", monitor=True)
result = await robot.run()
if result.has_changes:
diff = await robot.get_run_diff(result.run_id)
hasChanges and changedFormats appear only on robots with monitoring on. Crawl robots also report which pages were added, removed or changed. You can turn monitoring on for an existing robot with await robot.set_monitoring(True).
Better run handling
run()waits for the run to finish, however long it takes, instead of giving up after 5 minutes. Passtimeout=(seconds) to stop waiting sooner.run(formats=..., smart_queries=...)changes the formats or asks a question for a single run.- Run history is available with
get_runs(),get_latest_run(),get_run(id)andabort(id).run.resultgives the output of any run, including scheduled ones. - Errors are typed:
AuthenticationError,NotFoundError,ConflictError,ValidationErrorandRunFailedError. All of them are subclasses ofMaxunError.
Fixes
- Webhooks now fire. 0.0.x saved event names (
run.completed) that the server never sent. The SDK now usesrun_completedandrun_failed, and translates the old names with a warning. Webhooks saved with the old names need to be added again. - Documents: DOCX, JPG and PNG uploads used to be sent as PDFs and failed. They now work.
- Crawl: leaving out
limitormax_depthcrawled nothing. Crawls now default to 50 pages and depth 3. Extract.get_robots()crashed withKeyError. It now works.scroll()did nothing. It now scrolls by a number of screen heights, e.g.scroll(pages=2).- Imports: the package now uses a
srclayout, so itstypesmodule can no longer shadow Python's standard library.from maxun import *exports only the public API.
Breaking changes and behaviour changes
Most 0.0.x code keeps working: Scrape(Config(...)), Extract(Config(...)), awaiting a builder and result["data"][...] are all still supported. Check these:
- Search defaults to
mode="discover", which returns titles, URLs and snippets. Leaving outmodeused to scrape every result; passmode="scrape"for that. robot.get_schedule()androbot.get_webhooks()areasyncand read fresh data from the server, so they also see changes made in the app.awaitthem.get_schedule()returnsNonewhen there is no schedule, andget_webhooks()returns[](notNone) when there are no webhooks.- Option classes are deprecated.
ScheduleConfig,WebhookConfig,ExecutionOptions,CrawlConfig,SearchConfig,ExtractListConfigandPaginationConfigstill import, with aDeprecationWarning. Use keyword arguments instead. - Robots and runs are dicts of their summary. Raw fields such as
run["serializableOutput"]can still be read, andget_data()returns the full record. set_cookies()andmode()were never supported by the server. They now warn and do nothing.ConfigreadsMAXUN_API_KEY,MAXUN_BASE_URLandMAXUN_TEAM_IDwhen arguments are left out. The default URL is still Maxun Cloud.