ervie / jikan.net Goto Github PK
View Code? Open in Web Editor NEWA dotnet wrapper for Jikan REST API.
License: MIT License
A dotnet wrapper for Jikan REST API.
License: MIT License
Hi Ervie, I think I found some sort of bug from GetScheduleAsync method, this was what I found.
{System.InvalidOperationException: The JSON property name for 'JikanDotNet.DbPaginatedJikanResponse`1[System.Collections.Generic.ICollection`1[JikanDotNet.Anime]].Pagination' collides with another property.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_SerializerPropertyNameConflict (System.Text.Json.JsonClassInfo jsonClassInfo, System.Text.Json.JsonPropertyInfo jsonPropertyInfo) [0x0001b] in <815ff95f4d6a463fa6a3be490e0514aa>:0
at System.Text.Json.JsonClassInfo..ctor (System.Type type, System.Text.Json.JsonSerializerOptions options) [0x00133] in <815ff95f4d6a463fa6a3be490e0514aa>:0
at System.Text.Json.JsonSerializerOptions.GetOrAddClass (System.Type classType) [0x00017] in <815ff95f4d6a463fa6a3be490e0514aa>:0
at System.Text.Json.ReadStackFrame.Initialize (System.Type type, System.Text.Json.JsonSerializerOptions options) [0x00000] in <815ff95f4d6a463fa6a3be490e0514aa>:0
at System.Text.Json.JsonSerializer.ReadCore (System.Type returnType, System.Text.Json.JsonSerializerOptions options, System.Text.Json.Utf8JsonReader& reader) [0x00008] in <815ff95f4d6a463fa6a3be490e0514aa>:0
at System.Text.Json.JsonSerializer.Deserialize (System.String json, System.Type returnType, System.Text.Json.JsonSerializerOptions options) [0x0009d] in <815ff95f4d6a463fa6a3be490e0514aa>:0
at System.Text.Json.JsonSerializer.Deserialize[TValue] (System.String json, System.Text.Json.JsonSerializerOptions options) [0x00000] in <815ff95f4d6a463fa6a3be490e0514aa>:0
at JikanDotNet.Jikan.ExecuteGetRequestAsync[T] (System.Collections.Generic.ICollection`1[T] routeSections) [0x0012a] in <210aaa08ca6e48cc9535ceee605c1cbc>:0
_jikan.SearchAnime("one piece", 0) results in the following exception message:
"GET request failed. Status code: BadRequest Inner message: System.Net.Http.StreamContent"
Hi Ervie, I noticed there's no news endpoint at "https://myanimelist.net/news", only news for specific animes is currently covered at "https://myanimelist.net/anime/{id}/news)". Will this be covered in the future?
For the past couple of days, I've been getting this issue where it'll give me an error 400: BadRequest I have not tried the other methods besides GetAnime. I'm not sure if this is just something on my end. or something is up with the API at the moment.
.NET6, JikanDotNet v2.1.0
using JikanDotNet;
var jikan = new Jikan();
try
{
_ = await jikan.GetUserMangaListAsync("N0D4N");
//_ = await jikan.GetUserAnimeListAsync("N0D4N");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
JikanDotNet.Exceptions.JikanRequestException: Serialization failed.
Inner exception message: The JSON value could not be converted to System.String. Path: $.data[0].reading_status | LineNumber: 0 | BytePositionInLine: 28.
---> System.Text.Json.JsonException: The JSON value could not be converted to System.String. Path: $.data[0].reading_status | LineNumber: 0 | BytePositionInLine: 28.
---> System.InvalidOperationException: Cannot get the value of a token type 'Number' as a string.
at System.Text.Json.Utf8JsonReader.GetString()
at System.Text.Json.Serialization.Converters.StringConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at JikanDotNet.Jikan.ExecuteGetRequestAsync[T](ICollection`1 routeSections)
--- End of inner exception stack trace ---
at JikanDotNet.Jikan.ExecuteGetRequestAsync[T](ICollection`1 routeSections)
at JikanDotNet.Jikan.GetUserMangaListAsync(String username)
at Program.<Main>$(String[] args)
https://api.jikan.moe/v4/users/N0D4N/mangalist
{
"data": [
{
"reading_status": 1,
"score": 0,
// everything else
Seems like System.Text.Json doesn't convert json number value to string automatically, which is ReadingStatus
/WatchingStatus
of MangaListEntry
/AnimeListEntry
. Unfortunately JsonSerializerOptions
doesn't have option to allow getting string from json's number, one way to fix it would be to write custom JsonConverter
that will allow it, another is to change properties type from string to int
/enum
It is currently not possible to inject my own HttpClient
using IoC.
Also then instead of the Endpoint
property in the client config, using the HttpClientFactory pattern one could do this as well:
services.AddHttpClient<IJikan, Jikan>(client => {
client.Timeout = TimeSpan.FromSeconds(10);
client.BaseAddress = new Uri(/* your endpoint */)
});
See this page for even more benefits: https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
Hi Ervie, is there any place I can see the change notes for version 1.6.0?
My app broke cuz someone decided to move the API version up.. how do i get current season? it sued to be just GetSeason, your documentation shows that it still works but in 2.4.0 it does not accept it without params
Looks like there are upcoming changes to the ReviewDto:
jikan-me/jikan-rest#422
Is there a way to for you to add an Interface for the Anime item and Manga item so I can treat them as the same item to help with accessing internal propertys.
So instead of doing something like this;
public long ID { get { if (AnimeItem!= null) return AnimeItem.MalId; else return MangaItem.MalId; } }
I can reference the ID though a interface (or a series of interfaces) , like this
public interface MalItemInteracter
{
long MalId { get; }
string Title { get; }
string Studios { get; }
string Type { get; }
string Author { get; }
string Genres { get; }
float? Score { get; }
}
MalItemInteracter MII = (AnimeItem or MangaItem) as MalItemInteracter();
public long ID { get { MalItemInteracter.MalId; } }
With the current APIv4 you have the JSON elements for the titles separately available.
Those are marked as Deprecated according to the documentation here
The new way combines all of the titles under a single element titles
, example:
"titles": [
{
"type": "Default",
"title": "One Piece"
},
{
"type": "Synonym",
"title": "OP"
},
{
"type": "Japanese",
"title": "ONE PIECE"
},
{
"type": "English",
"title": "One Piece"
}
],
It started behaving like this since yesterday.
I'm sure the provided ID is valid (as being an anime) and there's also characters & staff listed at the MAL page. This same ID used to work a few days ago.
Tried with 2 different machines.
I was trying to list Animes using the fourth overload for SearchAnime, it loads fine for the first page, but it does not seems working after this. Maybe MAL changed the endpoint?
Steps to reproduce:
how can i obtain chapters names of a specific manga?
"GetMangaChapters" isn't there, while "GetAnimeEpisodes" exists
Hi Ervie, I was trying to implement AnimeSearchConfig filters and noticed the end point of excluded genres is not behaving as expected. I've Tried to fill 5 genres for exclusion(and marked the boolean property "GenreIncluded" as false), the returning collection was empty. I've checked as well MAL website, there it works removing the searched animes which has any genres specified for exclusion.
Steps to reproduce:
Expected:
Actual behavior:
The JSON deserializer can silently fail and return a response wih null data because the model fields are not required. This is especially problematic until the mantainers fix jikan-me/jikan-rest#351. Marking them with required
is enough to trigger a JsonException according to .NET Docs.
You can try getting data from {endpoint}/anime/2
. It will sometimes return the same error message but with a 200 status code
The problem is that this feature is only available on C# 11 / .NET 7 so this project must either drop support for .NET 6 and lower and start targeting .NET 7 or add the feature manually.
I tested PolySharp and it seems to work but if you don´t want to add it as dependency, adding this and this to the project should be fine.
After making Data
required:
Serialization failed.
Inner exception message: JSON deserialization for type 'JikanDotNet.BaseJikanResponse`1[JikanDotNet.Anime]' was missing required properties, including the following: data
Currently jikan.net doesn't make any checks on any enums passed as parameters to methods of Jikan
class, so its possible to pass int casted to enum to method which will result in making HTTP request and failing on parsing response from Jikan server.
Add method IsValidEnum
or IsDefinedEnum
to Guard
class which will check if passed parameter is defined enum. Add checks for validity of enums passed in methods.
Execution time of method with added checks will increase, and i'm not sure if its worth it for safechecking for such edge cases.
I can make PR for this.
When getting the EpisodeVideo data for most shows I've tried (ie. Shingeki no Kyojin), all ImageURLs are "https://cdn.myanimelist.net/images/icon-banned-youtube.png".
It would be appreciated to have an interval between requests as a optional parameter. It would be good to support custom ratelimits for self-hosted APIs as well.
As of now the ratelimits for the main instance jikan.moe are:
Daily Limit: Unlimited
30 requests / minute
2 requests / second
Bulk requests must be 1 request / 4 seconds.
Hi Ervie, I've noticed GetSeason stopped working as expected, I'm not sure when this happened but the last version of jikan GetSeason returns JikanValidationException when selected year is bigger than current year.
Steps to reproduce:
Expected:
Actual behavior:
Is this windows 10 package Manager?
Or do i need to install a piece if software first. E.G Node.js?
Looking at https://api.jikan.moe/v4/anime/1/reviews, you can see the json below. However, the model currently has properties that are no longer there, like votes, ReviewScores, and missing important fields like Score and IsSpoiler.
However I noticed multiple tests testing against Votes, despite the payload not having it. Thoughts? I need to be able to get the score of the review, however current version is always having Overall as 0.
Note: I have already coded up the model and can raise a PR if needed.
{
"mal_id": 7406,
"url": "https://myanimelist.net/reviews.php?id=7406",
"type": "anime",
"reactions": {
"overall": 2156,
"nice": 2136,
"love_it": 9,
"funny": 1,
"confusing": 1,
"informative": 5,
"well_written": 4,
"creative": 0
},
"date": "2008-08-24T05:46:00+00:00",
"review": "...",
"score": 10,
"tags": [
"Recommended"
],
"is_spoiler": false,
"is_preliminary": false,
"episodes_watched": null,
"user": {
"url": "https://myanimelist.net/profile/TheLlama",
"username": "TheLlama",
"images": {
"jpg": {
"image_url": "https://cdn.myanimelist.net/s/common/userimages/35fb5f95-6a86-498b-93a5-fcff7f402bc2_42x62_i?s=31842eb777c5fc3e5a4324250440ae95"
},
"webp": {
"image_url": "https://cdn.myanimelist.net/s/common/userimages/35fb5f95-6a86-498b-93a5-fcff7f402bc2_42x62_i?s=31842eb777c5fc3e5a4324250440ae95"
}
}
}
},
Hi, I just released Jikan v3.2. It has some new additions and changes, thought I'd let wrapper devs know directly.
Anime
GET /v3/anime/{id}/reviews/{page}
Manga
GET /v3/anime/{id}/reviews/{page}
Remarks: Only 20 items are shown per page for reviews
Anime
GET /v3/anime/{id}/recommendations
Manga
GET /v3/anime/{id}/recommendations
Anime
GET /v3/anime/{id}/userupdates/{page}
Manga
GET /v3/anime/{id}/userupdates/{page}
GET /v3/season/later
GET /v3/club/{id}
GET /v3/club/{id}/members
Documentation: https://jikan.docs.apiary.io
Add new constructor to Jikan
class which accepts custom, user-provided HttpClient
.
With this feature user will be able to provide custom HttpClient
with preconfigured HttpMessageHandler, make HttpClient
resilient with Polly for example etc.
Currently it is possible to achieve the same thing via reflection or with implementing IJikan
interface and making such constructor, however both ways are looking tricky to me.
/// <summary>
/// Constructor.
/// </summary>
/// <param name="httpClient">Http client to call REST request and receive REST response</param>
/// <param name="suppressException">Should exception be thrown in case of failed request. If true, failed request return null.</param>
public Jikan(HttpClient httpClient, bool suppressException = false)
{
_suppressException = suppressException;
_httpClient = httpClient
}
Optionally check httpClient
instance for being null.
I can make a PR for this.
Hi Ervie, after update 1.5.0 the property About from Character is empty.
Steps to reproduce:
Use GetCharacter(CharacterMALid) on Jikan version 1.4.2 to get any character which has a description (About property)
Expected behavior: character which has description on MAL will have text on About property
Actual behavior: text exist inside About property
Use GetCharacter(CharacterMALid) on Jikan version 1.5.0 to get any character which has a description (About property)
Expected behavior: character which has description on MAL will have text on About property
Actual behavior: About property is empty
Sample request: https://api.jikan.moe/v3/search/manga?q=naruto
...
"results":[{"mal_id":95210,"url":"https:\/\/myanimelist.net\/manga\/95210\/Boruto__Naruto_Next_Generations","title":"Boruto: Naruto Next Generations","image_url":"https:\/\/cdn.myanimelist.net\/images\/manga\/3\/181968.jpg","type":"Manga","volumes":null,"chapters":null,"publishing":true,
...
JikanDotNet.Exceptions.JikanRequestException: Serialization failed.
Inner exception message: Error converting value {null} to type 'System.Int32'. Path 'results[0].chapters', line 1, position 404.
---> Newtonsoft.Json.JsonSerializationException: Error converting value {null} to type 'System.Int32'. Path 'results[0].chapters', line 1, position 404.
---> System.InvalidCastException: Null object cannot be converted to a value type.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
--- End of inner exception stack trace ---
The System.Text,Json namespace is a relatively new JSON (de)serializing library for .NET, which would reduce one dependency for this project. Would it be possible to implement it instead? here is a doc/overview
I noticed the GetSeasonAsync
method doesn't have overload with page
param, in Jikan rest api it has a query param to page
.
Is there any way to retrieve next page from GetUpcomingSeasonAsync
method? Now it returns 25 records from first page with pagination data but with no option to set the number of page or am I missing something? Thank you
It looks like the JikanApiError
model does not get its properties filled.
Most likely due to the properties being private set
?
Is there any possible error handling for things like GetAnime? for example the id 500 does not exist on MAL and I use Jikan.net for a discord bot I am currently coding but am having trouble trying to do some error handling when something, like I mentioned above, happens. This could be very niche but would be cool if there's some built-in error handling or if you could give me some tips on how to handle situations like that.
Jikan REST API has a Rate Limit of 30 requests per minute, and 2 requests per second.
This becomes a problem when you are going over-limit. With request_cached
you can check if your request is cached so you dont have to add to your "rate limit" count. It is a way to not get errors when trying to do a request.
If you do IJikan#GetPerson
, i have no idea if it has been cached or not.
I think its because myanimelist.net change person to people in url
https://myanimelist.net/person/{id} return an error
the correct url that return a data is:
https://myanimelist.net/people/{id}
It seems I cannot do this request with Jikan.NET:
https://docs.api.jikan.moe/#operation/getCharacterFullById
Instead I would need to do all of these requests to get the complete information of the character.
GetCharacter
GetCharacterAnime
GetCharacterManga
GetCharacterVoiceActors
Using version 2.1.1
For reference, I am attempting to use GetAnime on the anime Key The Metal Idol
https://myanimelist.net/anime/1457/Key_the_Metal_Idol
Grabbing the basic info of the series directly from an AnimeSearchResult object works fine, but when I pull the MalID from the AnimeSearchResult object and then do GetAnime(MalId) in an attempt to get more detailed information, I receive this error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.