Skip to main content

Modified and rewritten using modern models version of James Fotherby malclient

Project description

MAL-API-Client-Upgraded

A third party object-oriented python3 client library for MyAnimeList's official REST API. Originally created by @JFryy, dropped around 2 years ago, picked up and rewritten by ModerNews to fit more modern standards and new REST API functions.

Documentation

There is first version of docs available, check it out

Installation

pip install git+https://github.com/ModerNews/MAL-API-Client-Upgraded

Authentication

Client library uses OAuth2 authorization, all you need to do is register your app here, and generate access token.
You can do it old-fashioned way using this tutorial
Or you can use function implemented in API

import malclient

print(malclient.generate_token("<YOUR_CLIENT_ID>", "<YOUR_CLIENT_SECRET>"))

Although remember to call it only once and, then use the token generated this way, optionally with Client.refresh_bearer_token method
Once an access token is retrieved, you can simply authenticate with this api with the following:

import malclient

client = malclient.Client(access_token="<YOUR_ACCESS_TOKEN>")

As mentioned previously, if your scared that your token will time out you can also utilize Client.refresh_bearer_token function

client.refresh_bearer_token(
          client_id="<your-client-id>",
          client_secret="<your-client-secret>",
          refresh_token="<your-refresh-token>"))

For any other issues regarding authentication, please refer to the following guide.

Quick Start Examples

I contained some examples of usage of this wrapper, note that all responses are converted to python objects using pydantic

import malclient

# nsfw filter is enabled by default, although it's recommended to disable it if your results are missing titles, 
#  you can also enable/disable it for every query individually 
client = malclient.Client(access_token="<your-access-token>", nsfw=True)

# search anime, returns list
anime = client.search_anime("cowboy", limit=20)
for item in anime:
    # prints only titles
    print(item)
    # prints all attributes of object
    print(repr(item))
    
# search anime, returns list
manga = client.search_manfa("Monogatari", limit=20)
for item in manga:
    # prints only titles
    print(manga)
    # prints all attributes of object
    print(repr(manga))

# Get individual anime by ID
anime = client.get_anime_details(1)
print(anime)
print(repr(anime))

# Update anime List based off of search results
anime = client.search_anime("Monogatari", limit=1)
my_status = {
    'status': 'watching',
    'score': 7
}
status = client.update_anime_my_list_status(anime[0].id, my_status)

# get authenticated user info
print(client.get_user_info())

# get user anime list (you can get other users by specifying username attribute)
for anime in client.get_user_anime_list():
    print(anime.title, anime.score)

# Update manga list based off search results
manga = client.search_manga('doro')
my_status = {
    'status': 'reading',
    'score': 9
}
client.update_manga_my_list_status(manga[0].id, my_status)

To Dos

  • [] Pagination support
  • [] Enumerators for statuses (completed, reading, watching, etc.)
  • [] Field filters for manga and anime queries
  • [] Rewrite boards (currently disabled)
  • [] Rewrite my list updaters
  • [] Probably something else that will pop out midways

P.S.

I'm looking forward to developing this library (even if myanimelist doesn't really look like developing API), and counting for your contributions
If anything bugs you, you can always reach me out at discord Gruzin#0911

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

malclient-upgraded-1.1.1.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

malclient_upgraded-1.1.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file malclient-upgraded-1.1.1.tar.gz.

File metadata

  • Download URL: malclient-upgraded-1.1.1.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for malclient-upgraded-1.1.1.tar.gz
Algorithm Hash digest
SHA256 6fa353f7933ba1654bdf8594cbba2efa70bc04cc57eabb76556f572d178097e2
MD5 3fd78864a540d607f2fcd8c304902af5
BLAKE2b-256 d63901495201f6d92fa5292f4b15f030811aeb573635c1f59197770e49e23067

See more details on using hashes here.

File details

Details for the file malclient_upgraded-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: malclient_upgraded-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for malclient_upgraded-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 409d2b1e4d0419348f0941702d254335292e309c9c15c28e192300f7da951d02
MD5 1360419e73cf0e96fbf1269a99b8371a
BLAKE2b-256 a4f5b54d3dc9bd644d45f17dfcd54d717f31149d1daeda045ea0ea3072771340

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page