Skip to content

Kayuwaii/MyAnimeList.API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

N|Solid

MyAnimeList.API (Unofficial Wrapper)

A simple .NET Standard wrapper for MAL's API v2. Nuget

This library provides a client that manages Athentication, Requests and Responses from the API, so that developers can interact with it easily. Authorization is not managed since each user should accept or decline on their own accord. However:

  • The authorization URL is generated by the URL.
  • The client has a method to recieve the authorization code and finish the authentication process.
  • Since the code is provided in the redirection URL, it is recomended to have some sort of API/WebService to automatically read the code and call the aforementioned method.

Current Features!

  • Authenticate aganist the API.
  • Manual Token Refresh.
  • Automatic Token Refresh.
  • Search Animes.
  • Get Seasonal Animes.

Future Features!

Basically everything avaliable in the API, but the next ones to become avaliable will be:

  • Check Anime rankings.
  • Check individual Anime(Detailed).
  • Exception handling.

Usage Example

I've tried my best to make it easy to use, here's an example where we manually provide the code to a console app:

            var temp = new UserParams
            {
                ClientId = "YOUR_CLIENT_ID",
                OAuth2State = "STRING_OF_YOUR CHOICE",
                RedirectURI = "THE_URI"
            };
            MALApiClient client = new MALApiClient(temp);
            string code = client.GetAuthUrl(); //The URL to authorize the API usage for our account
            Console.WriteLine(code); // Print to console, copy the url and allow from a browser
            client.DoAuth(Console.ReadLine()); // From the url copy the code and paste it.

            Console.Write("Search: "); 
            string s = Console.ReadLine();//Input string to search
            GetAnimeListRequest xd = new GetAnimeListRequest // Create a request object, limit is the maximum amount of entries to obtain
            {
                Search = "One",
                Limit = 10
            };
            Console.WriteLine("\n\n Test List:");
            var lRes = test.GetAnimeList(xd).Result;
            foreach (var item in lRes.data)
            {
                Console.WriteLine("\t" + item.node.title);
            }

            Console.WriteLine("\n\n Test Refresh Auth:");
            test.RenewAuth();

            xd.Search = "Souma";

            lRes = test.GetAnimeList(xd).Result;
            foreach (var item in lRes.data)
            {
                Console.WriteLine("\t" + item.node.title);
            }

            GetSeasonalAnimeListRequest s = new GetSeasonalAnimeListRequest
            {
                Season = Seasons.SUMMER,
                Limit = 10
            };
            Console.WriteLine("\n\n Test SeasonList:");
            var sRes = test.GetSeasonalAnimeList(s).Result;
            foreach (var item in sRes.data)
            {
                Console.WriteLine("\t" + item.node.title);
            }
            

This program ilustrates how to use the wrapper, but you can also use it to test if your API key or redirection url work properly, since it runs some methods automatically. More examples and better documentation will be added as more features are added.

About

A simple .NET wrapper for the new MyAnimeList API

Topics

Resources

License

Stars

Watchers

Forks

Languages