Skip to content

v0.0.13

Latest

Choose a tag to compare

@amhsirak amhsirak released this 01 Oct 12:07
· 3 commits to master since this release

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_data and so on.
  • Robots are plain dicts of {"id", "name", "type"}, so print() and json.dumps show 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. Pass timeout= (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) and abort(id). run.result gives the output of any run, including scheduled ones.
  • Errors are typed: AuthenticationError, NotFoundError, ConflictError, ValidationError and RunFailedError. All of them are subclasses of MaxunError.

Fixes

  • Webhooks now fire. 0.0.x saved event names (run.completed) that the server never sent. The SDK now uses run_completed and run_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 limit or max_depth crawled nothing. Crawls now default to 50 pages and depth 3.
  • Extract.get_robots() crashed with KeyError. 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 src layout, so its types module 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 out mode used to scrape every result; pass mode="scrape" for that.
  • robot.get_schedule() and robot.get_webhooks() are async and read fresh data from the server, so they also see changes made in the app. await them. get_schedule() returns None when there is no schedule, and get_webhooks() returns [] (not None) when there are no webhooks.
  • Option classes are deprecated. ScheduleConfig, WebhookConfig, ExecutionOptions, CrawlConfig, SearchConfig, ExtractListConfig and PaginationConfig still import, with a DeprecationWarning. Use keyword arguments instead.
  • Robots and runs are dicts of their summary. Raw fields such as run["serializableOutput"] can still be read, and get_data() returns the full record.
  • set_cookies() and mode() were never supported by the server. They now warn and do nothing.
  • Config reads MAXUN_API_KEY, MAXUN_BASE_URL and MAXUN_TEAM_ID when arguments are left out. The default URL is still Maxun Cloud.

Documentation