Skip to content

nomnoms12/shikimori_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shikimori_api

Build Status Coverage Status License Shikimori Status PyPI - Python Version

Unofficial wrapper for the Shikimori API

Installation

This package requires Python 3.6 or later

pip install shikimori_api

Dependencies

Usage

from shikimori_api import Shikimori


session = Shikimori()
api = session.get_api()

api.animes.GET(search='KonoSuba', kind='movie')  # GET /api/animes?search=KonoSuba&kind=movie
api.animes(1).GET()                              # GET /api/animes/1
api.animes(1).screenshots.GET()                  # GET /api/animes/1/screenshots

OAuth

import json


def token_saver(token: dict):
    with open('token.json', 'w') as f:
        f.write(json.dumps(token))


session = Shikimori('APP_NAME', client_id='CLIENT_ID', client_secret='CLIENT_SECRET', token_saver=token_saver)

print(session.get_auth_url())
code = input('Authorization Code: ')
session.fetch_token(code)

After receiving and saving token, you can load it from file:

with open('token.json') as f:
    token = json.load(f)
session = Shikimori('APP_NAME', client_id='CLIENT_ID', client_secret='CLIENT_SECRET',
                    token=token, token_saver=token_saver)