Package: jikanpy
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/v3/anime/1.headers: The response headers from Jikan, detailedhere.Installation$pipinstalljikanpyUsage 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.season(year=2018,season='winter')archive=jikan.season_archive()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/v3')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/v3',session=session)awaitsession.close()asyncio.run(main())Testing# In root of repository$pytestChangelog for Jikanpy[4.3.2] - 2021-04-15FixedDon't include the CHANGELOG.md as adata_file, just read it while building releases. Previously this could cause CHANGELOG.md to be installed into the users data dir (/usr/or~/.local/depending on how its installed). See#90[4.3.1] - 2021-02-27ChangedUpdated aiohttp to 3.7.4[4.3.0] - 2021-02-15AddedCalling season method with no arguments defaults to current season[4.2.2] - 2020-07-24FixedBug where downloading jikanpy from the distribution would fail because CHANGELOG.md wasn't included and setup.py uses it[4.2.1] - 2020-06-11FixedBug where simplejson wasn't being installed as a dependency[4.2.0] - 2020-06-10AddedRevamped how APIException works so it displays more information whether or not the HTTP response is JSONChangedSome refactoring to fix typing and linting errors from mypy, flake8, and pylintUpdated some unit tests and commented out ones that don't work because of Jikan 503 errorsFixedBug where jikanpy would crash when the JSON response can't be decoded with the simplejson JSON parserBug where jikanpy would crash when the JSON response is a list instead of a dict[4.1.0] - 2020-05-23FixedBug where selected_base wasn't being usedBug where trailing slash or whitespace in selected_base argument wouldn't work[4.0.0] - 2020-05-20AddedDocumentation athttps://jikanpy.readthedocs.ioAioJikan can be constructed using 'async with' techniqueOptional page argument to club methodChangedAbstractJikan rewritten as utility methodsDocstrings rewritten to follow Google style guideUpdated all requirements to current versionsRemovedRemoved checking arguments and throwing ClientException from invalid argumentsRemoved ClientException because it isn't being raised anymoreRemoved use_ssl argument so only HTTPS Jikan URL is availableRemoved loop argument for AioJikanUnnecessary type hints for variable instantiationsFixedLazy construct aiohttp session in AioJikan to stop DeprecationWarningIssue where page couldn't be added to user method URL when argument not passed in[3.4.2] - 2019-11-29AddedAdded extension forum/episodes for anime endpoint[3.4.1] - 2019-10-02AddedAdded MIT license to Jikanpy[3.4.0] - 2019-09-15AddedAdded Jikanpy to PyPI[3.3.0] - 2019-09-07AddedAbility to pass in own Requests session to Jikan in constructorFixedMade type hints for session and loop in constructors more accurate[3.2.0] - 2019-09-07AddedJikan URL and response headers to Jikanpy responseFixedError handling when type or period argument is None for meta methodBug in which letter argument for search method didn't allow the character .[3.1.2] - 2019-07-23AddedThis changelog[3.1.1] - 2019-07-22FixedBug when passing in genre_exclude as boolean[3.1.0] - 2019-05-18Addedselected_base constructor arg to aio_jikanChangedsearch and user methods to adhere with REST 3.3[3.0.2] - 2019-05-07FixedBug where search method didn't check genre parameter correctly[3.0.1] - 2019-04-28FixedBug where check_response didn't handle when there was no error in the response json[3.0.0] - 2019-03-30AddedType hints (only works in Python 3.6+)Optionsotherandunknownfor the parameterdayin schedule methodErrors thrown whenstatusrequest is called with arguments in meta methodpageparameter to manga endpointRemovedNo more support for Python versions before 3.6FixedBug where parameters weren't being added to search url correctlyArgument checks for user methodmeta not implemented test[2.4.1] - 2019-03-12AddedTests to reach 100% coverageChangedAbstract methods raiseNotImplementedError[2.4.0] - 2019-03-05AddedOption to provide base url to Jikanpy to use for endpointChangedREADME examples for user method[2.3.2] - 2019-01-19AddedCodecov integrationError if top method if subtype is provided without pageasync/await examples in examples.py[2.3.1] - 2019-01-05AddedTests and examples for person method[2.3.0] - 2019-01-04Addedclub and season later methods (for REST v3.2)reviews, recommendations, and user updates extensions (for REST v3.2)FixedBug where page wasn't added to url correctly for extensionepisodes[2.2.0] - 2018-12-05AddedTravis integrationSupport for multiple query parameters in search methodRemovedNo more support for Python versions before 3.5[2.1.3] - 2018-11-28FixedSubtypes checking for top endpoint[2.1.2] - 2018-11-20FixedBug when adding query parameter to url before converting it to a string in search method[2.1.1] - 2018-11-18FixedChecking key and value in search method[2.1.0] - 2018-10-18Addedanimelist and mangalist support in user endpoint (REST v3.1)search archive method (REST v3.1)[2.0.0] - 2018-09-05Addedgenre, producer, magazine, and user methods (REST v3)ChangedBase endpoint url toapi.jikan.moe/v3[1.0.1] - 2018-09-03FixedBug where page was added to url before converting it to a string[1.0.0] - 2018-06-17Addedsemver for versioningsetup.py2018-06-07AddedAioJikan async wrapper for Jikan2018-05-25Addedseason, schedule, top, and meta methods (REST v2.2)ChangedGeneralized error checking2018-05-18Addedpage support to anime, manga, character, and person methods (REST v2.2)query parameter to search method (REST v2.2)2018-04-12Addedsearch method (REST v2.1)examples.py for example usageChangedBase endpoint url toapi.jikan.moeExtensions for anime, manga, character, and person methods (REST v2.1)Limit warning in docstring to the new limit, 5000Link to Jikan docs in READMEDeprecateduser list method2017-10-20ChangedDeprecationWarning to DeprecatedEndpointFixedID typos in README usage2017-10-19Addedcharacter, person, and user list methodsTests for anime and manga methodsDeprecationWarning exceptionUsage info in README2017-10-18AddedInitial version with anime and manga methods and exceptions