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:
objectAPI 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
Workobjects.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
Episodeobjects.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
Recordobjects.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
Userobjects.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
Userobjects.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
Userobjects.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
Activityobjects.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: Userobject 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: Recordobject.
-
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: Recordobject 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
Workobjects.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
Programobjects.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
Activityobjects.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:
objectOAuth 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.ModelActivity information model
-
class
annict.models.Episode(api=None)[source]¶ Bases:
annict.models.ModelEpisode 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: Recordobject.
-
-
class
annict.models.Model(api=None)[source]¶ Bases:
objectAbstract 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.ModelProgram information model
-
class
annict.models.Record(api=None)[source]¶ Bases:
annict.models.ModelRecord 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: Recordobject after edit.
-
-
class
annict.models.ResultSet(total_count, prev_page=None, next_page=None)[source]¶ Bases:
listA list like object that holds results from an Annict API query.
-
class
annict.models.User(api=None)[source]¶ Bases:
annict.models.ModelUser 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
Userobjects.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
Userobjects.Return type:
-
-
class
annict.models.Work(*args, **kwargs)[source]¶ Bases:
annict.models.ModelWork 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
Episodeobjects.Return type:
-
get_episode(number)[source]¶ Get Episode object
Parameters: number – Episode number Returns: EpisodeobjectReturn 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: WorkobjectReturn 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:
objectA 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