twitcaspy.API — Twitcasting API v2 Reference
- class twitcaspy.API(auth=None, *, host='apiv2.twitcasting.tv', parser=None, user_agent=None, signature=None)
Twitcasting API v2.0 Interface
- Parameters
auth (
AuthHandler) – The authentication handler to be usedhost (
str) – The general REST API host server URLparser (
Parser) –The Parser instance to use for parsing the response from Twitcasting.defaults to an instance of ModelParseruser_agent (
str) – The UserAgent to be usedsignature (
str) – Key to prove that it is a legitimate request in webhook.
- Raises
TypeError – If the given parser is not a Parser instance
References
Twitcasting API v2 Endpoint |
|
|---|---|
|
|
User
get_user_info
- API.get_user_info(*, id=None, screen_id=None)
- Returns information about the specified user.Either an id or screen_id is required for this method.
- Parameters
- Returns
- Return type
- Raises
TwitcaspyException – If both id and screen_id are not specified
References
verify_credentials
- API.verify_credentials()
Returns application and user information about the access_token.
- Returns
- Return type
References
Live Thumbnail
get_live_thumbnail_image
- API.get_live_thumbnail_image(*, id=None, screen_id=None, size='small', position='latest')
- Returns live thumbnail the specified user.Returns an offline image if the user is not streaming now.Either an id or screen_id is required for this method.
Tip
No authentication required.
- Parameters
id (
str) – The ID of the user. If you specify this parameter, screen_id is ignored.screen_id (
str) – The screen name of the user.(e.g.: @~~)size(optional) (
str) –image size’large’ or ‘small’ can be specified.(default is ‘small’.)position(optional) (
str) –‘beginning’ or ‘latest’ can be specified.(default is ‘latest’.)
- Returns
- Image data is stored in the content attribute.
- Return type
requests.models.Response- Raises
TwitcaspyException – If both id and screen_id are not specified
References
Movie
get_movie_info
- API.get_movie_info(movie_id)
Returns information about the specified movie.
References
get_movies_by_user
- API.get_movies_by_user(*, id=None, screen_id=None, offset=0, limit=20, slice_id=None)
- Returns movies of the specified user in descending order of creation date and time.Either an id or screen_id is required for this method.
- Parameters
id (
str) – The ID of the user. If you specify this parameter, screen_id is ignored.screen_id (
str) – The screen name of the user.(e.g.: @~~)offset(optional) (
int) –Position from the beginningIt can be specified in the range of 0 to 1000.(default is 0.)limit(optional) (
int) –Maximum number of acquisitionsIt can be specified in the range of 1 to 50.(default is 20.)(In some cases, it may return less than the specified number of videos.)slice_id(optional) (
intorNone) –Gets the movie before this slice_id.It can be specified in the range of 1 or more.(Not specified by default.[=None])If you specify this parameter, offset is ignored.
- Returns
- Return type
- Raises
TwitcaspyException – If both id and screen_id are not specified
References
get_current_live
- API.get_current_live(*, id=None, screen_id=None)
- Returns live information if the user is streaming now.Either an id or screen_id is required for this method.
- Parameters
- Returns
- Return type
- Raises
TwitcaspyException – If both id and screen_id are not specified
References
set_current_live_subtitle
- API.set_current_live_subtitle(subtitle, *, cut_out=False)
- If the user is broadcasting, set a live telop.
- Parameters
- Returns
- Return type
- Raises
TwitcaspyException: – When the subtitle is less than one character. When the subtitle is more than 17 characters and cut_out is False.
References
unset_current_live_subtitle
- API.unset_current_live_subtitle()
- If the user is broadcasting, unset a live telop.
- Returns
- Return type
References
https://apiv2-doc.twitcasting.tv/#unset-current-live-subtitle
set_current_live_hashtag
- API.set_current_live_hashtag(hashtag, *, cut_out=False)
- If the user is broadcasting, set a live hashtag.
- Parameters
- Returns
- Return type
- Raises
TwitcaspyException: – When the hashtag is less than one character./ When the hashtag is more than 26 characters and cut_out is False.
References
unset_current_live_hashtag
- API.unset_current_live_hashtag()
- If the user is broadcasting, unset a live hashtag.
- Returns
- Return type
References
https://apiv2-doc.twitcasting.tv/#unset-current-live-hashtag
Comment
get_comments
- API.get_comments(movie_id, *, offset=0, limit=20, slice_id=None)
- Returns comments of the specified movie in descending order of creation date and time.
- Parameters
movie_id (
str) – The ID of the movie.offset(optional) (
int) –Position from the beginningIt can be specified in the range of 0 or more.(default is 0.)limit(optional) (
int) –Maximum number of acquisitionsIt can be specified in the range of 1 to 50.(default is 10.)(In some cases, it may return less than the specified number of videos.)slice_id(optional) (
intorNone) –Gets the comment after this slice_id.It can be specified in the range of 1 or more.(Not specified by default.[=None])If you specify this parameter, offset is ignored.The minimum value that can be specified for slice_id is now 1.
- Returns
- Return type
References
post_comment
- API.post_comment(movie_id, comment, *, sns='none')
- Post a comment.It can be executed only on a user-by-user basis.
- Parameters
movie_id (
str) – The ID of the movie.comment (
str) –Comment text to post.Must be 1 to 140 characters.sns (
str) –Simultaneous posting to SNS.(Valid only when the user is linked with Twitter or Facebook.)’reply’ : Post in a format that replies to the streamer.’normal’ : Regular post.’none’ : No SNS posts.
- Returns
- Return type
- Raises
TwitcaspyException: – When comment is not 1-140 characters.
References
delete_comment
- API.delete_comment(movie_id, comment_id)
- Delete the comment.It can be executed only on a user-by-user basis.As a general rule, the comments that can be deleted are limited to those that the poster is the same as the user associated with the access token.However, if you use the access token of the user who owns the movie, you can delete the comments posted by other users.
- Parameters
- Returns
- Return type
References
Gift
get_gifts
- API.get_gifts(*, slice_id=- 1)
- Acquire the item sent by the user associated with the access token in the last 10 seconds.
- Parameters
slice_id(optional) (
int) –Gets the items sent after this item send ID.It can be specified in the range of -1 or more.(default is -1.)- Returns
- Return type
References
Supporter
get_supporting_status
- API.get_supporting_status(target_user_id, *, id=None, screen_id=None)
- Gets the status of whether a user is a supporter of another user.Either an id or screen_id is required for this method.
- Parameters
Warning
Note that unlike
Supporter, there is no supported_time attribute.- Returns
- Return type
- Raises
TwitcaspyException – If both id and screen_id are not specified
References
support_user
- API.support_user(target_user_ids=None)
- Become a supporter of the specified user.
- Parameters
target_user_ids (
listortuple) –An array of target user id or screen_idThe number of elements in the array must be 20 or less.- Returns
- Return type
- Raises
TwitcaspyException – When target_user_ids is not a
listortuple
References
unsupport_user
- API.unsupport_user(target_user_ids=None)
- Release the supporter status of the specified user.
- Parameters
target_user_ids (
listortuple) –An array of target user id or screen_idThe number of elements in the array must be 20 or less.- Returns
- Return type
- Raises
TwitcaspyException – When target_user_ids is not a
listortuple
References
supporting_list
- API.supporting_list(*, id=None, screen_id=None, offset=0, limit=20)
- Get a list of users supported by the specified user.Either an id or screen_id is required for this method.
- Parameters
id (
str) – The ID of the user. If you specify this parameter, screen_id is ignored.screen_id (
str) – The screen name of the user.(e.g.: @~~)offset(optional) (
int) –Position from the beginningIt can be specified in the range of 0 or more.(default is 0.)limit(optional) (
int) –Maximum number of acquisitionsIt can be specified in the range of 1 to 20.(default is 20.)(In some cases, it may return less than the specified number of support users.)
- Returns
- Return type
- Raises
TwitcaspyException – If both id and screen_id are not specified
References
supporter_list
- API.supporter_list(sort='ranking', *, id=None, screen_id=None, offset=0, limit=20)
- Get a list of users who support the specified user.Either an id or screen_id is required for this method.
- Parameters
sort (
str) –Sort ordersort must be one of the following:’new’ : New arrival order’ranking’ : Contribution orderid (
str) – The ID of the user. If you specify this parameter, screen_id is ignored.screen_id (
str) – The screen name of the user.(e.g.: @~~)offset(optional) (
int) –Position from the beginningIt can be specified in the range of 0 or more.(default is 0.)limit(optional) (
int) –Maximum number of acquisitionsIt can be specified in the range of 1 to 20.(default is 20.)(In some cases, it may return less than the specified number of support users.)
- Returns
- Return type
- Raises
TwitcaspyException – If both id and screen_id are not specified.
TwitcaspyException – When sort is not a ‘new’ or ‘ranking’.
References
Category
get_categories
- API.get_categories(lang='ja')
- Get only the categories being streamed.
- Parameters
lang (
str) –Language to searchlang must be one of the following:’ja’ : Japanese’en’ : English- Returns
- Return type
- Raises
TwitcaspyException – When lang is not a ‘ja’ or ‘en’.
References
Search users and movies
search_users
- API.search_users(words, *, limit=10, lang='ja')
- Search for users.
- Parameters
words (
strorlistortuple) –Multiple words are ANDed by separating them with space.lang (
str) –Language setting of the user to be searched.Currently only “ja” is supported.’ja’ : Japaneselimit(optional) (
int) –Maximum number of acquisitionsIt can be specified in the range of 1 to 50.(default is 10.)(In some cases, it may return less than the specified number of support users.)
- Returns
- Return type
- Raises
TwitcaspyException – When lang is not a ‘ja’.
TwitcaspyException – When words are not specified
TwitcaspyException – When words is not a
str,listortuple
References
search_live_movies
- API.search_live_movies(*, type='word', content)
- Search for live concerts being streamed.
- Parameters
limit(optional) (
int) –Maximum number of acquisitionsIt can be specified in the range of 1 to 100.(default is 10.)(In some cases, it may return less than the specified number of support users.)type (
str) –Search typetype must be one of the following:’tag’ : Tag search’word’ : Word search’category’ : Subcategory ID match search’new’ : New Search’recommend’ : recommend searchlang (
str) –Language setting of the user to be searched.Currently only “ja” is supported.’ja’ : Japanese
- Returns
- Return type
- Raises
TwitcaspyException – When type are not specified.
TwitcaspyException – When type is not a tag, word, category, new or recommend.
TwitcaspyException – No context specified when type is tag, word or category.
TwitcaspyException – When lang is not a ‘ja’.
References
WebHook
incoming_webhook
- API.incoming_webhook(data, secure=True)
- Parses notifications to the specified WebHook URL.
Hint
By using the WebHook API, it is possible to notify the distribution start / end event of a specific distributor to the WebHook URL specified in advance. (This sentence was translated by Google Translate.[ja->en])
Tip
No authentication required.
Note
Method : POST
- Parameters
- Returns
- Return type
- Raises
TwitcaspyException – When secure is true and signature do not match.
References
get_webhook_list
- API.get_webhook_list(limit=50, offset=0, user_id)
- Get the list of WebHooks associated with the application.
Tip
It can only be executed on an Application-only authentication.- Parameters
limit(optional) (
int) –Maximum number of acquisitionsIt can be specified in the range of 1 to 50.(default is 50.)(In some cases, it may return less than the specified number of webhooks.)offset(optional) (
int) –Position from the beginningIt can be specified in the range of 0 or more.(default is 0.)user_id(optional) (
str) –Target user id
Hint
The limit and offset parameters are valid only if user_id is not specified.Note
For user_id, you can specify a numeric id (e.g.: 182224938) or a character string (e.g.: twitcasting_jp).- Returns
- Return type
References
register_webhook
- API.register_webhook(user_id, event)
- Register a new WebHook.
Tip
It can only be executed on an Application-only authentication.- Parameters
Note
For user_id, you can specify a numeric id (e.g.: 182224938) or a character string (e.g.: twitcasting_jp).- Returns
- Return type
- Raises
TwitcaspyException – When events is not a
listortupleTwitcaspyException – When events is not a livestart, liveend.
References
remove_webhook
- API.remove_webhook(user_id, event)
- Remove WebHook.
Tip
It can only be executed on an Application-only authentication.- Parameters
Note
For user_id, you can specify a numeric id (e.g.: 182224938) or a character string (e.g.: twitcasting_jp).- Returns
- Return type
- Raises
TwitcaspyException – When events is not a
listortupleTwitcaspyException – When events is not a livestart, liveend.
References
Broadcasting
get_rtmp_url
- API.get_rtmp_url()
- Obtain the URL (RTMP) for stream of the user associated with the access token.
Tip
It can only be executed on an non-Application-only authentication.- Returns
- Return type
References
get_webm_url
- API.get_webm_url()
- Obtain the URL (WebM, WebSocket) for stream of the user associated with the access token.
Tip
It can only be executed on an non-Application-only authentication.- Returns
- Return type
References