jikanpy
jikanpy copied to clipboard
Create wrapper for Jikan API v4 beta
2 new classes would be created, Jikan4 and AioJikan4 that could be imported like from jikanpy import Jikan4
Endpoint: https://api.jikan.moe/v4 Docs: https://docs.api.jikan.moe/
Once Jikan API v3 gets deprecated, Jikan4 will become the main class and Jikan will become Jikan3 as seen below.
Jikan => Jikan3
AioJikan => AioJikan3
Jikan4 => Jikan
AioJikan4 => AioJikan
Sounds good
Not sure if there are OpenAPI consumers in python/if you wanted to use that - v4 would provide a schema file which could be converted into structs/request interfaces. Not sure how that affects documentation etc.
I can look into that/can discuss on discord if that's a possibility
In Nekomata's message he said not to use the tools yet since v4 is in beta, but we could look into it. It looks like the generator at https://github.com/OpenAPITools/openapi-generator can be combined with ReDoc or documentation generators.
Yo. I guess it's time to revisit this based on this document that's now part of Jikan's responses.
Quote from linked doc:
Timeline 1️⃣ 1st March 2022 - Deprecation The v3 API will enter into a deprecation state from 1st March 2022. 👉 You will be receiving a warning through headers and in the JSON body as mentioned above.
2️⃣ 1st May 2022 - Maintenance Ends The v3 API will no longer receive any maintenance from 1st May 2022. 👉 This includes parser fixes.
3️⃣ 1st September 2022 - Brownout The v3 API will enter into a brownout state from 1st September 2022. 👉 v3 Endpoints will return HTTP 410 GONE for the first 15 minutes of every other hour to alert anyone still using v3.
4️⃣ 1st October 2022 - Sunsetting The v3 API will be discontinued from 1st October 2022. 👉 v3 Endpoints will no longer be available on the public Jikan REST API.
To be perfectly honest, I'm not sure when I'll be able to get to this as I've gotten a job and am now more busy. It'd be great if you or someone else could take this up and I can review the changes. I think we probably just need to use the OpenAPI wrapper generator and update the docs.
I'm sorry, I have neither the time nor enough interest to maintain this library. 😓
I am interested in v4 support so I might produce some results. No idea how much v4 interface is different from v3 though. Did either of you did some research in this area?
Its pretty different -- you may be able to leverage the openapi file which describes the schema though:
Seems like this covers all the endpoints, not sure if attrs
and httpx
is configurable, but its at least a starting point and something to reference. it could be great, idk:
pip install pipx
pipx install openapi-python-client --include-deps
pipx run openapi-python-client generate --url 'https://raw.githubusercontent.com/jikan-me/jikan-rest/master/storage/api-docs/api-docs.json'
generates generates a bunch of models and an API structure you could reference:
may have to configure it to get it to be something usable, see https://github.com/openapi-generators/openapi-python-client
I wouldnt be against using the openapi client, it means that we'd automatically update the models whenever the API spec changed
Not sure how this would work with the codebase already here -- it may make more sense to create a separate repo for v4 since its using the generated code
would probably move setup.py/v3 to a separate subdir, the generated code uses poetry so that would be in a ./v4
subdirectory
could create a buildscript to create the wheels so they could be pushed to pypi separately -- maybe will make a major version bump when v3 is finally sunsetted
Been working on a basic restructure, see #99
look forward to this
To just copy paste what was said in #wrapper-devs
, regarding #99
There's incompatibility in types with the schema and the generator is super strict so it doesn't really work.
Edit: actually, part of it did get fixed here, but all the other requests still need to be checked
If the schema did match perfectly would probably have been easier but I dont think either of us are as free to create an entire wrapper from scratch right now
If anyone else would like to work on this, feel free to comment/go ahead
I try to maintain the OpenAPI Schema of Jikan. I use it in a project to generate a python client and experienced the same problem with the generated code. I do not know at the moment how could we validate the schema automatically in Jikan but if you have any proposal, feel free to reach out.
Looks like it has been discontinued now.
jikanpy.exceptions.APIException: HTTP 503 - status=503, type=BadResponseException, message=v3 has been discontinued. For more information visit https://bit.ly/jikan-v3-deprecation, upgrade=Please upgrade to v4: https://docs.api.jikan.moe/ for id=48675, endpoint=anime
Fixed in #101