Skip to main content

Megalania Python SDK

Beta. A small client for the Megalania scraping API. One call returns a page as HTML, Markdown or JSON, and batches, monitors, map and tier have a method each. You get the body, the response headers as typed fields, and a MegalaniaError with the error code and message.

  • It retries once on a 429, after Retry-After, and never on anything else.
  • Every scrape, map and create call sends an Idempotency-Key, so a repeat is never charged twice.
  • The types are generated from the Megalania OpenAPI document.

Install

Python 3.10 or newer.

pip install megalania

One page

import os

from megalania import Megalania, MegalaniaError

with Megalania(os.environ["MEG_API_KEY"]) as meg:
    try:
        page = meg.scrape("https://example.com/", response_types="markdown")
    except MegalaniaError as e:
        print(e.status, e.code, e.message, e.request_id)
        raise
    print(page.headers.credits_charged, page.text[:200])

The client calls https://get.megalania.io unless you pass base_url.

Batches, monitors, map and tier have their own methods, named after their REST operation: get_tier, map_site, create_batch, get_batch, list_batch_items, cancel_batch, create_monitor, list_monitors and more. They call https://api.megalania.io unless you pass api_url:

with Megalania(os.environ["MEG_API_KEY"]) as meg:
    batch = meg.create_batch(["https://docs.megalania.io/start/quickstart"], response_types="markdown")
    print(meg.get_batch(batch["id"]))

Docs

The full guide is at https://docs.megalania.io/guides/sdk-python.

License

MIT. See LICENSE. Security reports: see SECURITY.md.

Metadata

Release files for megalania 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for megalania 0.2.0
File Size Uploaded Provenance Actions
megalania-0.2.0.tar.gz 41.7 kB With provenance Details for megalania-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for megalania 0.2.0
File Interpreter ABI Platform Actions
megalania-0.2.0-py3-none-any.whl Python 3 none any Details for megalania-0.2.0-py3-none-any.whl

Total release size: 109.5 kB

Release files / megalania-0.2.0.tar.gz

Download URL megalania-0.2.0.tar.gz
Size 41.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a9c2ac899c681c306a8d1fc40aad83da0810bf50fe806c11b7ebe23616b40361
BLAKE2b-256 checksum
How to use checksums
40c22c09819781d738d7051cd56fa0a0d471cfd123d462daa3c09f9f46014f5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / megalania-0.2.0-py3-none-any.whl

Download URL megalania-0.2.0-py3-none-any.whl
Size 67.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff443a08ba3af7d82d8bd755511273a0719ef67a752191d07a01796daada49e5
BLAKE2b-256 checksum
How to use checksums
437dd8ad6b65927ad7fd81ee1df91c5d9e5e025c714f8d29f76c64d85f1bb60b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for megalania 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for megalania-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page