API Reference¶
annict.api module¶
API (token[, base_url, api_version, parser]) |
API wrapper for Annict. |
API.works ([fields, filter_ids, ...]) |
Get works information |
API.episodes ([fields, filter_ids, ...]) |
Get episodes information |
API.records ([fields, filter_ids, ...]) |
Get records to episodes |
API.search_users ([fields, filter_ids, ...]) |
Get users information |
API.following ([fields, filter_user_id, ...]) |
Get following information |
API.followers ([fields, filter_user_id, ...]) |
Get followers information |
API.activities ([fields, filter_user_id, ...]) |
Get activities |
API.me ([fields]) |
Get your profile information |
API.set_status (work_id, kind) |
Set the status of the work. |
API.create_record (episode_id[, comment, ...]) |
Create a record to the episode. |
API.edit_record (id_[, comment, rating, ...]) |
Edit the created record. |
API.delete_record (id_) |
Delete the created record. |
API.my_works ([fields, filter_ids, ...]) |
Get the information of the work you are setting status. |
API.my_programs ([fields, filter_ids, ...]) |
Get the broadcast schedule. |
API.following_activities ([fields, ...]) |
Get the activity of the user you are following. |
-
class
annict.api.
API
(token, base_url='https://api.annict.com', api_version='v1', parser=<class 'annict.parsers.ModelParser'>)[source]¶ Bases:
object
API wrapper for Annict.
Basic Usage:
>>> from annict.api import API >>> api = API('your-access-token') >>> api.me() <User:1229:あしやひろ:@kk6>
-
works
(fields=None, filter_ids=None, filter_season=None, filter_title=None, page=None, per_page=None, sort_id=None, sort_season=None, sort_watchers_count=None)[source]¶ Get works information
Reference: Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- filter_ids (list of int) – (optional) Filter results by IDs.
- filter_season (str) – (optional) Filter results by release time of season.
- filter_title (str) – (optional) Filter results by title.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
- sort_season (str) – (optional) Sort the results by their release time of season. You can specify asc or desc.
- sort_watchers_count (str) – (optional) Sort the results by their watchers count. You can specify asc or desc.
Returns: list of
Work
objects.Return type:
-
episodes
(fields=None, filter_ids=None, filter_work_id=None, page=None, per_page=None, sort_id=None, sort_sort_number=None)[source]¶ Get episodes information
Reference: Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- filter_ids (list of int) – (optional) Filter results by IDs.
- filter_work_id (int) – (optional) Filter results by Work’s ID.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
- sort_sort_number (str) – (optional) Sort by number for sorting. You can specify asc or desc.
Returns: list of
Episode
objects.Return type:
-
records
(fields=None, filter_ids=None, filter_episode_id=None, filter_has_record_comment=None, page=None, per_page=None, sort_id=None, sort_likes_count=None)[source]¶ Get records to episodes
Reference: Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- filter_ids (list of int) – (optional) Filter results by IDs.
- filter_episode_id (int) – (optional) Filter results by Episode’s ID.
- filter_has_record_comment (bool) – (optional) Filter the results by the presence or absence of comments. If you specify True, only records with comments will be filtered. Specifying False Filter records without comments.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
- sort_likes_count (str) – (optional) Sort the results by their number of likes. You can specify asc or desc.
Returns: list of
Record
objects.Return type:
-
search_users
(fields=None, filter_ids=None, filter_usernames=None, page=None, per_page=None, sort_id=None)[source]¶ Get users information
Reference: Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- filter_ids (list of int) – (optional) Filter results by IDs.
- filter_usernames (list of str) – (optional) Filter results by usernames.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
Returns: list of
User
objects.Return type:
-
following
(fields=None, filter_user_id=None, filter_username=None, page=None, per_page=None, sort_id=None)[source]¶ Get following information
Reference: Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- filter_user_id (int) – (optional) Filter results by User’s ID.
- filter_username (str) – (optional) Filter results by username.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
Returns: list of
User
objects.Return type:
-
followers
(fields=None, filter_user_id=None, filter_username=None, page=None, per_page=None, sort_id=None)[source]¶ Get followers information
Reference: Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- filter_user_id (int) – (optional) Filter results by User’s ID.
- filter_username (str) – (optional) Filter results by username.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
Returns: list of
User
objects.Return type:
-
activities
(fields=None, filter_user_id=None, filter_username=None, page=None, per_page=None, sort_id=None)[source]¶ Get activities
Reference: Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- filter_user_id (int) – (optional) Filter results by User’s ID.
- filter_username (str) – (optional) Filter results by username.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
Returns: list of
Activity
objects.Return type:
-
me
(fields=None)[source]¶ Get your profile information
Reference: https://docs.annict.com/ja/api/v1/me.html Parameters: fields (list of str) – (optional) Narrow down the fields of data contained in the response body. Returns: User
object of your user information.
-
set_status
(work_id, kind)[source]¶ Set the status of the work.
Reference: Parameters: - work_id (int) – Work’s ID
- kind (str) – Types of status. You can specify wanna_watch, watching, watched, on_hold, stop_watching, or no_select.
Returns: Returns True if deletion succeeded.
-
create_record
(episode_id, comment=None, rating=None, share_twitter=False, share_facebook=False)[source]¶ Create a record to the episode.
Reference: Parameters: - episode_id (int) – Episode’s ID
- comment (str) – (optional) Comment.
- rating (float) – (optional) Rating.
- share_twitter (bool) – (optional) Whether to share the record on Twitter. You can enter True or False.
- share_facebook (bool) – (optional) Whether to share the record on Facebook. You can enter True or False.
Returns: Record
object.
-
edit_record
(id_, comment=None, rating=None, share_twitter=False, share_facebook=False)[source]¶ Edit the created record.
Reference: Parameters: - id (int) – Record’s ID.
- comment (str) – (optional) Comment.
- rating (float) – (optional) Rating.
- share_twitter (bool) – (optional) Whether to share the record on Twitter. You can enter True or False.
- share_facebook (bool) – (optional) Whether to share the record on Facebook. You can enter True or False.
Returns: Record
object after update.
-
delete_record
(id_)[source]¶ Delete the created record.
Reference: https://docs.annict.com/ja/api/v1/me-records.html Parameters: id (int) – Recode’s ID Returns: Returns True if deletion succeeded.
-
my_works
(fields=None, filter_ids=None, filter_season=None, filter_title=None, filter_status=None, page=None, per_page=None, sort_id=None, sort_season=None, sort_watchers_count=None)[source]¶ Get the information of the work you are setting status.
Reference: Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- filter_ids (list of int) – (optional) Filter results by IDs.
- filter_season (str) – (optional) Filter results by release time of season.
- filter_title (str) – (optional) Filter results by title.
- filter_status (str) – (optional) Filter results by status. You can specify wanna_watch, watching, watched, on_hold, stop_watching.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
- sort_season (str) – (optional) Sort the results by their release time of season. You can specify asc or desc.
- sort_watchers_count (str) – (optional) Sort the results by their watchers count. You can specify asc or desc.
Returns: list of
Work
objects.Return type:
-
my_programs
(fields=None, filter_ids=None, filter_channel_ids=None, filter_work_ids=None, filter_started_at_gt=None, filter_started_at_lt=None, filter_unwatched=None, filter_rebroadcast=None, page=None, per_page=None, sort_id=None, sort_started_at=None)[source]¶ Get the broadcast schedule.
Reference: Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- filter_ids (list of int) – (optional) Filter results by IDs.
- filter_channel_ids (list of int) – (optional) Filter results by Channel IDs.
- filter_work_ids (list of int) – (optional) Filter results by Work IDs.
- filter_started_at_gt (datetime) – (optional) Filter results results to those with the broadcast start date and time after the specified date and time.
- filter_started_at_lt (datetime) – (optional) Filter results results to those with the broadcast start date and time before the specified date and time.
- filter_unwatched (bool) – (optional) Only get unwatched broadcast schedules.
- filter_rebroadcast (bool) – (optional) Filter the broadcast schedule based on the rebroadcast flag. If you pass True, only rebroadcasting, passing False will get broadcast schedules other than rebroadcast.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
- sort_started_at (str) – (optional) Sort the results by started_at.
Returns: list of
Program
objects.Return type:
-
following_activities
(fields=None, filter_actions=None, filter_muted=None, page=None, per_page=None, sort_id=None)[source]¶ Get the activity of the user you are following.
Reference: https://docs.annict.com/ja/api/v1/me-following-activities.html
Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- filter_actions (str) – (optional) Filter results by action (create_record|create_multiple_records|create_status).
- filter_muted (bool) – (optional) Specify whether to exclude muted users with the mute function. You can exclude with True and not exclude with False. The default is True (exclude).
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
Returns: list of
Activity
objects.Return type:
-
annict.auth module¶
-
class
annict.auth.
OAuthHandler
(client_id, client_secret, name='annict', base_url='https://api.annict.com', redirect_uri='urn:ietf:wg:oauth:2.0:oob')[source]¶ Bases:
object
OAuth authentication handler
-
authenticate
(code, decoder=<function OAuthHandler.<lambda>>)[source]¶ Acquire the access token using the authorization code acquired after approval.
Parameters: - code – Authorization code obtained after approval.
- decoder – (optional) A function used to parse the Response content. Should return a dictionary.
Returns an authorization url
Parameters: scope – (optional) Specify authority to access resources. Readonly defaults. Returns: URL of page requesting permission Return type: str
-
annict.models module¶
-
class
annict.models.
Activity
(api=None)[source]¶ Bases:
annict.models.Model
Activity information model
-
class
annict.models.
Episode
(api=None)[source]¶ Bases:
annict.models.Model
Episode information model
-
create_record
(comment=None, rating=None, share_twitter=False, share_facebook=False)[source]¶ Create a record for this episode.
Parameters: - comment (str) – (optional) Comment.
- rating (float) – (optional) Rating.
- share_twitter (bool) – (optional) Whether to share the record on Twitter. You can enter True or False.
- share_facebook (bool) – (optional) Whether to share the record on Facebook. You can enter True or False.
Returns: Record
object.
-
-
class
annict.models.
Model
(api=None)[source]¶ Bases:
object
Abstract class of each models.
-
classmethod
parse_list
(api, json, payload_type)[source]¶ Parse JSON objects into list of model instances.
Parameters: - api (annict.api.API) – instance of
API
. - json (dict) – JSON from Annict API.
- payload_type (str) – Type of payload.
Returns: list of Model objects.
Return type: - api (annict.api.API) – instance of
-
classmethod
-
class
annict.models.
Program
(api=None)[source]¶ Bases:
annict.models.Model
Program information model
-
class
annict.models.
Record
(api=None)[source]¶ Bases:
annict.models.Model
Record information model
-
edit
(comment=None, rating=None, share_twitter=False, share_facebook=False)[source]¶ Edit the created record.
Parameters: - comment (str) – (optional) Comment.
- rating (float) – (optional) Rating.
- share_twitter (bool) – (optional) Whether to share the record on Twitter. You can enter True or False.
- share_facebook (bool) – (optional) Whether to share the record on Facebook. You can enter True or False.
Returns: Record
object after edit.
-
-
class
annict.models.
ResultSet
(total_count, prev_page=None, next_page=None)[source]¶ Bases:
list
A list like object that holds results from an Annict API query.
-
class
annict.models.
User
(api=None)[source]¶ Bases:
annict.models.Model
User information model
-
followers
(fields=None, page=None, per_page=None, sort_id=None)[source]¶ Get following information of this user.
Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
Returns: list of
User
objects.Return type:
-
following
(fields=None, page=None, per_page=None, sort_id=None)[source]¶ Get following information of this user.
Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
Returns: list of
User
objects.Return type:
-
-
class
annict.models.
Work
(*args, **kwargs)[source]¶ Bases:
annict.models.Model
Work information model
-
episodes
(fields=None, filter_ids=None, page=None, per_page=None, sort_id=None, sort_sort_number=None)[source]¶ Get episodes information
Reference: Parameters: - fields (list of str) – (optional) Narrow down the fields of data contained in the response body.
- filter_ids (list of int) – (optional) Filter results by IDs.
- page (int) – (optional) Specify the number of pages.
- per_page (int) – (optional) Specify how many items to acquire per page.
- sort_id (str) – (optional) Sort the results by their ID. You can specify asc or desc.
- sort_sort_number (str) – (optional) Sort by number for sorting. You can specify asc or desc.
Returns: list of
Episode
objects.Return type:
-
get_episode
(number)[source]¶ Get Episode object
Parameters: number – Episode number Returns: Episode
objectReturn type: Episode
-
classmethod
parse
(api, json)[source]¶ Parse a JSON object into a model instance.
Parameters: - api (annict.api.API) – instance of
API
. - json (dict) – JSON from Annict API.
Returns: Work
objectReturn type: - api (annict.api.API) – instance of
-
annict.parsers module¶
annict.services module¶
-
class
annict.services.
APIMethod
(api, path, method, allowed_params=None, payload_type=None, payload_list=False)[source]¶ Bases:
object
A class abstracting each method of AnnictAPI
Parameters: - api (annict.api.API) – instance of
API
. - path (str) – Endpoint path
- method (str) – HTTP Method
- allowed_params (tuple) – (optional) List of request parameter names that can be sent.
- payload_type (str) – Type of payload
- payload_list (bool) – Specifies whether the payload is a list or not.
-
build_parameters
(dic)[source]¶ Build a suitable parameters for request.
It filters the given dictionary based on self.allowed_params and returns a dictionary with an additional access token.
Parameters: dic (dict) – dict of arguments given to annict.API’s method. Returns: dict for request parameter Return type: dict
- api (annict.api.API) – instance of