GithubHelp home page GithubHelp logo

kk6 / python-annict Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 2.0 413 KB

Annict API for python

Home Page: https://python-annict.readthedocs.io/en/latest/

License: MIT License

Python 99.97% Gherkin 0.03%
python annict library api-wrapper

python-annict's Introduction

python-annict

Annict API wrapper for Python

Codacy Badge CircleCI codecov PyPI License Code style: black

python-annict officially supports Python 3.6 or higher.

Installation

pip install annict

Quickstart

Authentication

Acquire the URL for authentication code.

>>> from annict.auth import OAuthHandler
>>> handler = OAuthHandler(client_id='Your client ID', client_secret='Your client secret')
>>> url = handler.get_authorization_url(scope='read write')
>>> print(url)

Open the browser and access the URL you obtained, the authentication code will be displayed. It will be passed to the handler.authenticate() 's argument to get the access token.

>>> handler.authenticate(code='Authentication code')
>>> print(handler.get_access_token())

Note that this authentication flow is unnecessary when issuing a personal access token on Annict and using it.

See: Annict API: 個人用アクセストークンが発行できるようになりました

Hello world

>>> from annict.api import API
>>> annict = API('Your access token')
>>> results = annict.works(filter_title="Re:ゼロから始める異世界生活")
>>> print(results[0].title)
Re:ゼロから始める異世界生活

Cache

For now, we do not have our own cache system. However, caching is also important to reduce the load on AnnictAPI.

So I introduce a cache plugin for requests library called requests_cache.

Install with pip.

pip insall requests_cache

requests_cache is very easy to use.

>>> import requests_cache
>>> requests_cache.install_cache(cache_name='annict', backend='memory', expire_after=300)
>>> # At first, from Annict API.
>>> api.me()
>>> # You can get results from cache, if it is within the expiration time.
>>> api.me()

For more information: Requests-cache documentation

Documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.