Package: 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 requests with cache and apply coroutine delay if ratelimit was hit or it's expired.Contributing•Documentation•Report IssuesJikan4snekFeaturesInstallationPrerequisitesUsageGetSearchBulk-requestConstructorsRunning testsDebugJikan4snek.dumpDocumentationJikan4snekJikan.moe documentationAcknowledgmentsPronunciationLegalFeaturesJikan4snek combines in-disk cache and ratelimit hit to simulate the requests.Has own ratelimit flowCustomizable behaviourSimplified, nested method callCovers 80% of the v4 Jikan endpointsEasy to use, check your intelisenseInstallationpip install jikan4snekOr build from source:clone this repo and runpython setup.py installPrerequisitesNOTE:Python 3.7 or aboveUsageShould be run in async context, also follow the nested call aftergetorsearchmethod.importasynciofromjikan4snekimportJikan4SNEK,dumpasyncdefmain():jikan=Jikan4SNEK()anime=awaitjikan.get(18679).anime()print(anime)## this is <class 'dict'>print(dump(anime))## this is <class 'str'>asyncio.run(main())ConstructorsYou can apply your own instance ofJikan, user-agent, sqlite backend, cache expiration, and debug.The default:importasynciofromjikan4snekimportJikan4SNEKasyncdefmain():jikan=Jikan4SNEK(api="https://api.jikan.moe/v4",ua={"User-Agent":"jikan4snek/current_version","From":"hey@scathach.id",},sqlite_backend="jikan4snek_cache/jikan4snek",expire_cache=60,## 1 hourdebug=False## debug mode, default is False)some_anime=awaitjikan.search("naruto").anime()## do with some_animeasyncio.run(main())Getjikan.get()used from based on id.awaitjikan.get(18679,entry="characters").anime()awaitjikan.get(18679,entry="pictures").anime()See moreAnimejikan4snek.client.jikan.JikanResponseFromId.animeawaitjikan.get(18679,entry="characters").anime()awaitjikan.get(18679,entry="pictures").anime()Mangajikan4snek.client.jikan.JikanResponseFromId.mangaawaitjikan.get(58391).manga()awaitjikan.get(58391,entry="characters").manga()Charactersjikan4snek.client.jikan.JikanResponseFromId.charactersawaitjikan.get(83799).characters()awaitjikan.get(83799,entry="voices").characters()Clubsjikan4snek.client.jikan.JikanResponseFromId.clubsawaitjikan.get(1).clubs()awaitjikan.get(1,entry="members").clubs()Peoplejikan4snek.client.jikan.JikanResponseFromId.peopleawaitjikan.get(1).people()awaitjikan.get(1,entry="pictures").people()Producersjikan4snek.client.jikan.JikanResponseFromId.producersawaitjikan.get(1).producers()awaitjikan.get(1,entry="external").producers()Randomjikan4snek.client.jikan.JikanResponseFromId.randomawaitjikan.get(False,entry="anime").random()awaitjikan.get(False,entry="manga").random()Usersjikan4snek.client.jikan.JikanResponseFromId.usersawaitjikan.get("sinkaroid").users()awaitjikan.get("sinkaroid",entry="history").users()Searchjikan.search()used from based on query search.awaitjikan.search("naruto").anime()awaitjikan.search("naruto",limit=10,page=2).anime()See moreAnimejikan4snek.client.jikan.JikanResponseFromSearch.animeawaitjikan.search("naruto").anime()awaitjikan.search("naruto",limit=10,page=2).anime()Mangajikan4snek.client.jikan.JikanResponseFromSearch.mangaawaitjikan.search("naruto").manga()awaitjikan.search("naruto",limit=10,page=2).manga()Charactersjikan4snek.client.jikan.JikanResponseFromSearch.charactersawaitjikan.search("uchiha").characters()awaitjikan.search("uchiha",limit=10,page=1).characters()Clubsjikan4snek.client.jikan.JikanResponseFromSearch.clubsawaitjikan.search("naruto").clubs()awaitjikan.search("naruto",limit=10,page=1).clubs()Peoplejikan4snek.client.jikan.JikanResponseFromSearch.peopleawaitjikan.search("tanaka rie").people()awaitjikan.search("tanaka",limit=10,page=1).people()Producersjikan4snek.client.jikan.JikanResponseFromSearch.producersawaitjikan.search("madhouse").producers()awaitjikan.search("japan",limit=10,page=1).producers()Magazinesjikan4snek.client.jikan.JikanResponseFromSearch.magazinesawaitjikan.search("jump").magazines()awaitjikan.search("jump",limit=10,page=1).magazines()Usersjikan4snek.client.jikan.JikanResponseFromSearch.usersawaitjikan.search("sinkaroid").users()awaitjikan.search("sin",limit=10,page=1).users()Bulk requestIf you usingasyncio.gather(*[jikan.get("..").anime()])sadly, It will broke the base api hit, Just do it like usual, enable debug, and snek will handle the ratelimit for you. For example:importasyncioimportjikan4sneksome_bunch_of_anime=[44511,50602,50172,49918,49596,41467,48316,49709,42962,47917,49891,50425,50710,49784,51098,49979,52046,52193,51128,48542,49828,51403,50205,50528,50590,51212,30455,50923,50348,51680]asyncdefmain():Jikan=jikan4snek.Jikan4SNEK(debug=True)foriinsome_bunch_of_anime:res=awaitJikan.get(i).anime()print("Anime:",res['data']['title'])asyncio.run(main())Running testsCheck workflows and the whole/testfolder.DebugEnable debug. Default is False. Use this if jikan4snek request is not working as expected.jikan=Jikan4SNEK(debug=True)2022-12-20 21:02:06,435 | INFO | request:fetch | Not hitting API, cache is available
2022-12-20 21:02:06,435 | INFO | request:fetch | is_cache:True | status_code:200 | url:https://api.jikan.moe/v4/anime/44511 | took:0.02 seconds
2022-12-20 21:02:06,435 | INFO | main:memek | Anime: Chainsaw Man
2022-12-20 21:02:06,435 | INFO | request:fetch | Not hitting API, cache is available
2022-12-20 21:02:06,435 | INFO | request:fetch | is_cache:True | status_code:200 | url:https://api.jikan.moe/v4/anime/50602 | took:0.0 seconds
2022-12-20 21:02:06,435 | INFO | main:memek | Anime: Spy x Family Part 2
2022-12-20 21:02:06,435 | INFO | request:fetch | Not hitting API, cache is available
2022-12-20 21:02:06,435 | INFO | request:fetch | is_cache:True | status_code:200 | url:https://api.jikan.moe/v4/anime/50172 | took:0.0 seconds
2022-12-20 21:02:06,435 | INFO | main:memek | Anime: Mob Psycho 100 III
2022-12-20 21:02:07,997 | INFO | request:fetch | First conditions of request, API hit 1
2022-12-20 21:02:07,997 | INFO | request:fetch | is_cache:False | status_code:200 | url:https://api.jikan.moe/v4/anime/49918 | took:1.56 seconds
2022-12-20 21:02:07,997 | INFO | main:memek | Anime: Boku no Hero Academia 6th Season
2022-12-20 21:02:09,560 | INFO | request:fetch | Second conditions of request, API hit 2
2022-12-20 21:02:09,576 | INFO | request:fetch | is_cache:False | status_code:200 | url:https://api.jikan.moe/v4/anime/49596 | took:0.016 seconds
2022-12-20 21:02:09,576 | INFO | main:memek | Anime: Blue Lock
2022-12-20 21:02:11,122 | INFO | request:fetch | Third conditions of request, apply sleep for 1 seconds..
2022-12-20 21:02:12,123 | INFO | request:fetch | Third should back to first condtions, API hit 1
2022-12-20 21:02:12,154 | INFO | request:fetch | is_cache:False | status_code:200 | url:https://api.jikan.moe/v4/anime/41467 | took:0.031 seconds
2022-12-20 21:02:12,154 | INFO | main:memek | Anime: Bleach: Sennen Kessen-hen
2022-12-20 21:02:13,716 | INFO | request:fetch | Second conditions of request, API hit 2
2022-12-20 21:02:13,732 | INFO | request:fetch | is_cache:False | status_code:200 | url:https://api.jikan.moe/v4/anime/48316 | took:0.016 seconds
2022-12-20 21:02:13,732 | INFO | main:memek | Anime: Kage no Jitsuryokusha ni Naritakute!
2022-12-20 21:02:15,247 | INFO | request:fetch | Third conditions of request, apply sleep for 1 seconds..
2022-12-20 21:02:16,247 | INFO | request:fetch | Third should back to first condtions, API hit 1Jikan4snek.dumpShort hand ofjson.dump()If you are phobia with arbitrary bad indentation of json. UseJikan4snek.dump()to dump them, It's definitely str, not dictionaries, just in case for reading object to save your time.Documentationhttps://scathachgrip.github.io/jikan4snekAcknowledgementsI hope you have found this project useful. All the major credit really goes to theJikanandMyAnimeListitself.PronunciationJikan is jikan.moe. then Snek is snek you know exactly what it's mean.LegalThis 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.