Package: jikanpy-v4
JikanPyJikanPy is a Python wrapper forJikan,
providing bindings for all API functionality, and supports Python 3.6+. Because
it is intended to be pretty much identical, please consultJikan's
documentationfor thornier details on how it is
meant to be used. Perhaps most importantly, JikanPy does not make any attempts
to rate limit itself, so use it as responsibly as you would use the API
primitively and remember that Jikan API has limitations, check outthis sectionof documentation in order to see to what extent the API is limited or throttled.You can use either Jikan or AioJikan depending on whether you want a synchronous
wrapper class or an asynchronous wrapper class respectively. More usage examples
are below.In addition to the typical response from the Jikan API, each response contains
two additional fields:jikan_url: The URL that was requested; for example:https://api.jikan.moe/v4/anime/1.headers: The response headers from Jikan, detailedhere.InstallationYou can install the package from PyPI using pip:$pipinstalljikanpy-v4If you have previously installed the old version of jikanpy, then make sure to uninstall the old version first:$pipuninstalljikanpy
$pipinstall--no-cache-dirjikanpy-v4You can also install this package directly from the source:$gitclonehttps://github.com/abhinavk99/jikanpy.git$cdjikanpy
$pythonsetup.pyinstallNote: This package is different fromjikanpyon PyPI, which is the old Jikan v3 compatible version ofjikanpy.Usage ExamplesBelow are some basic examples of how to use Jikan and AioJikan. Please read thedocumentation belowto see all the methods and more examples.Usage Examples with JikanfromjikanpyimportJikanjikan=Jikan()mushishi=jikan.anime(457)mushishi_with_eps=jikan.anime(457,extension='episodes')search_result=jikan.search('anime','Mushishi',page=2)winter_2018_anime=jikan.seasons(year=2018,season='winter')current_season=jikan.seasons(extension='now')Async Usage Examples with AioJikanimportasynciofromjikanpyimportAioJikanasyncdefmain():asyncwithAioJikan()asaio_jikan:mushishi=awaitaio_jikan.anime(457)fma=awaitaio_jikan.manga(25)ginko=awaitaio_jikan.character(425)kana_hanazawa=awaitaio_jikan.person(185)naruto=awaitaio_jikan.search(search_type='anime',query='naruto')# You can also construct AioJikan like below, but make sure to close the objectaio_jikan_2=AioJikan()mushishi=awaitaio_jikan.anime(457)awaitaio_jikan_2.close()asyncio.run(main())DocumentationCheck out the documentationhere.Overriding default settings in Jikan and AioJikan with constructor argumentsIf you're running an instance ofjikan-reston your system, and want to use that instead ofapi.jikan.moe,
you can pass that to Jikan:fromjikanpyimportJikanjikan=Jikan(selected_base='http://localhost:8000/v4')If you want to use your own Requests session, you can do that too.importrequestsfromjikanpyimportJikansession=requests.Session()# Set custom persistent headers that will be used with all HTTP requests with your sessionsession.headers.update({'x-test':'true'})jikan=Jikan(session=session)You can use any or all of these constructor arguments when creating an instance
of Jikan.AioJikan also hasselected_baseandsession(although AioJikan uses AioHTTP
session, not Requests).importaiohttpimportasynciofromjikanpyimportAioJikanasyncdefmain():# Construct AioJikan with own base URL and custom AioHTTP session with custom persistent headerssession=aiohttp.ClientSession(headers={'x-test':'true'})aio_jikan=AioJikan(selected_base='http://localhost:8000/v4',session=session)awaitsession.close()asyncio.run(main())Testing# In root of repository$pytest-mpytesttests/# Optionally, you can run a single test:$pytest-mpytesttests/test_jikan.py::test_anime_episodes_successChangelog for Jikanpy_v4[1.0.0] - 2022-12-28AddedInitial support for v4 of the Jikan APIChangedPackage name changed fromjikanpytojikanpy_v4RemovedRemoved suppport for Jikan API <= v3. Seeherefor old package.