Skip to main content

Python client for Jikan.moe

Project description

jikan4snek

Python client for Jikan.moe, simplified with amplified in mind.

The motivation is simplified the api call, customizable behaviour, and user should have no worries with ratelimit.
Jikan4snek simulating the requests with saved cache and apply coroutine delay if cache was expired.

ContributingDocumentationReport Issues


Features

Jikan4snek combines in-disk cache and ratelimit hit to simulate the requests.

  • Has own ratelimit flow
  • Customizable behaviour
  • Simplified, nested method call
  • Covers 80% of the v4 Jikan endpoints
  • Easy to use, check your intelisense

Installation

pip install jikan4snek

Or build from source:

clone this repo and run python setup.py install

Prerequisites

NOTE: Python 3.7 or above

Usage

Should be run in async context, also follow the nested call after get or search method.

import asyncio
from jikan4snek import Jikan4SNEK, dump

async def main():
    jikan = Jikan4SNEK()
    anime = await jikan.get(18679).anime()
    print(anime) ## this is <class 'dict'>
    print(dump(anime)) ## this is <class 'str'>

asyncio.run(main())

Constructors

You can apply your own instance of Jikan, user-agent, sqlite backend, and cache expiration time on the constructor.

The default:

import asyncio
from jikan4snek import Jikan4SNEK

async def main():
    jikan = Jikan4SNEK(
        api="https://api.jikan.moe/v4",
        ua={
            "User-Agent": f"jikan4snek/{__version__}",
            "From": "hey@scathach.id",
        },
        sqlite_backend="jikan4snek_cache/jikan4snek",
        expire_cache=60, ## 1 hour
    )
    anime = await jikan.search("naruto").anime()
    print(anime)

asyncio.run(main())

Get

jikan.get() used from based on id.

await jikan.get(18679, entry="characters").anime()
await jikan.get(18679, entry="pictures").anime()
See more

Anime

jikan4snek.client.jikan.JikanResponseFromId.anime

await jikan.get(18679, entry="characters").anime()
await jikan.get(18679, entry="pictures").anime()

Manga

jikan4snek.client.jikan.JikanResponseFromId.manga

await jikan.get(58391).manga()
await jikan.get(58391, entry="characters").manga()

Characters

jikan4snek.client.jikan.JikanResponseFromId.characters

await jikan.get(83799).characters()
await jikan.get(83799, entry="voices").characters()

Clubs

jikan4snek.client.jikan.JikanResponseFromId.clubs

await jikan.get(1).clubs()
await jikan.get(1, entry="members").clubs()

People

jikan4snek.client.jikan.JikanResponseFromId.people

await jikan.get(1).people()
await jikan.get(1, entry="pictures").people()

Producers

jikan4snek.client.jikan.JikanResponseFromId.producers

await jikan.get(1).producers()
await jikan.get(1, entry="external").producers()

Random

jikan4snek.client.jikan.JikanResponseFromId.random

await jikan.get(False, entry="anime").random()
await jikan.get(False, entry="manga").random()

Users

jikan4snek.client.jikan.JikanResponseFromId.users

await jikan.get("sinkaroid").users()
await jikan.get("sinkaroid", entry="history").users()

Search

jikan.search() used from based on query search.

await jikan.search("naruto").anime()
await jikan.search("naruto", limit=10, page=2).anime()
See more

Anime

jikan4snek.client.jikan.JikanResponseFromSearch.anime

await jikan.search("naruto").anime()
await jikan.search("naruto", limit=10, page=2).anime()

Manga

jikan4snek.client.jikan.JikanResponseFromSearch.manga

await jikan.search("naruto").manga()
await jikan.search("naruto", limit=10, page=2).manga()

Characters

jikan4snek.client.jikan.JikanResponseFromSearch.characters

await jikan.search("uchiha").characters()
await jikan.search("uchiha", limit=10, page=1).characters()

Clubs

jikan4snek.client.jikan.JikanResponseFromSearch.clubs

await jikan.search("naruto").clubs()
await jikan.search("naruto", limit=10, page=1).clubs()

People

jikan4snek.client.jikan.JikanResponseFromSearch.people

await jikan.search("tanaka rie").people()
await jikan.search("tanaka", limit=10, page=1).people()

Producers

jikan4snek.client.jikan.JikanResponseFromSearch.producers

await jikan.search("madhouse").producers()
await jikan.search("japan", limit=10, page=1).producers()

Magazines

jikan4snek.client.jikan.JikanResponseFromSearch.magazines

await jikan.search("jump").magazines()
await jikan.search("jump", limit=10, page=1).magazines()

Users

jikan4snek.client.jikan.JikanResponseFromSearch.users

await jikan.search("sinkaroid").users()
await jikan.search("sin", limit=10, page=1).users()

Running tests

Check workflows and the whole /test folder.

Jikan4snek.dump

Short hand of json.dump() If you are phobia with arbitrary bad indentation of json, use Jikan4snek.dump() to dump them, It's definitely str, not dictionaries, just in case for reading object to save your time.

Documentation

https://scathachgrip.github.io/jikan4snek

Acknowledgements

I hope you have found this project useful. All the major credit really goes to the Jikan and MyAnimeList itself.

Pronunciation

Jikan is jikan.moe. then Snek is snek you know exactly what it's mean.

Legal

This tool can be freely copied, modified, altered, distributed without any attribution whatsoever. However, if you feel like this tool deserves an attribution, mention it. It won't hurt anybody.

Licence: WTF.

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

jikan4snek-1.0.2.tar.gz (12.8 kB view details)

Uploaded Source

File details

Details for the file jikan4snek-1.0.2.tar.gz.

File metadata

  • Download URL: jikan4snek-1.0.2.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for jikan4snek-1.0.2.tar.gz
Algorithm Hash digest
SHA256 998136854387c72e0b8b39e775bf5481a353595d2ea6f699df2d66c2a7261172
MD5 24e003fd1d98144e946a484c8328bb50
BLAKE2b-256 c9d67a7a3585477b0c408793997589a4bdf3becf60cff6cf96160af55d05dab6

See more details on using hashes here.

Supported by

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