Skip to main content

Python wrapper for Metron API

Project description

Mokkari

PyPI - Version PyPI - Python Ruff Pre-Commit

A python wrapper for the Metron Comic Book Database API.

Installation

pip install mokkari

Example Usage

import mokkari

# Your own config file to keep your credentials secret
from config import username, password

m = mokkari.api(username, password)

# Get all Marvel comics for the week of 2021-06-07
this_week = m.issues_list({"store_date_range_after": "2021-06-07", "store_date_range_before": "2021-06-13", "publisher_name": "marvel"})

# Print the results
for i in this_week:
    print(f"{i.id} {i.issue_name}")

# Retrieve the detail for an individual issue
    asm_68 = m.issue(31660)

# Print the issue Description
print(asm_68.desc)

Rate Limiting

The API has rate limits of 20 requests per minute and 5,000 requests per day. Mokkari automatically enforces these limits locally to prevent unnecessary API calls. When a rate limit is exceeded, a RateLimitError is raised.

Handling Rate Limits

The RateLimitError includes a retry_after attribute that tells you exactly how many seconds to wait before making another request:

import mokkari
from mokkari.exceptions import RateLimitError
import time

m = mokkari.api(username, password)

try:
    issue = m.issue(31660)
except RateLimitError as e:
    # Display user-friendly message
    print(f"Rate limited: {e}")

    # Programmatically wait for the exact time needed
    print(f"Waiting {e.retry_after} seconds...")
    time.sleep(e.retry_after)

    # Retry the request
    issue = m.issue(31660)

Documentation

Read the project documentation

Bugs/Requests

Please use the GitHub issue tracker to submit bugs or request features.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mokkari-3.25.0.tar.gz (355.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mokkari-3.25.0-py3-none-any.whl (51.5 kB view details)

Uploaded Python 3

File details

Details for the file mokkari-3.25.0.tar.gz.

File metadata

  • Download URL: mokkari-3.25.0.tar.gz
  • Upload date:
  • Size: 355.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mokkari-3.25.0.tar.gz
Algorithm Hash digest
SHA256 d6d4d5e2e4e8ff1684e4b46bfbe8953d3008c1df439817e59d3c1fca05acb3ce
MD5 6791c9cb158dbc5f85e2e8bcefb8e109
BLAKE2b-256 7b42f9bc10df056ca9cccdbe1b6ed2e63f87395828cdacd4ad5dd247965ff79b

See more details on using hashes here.

File details

Details for the file mokkari-3.25.0-py3-none-any.whl.

File metadata

  • Download URL: mokkari-3.25.0-py3-none-any.whl
  • Upload date:
  • Size: 51.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mokkari-3.25.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee3cac2029142d22b93da29ce1e76b0d8818494c5b0dc3cc9c3b00cd43fe9247
MD5 dd5e3070b2ea587acb560f46410890fc
BLAKE2b-256 5976526e188b2bbaa714fa00c2e3e8eaf09b192b218dfe7ad821a171a0e0c5fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page