python-annict
Annict API wrapper for Python
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
Release files for annict 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| annict-0.7.0.tar.gz | 11.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| annict-0.7.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 57.0 kB
Release files / annict-0.7.0.tar.gz
| Download URL | annict-0.7.0.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29001f7aba31a6ec0bc0c1c1868f4490b78e058a3e93c3e0f54222e70b52bff2
|
|
BLAKE2b-256 checksum How to use checksums |
3a47b67c65341da26f9113696f59db04c780b9c7a263ee2d4bf605cb25b2951d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.10 CPython/3.7.1 Darwin/18.2.0
|
Release files / annict-0.7.0-py3-none-any.whl
| Download URL | annict-0.7.0-py3-none-any.whl |
|---|---|
| Size | 45.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
74978c0be438a8a508416a808a9904c8a5e1f0f050b10ed7c3e3a8fd97fabc36
|
|
BLAKE2b-256 checksum How to use checksums |
e758720933a34828f46f19ecef3ed4b3d5e33df80f27781ba885aad1fbee2037
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.10 CPython/3.7.1 Darwin/18.2.0
|