Client

class tweepy.Client(bearer_token=None, consumer_key=None, consumer_secret=None, access_token=None, access_token_secret=None, *, return_type=Response, wait_on_rate_limit=False)

트위터 API v2 클라이언트(Client)

버전 4.0에 추가.

버전 4.15에서 변경: Removed block and unblock methods, as the endpoints they use have been removed

매개변수
  • bearer_token (str | None) – Twitter API OAuth 2.0 Bearer Token / Access Token

  • consumer_key (str | None) – Twitter API OAuth 1.0a Consumer Key

  • consumer_secret (str | None) – Twitter API OAuth 1.0a Consumer Secret

  • access_token (str | None) – Twitter API OAuth 1.0a Access Token

  • access_token_secret (str | None) – Twitter API OAuth 1.0a Access Token Secret

  • return_type (type[dict | requests.Response | Response]) – API 요청으로 반환받을 값의 형태

  • wait_on_rate_limit (bool) – API 호출 제한에 도달했을때 기다릴지의 여부

session

API 요청에 사용되는 요청 세션(Requests Session)

유형

requests.Session

user_agent

API 요청에 사용되는 사용자 에이전트(User agent)

유형

str

트위터 API v2 엔드포인트

Client 메서드

트윗

Bookmarks

DELETE /2/users/:id/bookmarks/:tweet_id

Client.remove_bookmark()

GET /2/users/:id/bookmarks

Client.get_bookmarks()

POST /2/users/:id/bookmarks

Client.bookmark()

Hide replies

부여: /2/tweets/:id/hidden

Client.hide_reply()

부여: /2/tweets/:id/hidden

Client.unhide_reply()

Likes

삭제: /2/users/:id/likes/:tweet_id

Client.unlike()

가져오기: /2/tweets/:id/liking_users

Client.get_liking_users()

가져오기: /2/users/:id/liked_tweets

Client.get_liked_tweets()

게시: /2/users/:id/likes

Client.like()

Manage Tweets

삭제: /2/tweets/:id

Client.delete_tweet()

게시: /2/tweets

Client.create_tweet()

Quote Tweets

GET /2/tweets/:id/quote_tweets

Client.get_quote_tweets()

Retweets

삭제: /2/users/:id/retweets/:source_tweet_id

Client.unretweet()

가져오기: /2/tweets/:id/retweeted_by

Client.get_retweeters()

게시: /2/users/:id/retweets

Client.retweet()

Search Tweets

가져오기: /2/tweets/search/all

Client.search_all_tweets()

가져오기: /2/tweets/search/recent

Client.search_recent_tweets()

Timelines

가져오기: /2/users/:id/mentions

Client.get_users_mentions()

GET /2/users/:id/timelines/reverse_chronological

Client.get_home_timeline()

가져오기: /2/users/:id/tweets

Client.get_users_tweets()

Tweet counts

가져오기: /2/tweets/counts/all

Client.get_all_tweets_count()

가져오기: /2/tweets/counts/recent

Client.get_recent_tweets_count()

Tweet lookup

가져오기: /2/tweets/:id

Client.get_tweet()

가져오기: /2/tweets

Client.get_tweets()

사용자

Blocks

가져오기: /2/users/:id/blocking

Client.get_blocked()

Follows

삭제: /2/users/:source_user_id/following/:target_user_id

Client.unfollow_user()

가져오기: /2/users/:id/followers

Client.get_users_followers()

가져오기: /2/users/:id/following

Client.get_users_following()

게시: /2/users/:id/following

Client.follow_user()

Mutes

삭제: /2/users/:source_user_id/muting/:target_user_id

Client.unmute()

가져오기: /2/users/:id/muting

Client.get_muted()

게시: /2/users/:id/muting

Client.mute()

User lookup

가져오기: /2/users/:id

Client.get_user()

가져오기: /2/users/by/username/:username

Client.get_user()

가져오기: /2/users

Client.get_users()

가져오기: /2/users/by

Client.get_users()

GET /2/users/me

Client.get_me()

스페이스

Search Spaces

가져오기: /2/spaces/search

Client.search_spaces()

Spaces lookup

가져오기: /2/spaces

Client.get_spaces()

가져오기: /2/spaces/:id

Client.get_space()

가져오기: /2/spaces/:id/buyers

Client.get_space_buyers()

GET /2/spaces/:id/tweets

Client.get_space_tweets()

가져오기: /2/spaces/by/creator_ids

Client.get_spaces()

Direct Messages

Direct Messages lookup

GET /2/dm_conversations/:dm_conversation_id/dm_events

Client.get_direct_message_events()

GET /2/dm_conversations/with/:participant_id/dm_events

Client.get_direct_message_events()

GET /2/dm_events

Client.get_direct_message_events()

Manage Direct Messages

POST /2/dm_conversations

Client.create_direct_message_conversation()

POST /2/dm_conversations/:dm_conversation_id/messages

Client.create_direct_message()

POST /2/dm_conversations/with/:participant_id/messages

Client.create_direct_message()

리스트

List Tweets lookup

가져오기: /2/lists/:id/tweets

Client.get_list_tweets()

List follows

삭제: /2/users/:id/followed_lists/:list_id

Client.unfollow_list()

가져오기: /2/lists/:id/followers

Client.get_list_followers()

가져오기: /2/users/:id/followed_lists

Client.get_followed_lists()

게시: /2/users/:id/followed_lists

Client.follow_list()

List lookup

가져오기: /2/lists/:id

Client.get_list()

가져오기: /2/users/:id/owned_lists

Client.get_owned_lists()

List members

삭제: /2/lists/:id/members/:user_id

Client.remove_list_member()

가져오기: /2/lists/:id/members

Client.get_list_members()

가져오기: /2/users/:id/list_memberships

Client.get_list_memberships()

게시: /2/lists/:id/members

Client.add_list_member()

Manage Lists

삭제: /2/lists/:id

Client.delete_list()

게시: /2/lists/:id

Client.update_list()

게시: /2/lists

Client.create_list()

Pinned Lists

삭제: /2/users/:id/pinned_lists/:list_id

Client.unpin_list()

가져오기: /2/users/:id/pinned_lists

Client.get_pinned_lists()

게시: /2/users/:id/pinned_lists

Client.pin_list()

표준 작업(Compliance)

Batch Compliance

가져오기: /2/compliance/jobs

Client.get_compliance_jobs()

가져오기: /2/compliance/jobs/:id

Client.get_compliance_job()

게시: /2/compliance/jobs

Client.create_compliance_job()

트윗

Bookmarks

Client.remove_bookmark(tweet_id)

Allows a user or authenticated user ID to remove a Bookmark of a Tweet.

참고

A request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.8에 추가.

매개변수

tweet_id (int | str) – The ID of the Tweet that you would like the id to remove a Bookmark of.

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/delete-users-id-bookmarks-tweet_id

Client.get_bookmarks(*, expansions=None, max_results=None, media_fields=None, pagination_token=None, place_fields=None, poll_fields=None, tweet_fields=None, user_fields=None)

Allows you to get an authenticated user’s 800 most recent bookmarked Tweets.

참고

A request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.8에 추가.

매개변수
예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/get-users-id-bookmarks

Client.bookmark(tweet_id)

Causes the authenticating user to Bookmark the target Tweet provided in the request body.

참고

A request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.8에 추가.

매개변수

tweet_id (int | str) – The ID of the Tweet that you would like the user id to Bookmark.

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/post-users-id-bookmarks

답글 숨기기

Client.hide_reply(id, *, user_auth=True)

트윗의 답글을 숨깁니다.

버전 4.5에서 변경: Added user_auth parameter

매개변수
  • id (int | str) – 숨길 트윗의 고유 식별자. 대상 트윗은 현재 인증된 사용자애 의해 시작된 트윗 타래에 속해있어야 합니다.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/hide-replies/api-reference/put-tweets-id-hidden

Client.unhide_reply(id, *, user_auth=True)

트윗의 답글 숨김을 해제합니다.

버전 4.5에서 변경: Added user_auth parameter

매개변수
  • id (int | str) – 숨김 해제할 트윗의 고유 식별자. 대상 트윗은 현재 인증된 사용자애 의해 시작된 트윗 타래에 속해있어야 합니다.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/hide-replies/api-reference/put-tweets-id-hidden

마음에 들어요

Client.unlike(tweet_id, *, user_auth=True)

〈마음에 들어요’를 취소합니다.

〈마음에 들어요’를 표시하지 않은 트윗이나, 이미 〈마음에 들어요’를 취소한 트윗에 이 요청을 보내면, 특별한 처리 없이도 요청이 성공합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • tweet_id (int | str) – 〈마음에 들어요’를 취소할 트윗의 ID.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/delete-users-id-likes-tweet_id

Client.get_liking_users(id, *, expansions=None, max_results=None, media_fields=None, pagination_token=None, place_fields=None, poll_fields=None, tweet_fields=None, user_fields=None, user_auth=False)

트윗에 〈마음에 들어요’를 표시한 사용자에 대한 정보를 얻을 수 있습니다.

버전 4.6에서 변경: Added max_results and pagination_token parameters

매개변수
  • id (int | str) – 〈마음에 들어요’를 표시한 사용자 목록을 받아올 트윗의 ID.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 100 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • media_fields (list[str] | str | None) – media_fields

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다. 바로 다음 페이지를 조회하려면 이전 요청에서 반환된 next_token 값을 전달하고, 바로 이전 페이지를 조회하려면 이전 요청에서 반환된 previous_token 값을 전달하면 됩니다.

  • place_fields (list[str] | str | None) – place_fields

  • poll_fields (list[str] | str | None) – poll_fields

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/get-tweets-id-liking_users

Client.get_liked_tweets(id, *, expansions=None, max_results=None, media_fields=None, pagination_token=None, place_fields=None, poll_fields=None, tweet_fields=None, user_fields=None, user_auth=False)

사용자가 〈마음에 들어요’를 표시한 트윗에 대한 정보를 얻을 수 있습니다.

이 엔드포인트를 통해 반환된 트윗은, 프로젝트 수준(Project-level)의 트윗 한도 에 계산됩니다.

매개변수
  • id (int | str) – 〈마음에 들어요’를 표시한 트윗 목록을 가져올 대상 사용자의 ID.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 5에서 100 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • media_fields (list[str] | str | None) – media_fields

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다. 바로 다음 페이지를 조회하려면 이전 요청에서 반환된 next_token 값을 전달하고, 바로 이전 페이지를 조회하려면 이전 요청에서 반환된 previous_token 값을 전달하면 됩니다.

  • place_fields (list[str] | str | None) – place_fields

  • poll_fields (list[str] | str | None) – poll_fields

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/get-users-id-liked_tweets

Client.like(tweet_id, *, user_auth=True)

트윗에 〈마음에 들어요’를 표시합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • tweet_id (int | str) – 〈마음에 들어요’를 표시할 트윗의 ID.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/post-users-id-likes

트윗 관리

Client.delete_tweet(id, *, user_auth=True)

현재 인증된 사용자의 트윗을 삭제합니다.

버전 4.3에 추가.

버전 4.5에서 변경: Added user_auth parameter

매개변수
  • id (int | str) – 삭제하려는 트윗의 ID.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/delete-tweets-id

Client.create_tweet(*, direct_message_deep_link=None, for_super_followers_only=None, place_id=None, media_ids=None, media_tagged_user_ids=None, poll_duration_minutes=None, poll_options=None, quote_tweet_id=None, exclude_reply_user_ids=None, in_reply_to_tweet_id=None, reply_settings=None, text=None, user_auth=True)

현재 인증된 사용자로서 트윗을 작성합니다.

버전 4.3에 추가.

버전 4.5에서 변경: Added user_auth parameter

매개변수
  • direct_message_deep_link (str | None) – 계정과의 1:1 쪽지 링크를 트윗함.

  • for_super_followers_only (bool | None) – 슈퍼 팔로워 전용 트윗을 작성할지의 여부.

  • place_id (str | None) – 트윗에 포함될 위치의 ID값.

  • media_ids (list[int | str] | None) – 트윗에 포함할 미디어의 ID. 요청이 tagged_user_ids 값을 포함하고 있는 경우에만 필수가 됩니다.

  • media_tagged_user_ids (list[int | str] | None) – 트윗 미디어에 태그할 사용자들의 ID 목록. 태그하려는 사용자가 사진 태그를 허용하지 않은 경우, 트윗이 성공적으로 작성되더라도 태그된 사용자 목록에 이름이 표시되지 않습니다.

  • poll_duration_minutes (int | None) – 투표가 포함된 트윗의 투표 기간. 요청이 poll.options 값을 포함하고 있는 경우에만 필수가 됩니다.

  • poll_options (list[str] | None) – 투표를 포함한 트윗의, 투표 항목 목록

  • quote_tweet_id (int | str | None) – 인용 리트윗하려는 트윗의 링크.

  • exclude_reply_user_ids (list[int | str] | None) – 답글에서 제외할 사용자의 ID 목록.

  • in_reply_to_tweet_id (int | str | None) – 답글을 작성할 대상 트윗의 ID. 요청에 exclude_reply_user_ids 값이 포함되어 있는 경우, 이 in_reply_to_tweet_id 가 반드시 포함되어야 함에 유의하시기 바랍니다.

  • reply_settings (str | None) – 답글을 작성할 수 있는 사용자를 설정 합니다. 《mentionedUsers》(내가 멘션하는 사람들만), 《following》(내가 팔로우하는 사람들) 만 입력할 수 있으며, 따로 지정하지 않으면 《모든 사람 답글 작성 가능》으로 설정됩니다.

  • text (str | None) – 트윗의 본문 텍스트. 트윗에 media.media_ids 가 포함되어 있지 않은 경우, 이 값은 필수가 됩니다.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets

Quote Tweets

Client.get_quote_tweets(id, *, exclude=None, expansions=None, max_results=None, media_fields=None, pagination_token=None, place_fields=None, poll_fields=None, tweet_fields=None, user_fields=None, user_auth=False)

Returns Quote Tweets for a Tweet specified by the requested Tweet ID.

이 엔드포인트를 통해 반환된 트윗은, 프로젝트 수준(Project-level)의 트윗 한도 에 계산됩니다.

버전 4.7에 추가.

버전 4.11에서 변경: Added exclude parameter

매개변수
  • id (int | str) – Unique identifier of the Tweet to request.

  • exclude (list[str] | str | None) – Comma-separated list of the types of Tweets to exclude from the response.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – Specifies the number of Tweets to try and retrieve, up to a maximum of 100 per distinct request. By default, 10 results are returned if this parameter is not supplied. The minimum permitted value is 10. It is possible to receive less than the max_results per request throughout the pagination process.

  • media_fields (list[str] | str | None) – media_fields

  • pagination_token (str | None) – This parameter is used to move forwards through 〈pages〉 of results, based on the value of the next_token. The value used with the parameter is pulled directly from the response provided by the API, and should not be modified.

  • place_fields (list[str] | str | None) – place_fields

  • poll_fields (list[str] | str | None) – poll_fields

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/quote-tweets/api-reference/get-tweets-id-quote_tweets

리트윗

Client.unretweet(source_tweet_id, *, user_auth=True)

현재 인증된 사용자로서 리트윗을 취소합니다.

리트윗하지 않은 트윗이나, 이미 리트윗을 취소한 트윗에 이 요청을 보내면, 특별한 처리 없이도 요청이 성공합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • source_tweet_id (int | str) – 리트윗 취소할 트윗의 ID.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/api-reference/delete-users-id-retweets-tweet_id

Client.get_retweeters(id, *, expansions=None, max_results=None, media_fields=None, pagination_token=None, place_fields=None, poll_fields=None, tweet_fields=None, user_fields=None, user_auth=False)

트윗을 리트윗한 사용자들에 대한 정보를 얻을 수 있습니다.

버전 4.6에서 변경: Added max_results and pagination_token parameters

매개변수
  • id (int | str) – 리트윗한 사용자 목록을 받아올 트윗의 ID.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 100 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • media_fields (list[str] | str | None) – media_fields

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다. 바로 다음 페이지를 조회하려면 이전 요청에서 반환된 next_token 값을 전달하고, 바로 이전 페이지를 조회하려면 이전 요청에서 반환된 previous_token 값을 전달하면 됩니다.

  • place_fields (list[str] | str | None) – place_fields

  • poll_fields (list[str] | str | None) – poll_fields

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/api-reference/get-tweets-id-retweeted_by

Client.retweet(tweet_id, *, user_auth=True)

지정한 트윗을 현재 인증된 사용자로서 리트윗합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • tweet_id (int | str) – 리트윗하려는 트윗의 ID.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/api-reference/post-users-id-retweets

트윗 검색

Client.search_all_tweets(query, *, end_time=None, expansions=None, max_results=None, media_fields=None, next_token=None, place_fields=None, poll_fields=None, since_id=None, sort_order=None, start_time=None, tweet_fields=None, until_id=None, user_fields=None)

이 엔드포인트는 학술 연구 제품 트랙 사용이 승인된 사용자만 사용할 수 있습니다.

이 전체 아카이브 검색 엔드포인트는 모든 공개 트윗의 전체 기록 중 검색 쿼리와 맞는 전체 트윗을 반환합니다. 범위는 트위터의 첫 번째 트윗부터이며, 이는 2006년 3월 26일에 작성되었습니다.

이 엔드포인트를 통해 반환된 트윗은, 프로젝트 수준(Project-level)의 트윗 한도 에 계산됩니다.

참고

By default, a request will return Tweets from up to 30 days ago if the start_time parameter is not provided.

버전 4.6에서 변경: Added sort_order parameter

매개변수
  • query (str) – 트윗 검색에 사용할 쿼리. 최대 1024자.

  • end_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴로 입력하는 매개변수. start_time 매개변수와 같이 사용하는 것이 권장됩니다.트윗 검색 기간의 끝을 의미하며, 두 개로 세분화되었고 계산에 기준값을 포함하지 않습니다. (예: 12:00:01로 설정하면 검색 기간에 12:00:00까지만 고려되고 그 다음 초는 고려되지 않음) start_time 매개변수가 주어지지 않은 경우, end_time 으로부터 30일 전까지가 검색 기간이 됩니다. 이 매개변수가 지정되지 않은 경우의 기본값은 〈현재 시점으로부터 30초 전’입니다.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 요청당 반환받을 결과의 수. 10부터 트위터 시스템 제한 수치 (현재 500) 사이의 값이며, 기본값은 10입니다. (요청 당 10개의 결과 반환)

  • media_fields (list[str] | str | None) – media_fields

  • next_token (str | None) – 이 매개변수는 결과의 다음 〈page〉 (페이지) 를 가져오는 데 사용됩니다. 이 매개변수의 값은 API에서 제공된 값으로만 사용 가능하며, 이는 수정할 수 없습니다. 자세한 사항은 Pagination 페이지를 참고하시기 바랍니다.

  • place_fields (list[str] | str | None) – place_fields

  • poll_fields (list[str] | str | None) – poll_fields

  • since_id (int | str | None) – 지정한 ID값보다 더 큰 ID값을 가지는 (즉, 더 최근의) 트윗들만 검색 결과에 포함합니다. ID값은 비포함적으로 계산됩니다(〈초과’를 의미, 즉 기준값을 포함하지 않음). 같은 요청에 start_time 값을 같이 전달할 경우, since_id 값만 사용됩니다.

  • sort_order (str | None) – This parameter is used to specify the order in which you want the Tweets returned. By default, a request will return the most recent Tweets first (sorted by recency).

  • start_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗 검색 범위의 시작점을 지정하는 UTC 타임스탬프값입니다. 포함적으로 계산되며(〈이상’을 의미, 즉 기준값을 포함 - 예: 12:00:01로 지정하면 01초도 검색 범위에 포함됨), 이 매개변수에 값을 지정하지 않으면 기본적으로 30일 이전까지의 결과를 반환합니다.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • until_id (int | str | None) – 지정한 ID값보다 더 작은 ID값을 가지는 (즉, 더 이전의) 트윗들만 검색 결과에 포함합니다. ID값은 비포함적으로 계산됩니다(〈미만’을 의미, 즉 기준값을 포함하지 않음). 같은 요청에 since_id 값을 같이 전달할 경우, since_id 값만 사용됩니다.

  • user_fields (list[str] | str | None) – user_fields

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-all

Client.search_recent_tweets(query, *, end_time=None, expansions=None, max_results=None, media_fields=None, next_token=None, place_fields=None, poll_fields=None, since_id=None, sort_order=None, start_time=None, tweet_fields=None, until_id=None, user_fields=None, user_auth=False)

이 〈최근 검색〉 엔드포인트는 검색 조건과 일치하는, 최근 7일간의 트윗을 반환합니다.

이 엔드포인트를 통해 반환된 트윗은, 프로젝트 수준(Project-level)의 트윗 한도 에 계산됩니다.

버전 4.6에서 변경: Added sort_order parameter

매개변수
  • query (str) – 트윗 검색에 사용할 쿼리(조건). 일반(Standard) 프로젝트 를 기본(Basic) 권한(Access level) 에서 사용 중인 경우, 기본적인 연산자 를 포함해 최대 512자까지의 쿼리를 사용할 수 있습니다. 학술 연구용 프로젝트 를 기본 권한(Basic access level) 에서 사용 중인 경우, 기본적인 연산자를 포함해 최대 1,024자까지의 쿼리를 사용할 수 있습니다.

  • end_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗 검색 범위의 끝점을 지정하는 UTC 타임스탬프값입니다. 이분법적·비포함적으로 계산되며(〈미만’을 의미, 즉 기준값을 포함하지 않음 - 예: 12:00:01로 지정하면 01초는 검색 범위에서 제외됨), 이 매개변수에 값을 지정하지 않으면 기본적으로 30초 이전까지의 결과를 반환합니다.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 요청 당 반환받을 결과의 수. 10 이상 100 이하의 자연수로 입력해야 하며, 값을 따로 지정하지 않으면 기본적으로 요청 당 10개의 결과를 반환합니다.

  • media_fields (list[str] | str | None) – media_fields

  • next_token (str | None) – 반환받은 결과의 다음 〈페이지’를 가져올때 사용되는 매개변수. 이 매개변수의 값은 API에서 제공된 값으로만 사용 가능하며, 이는 수정할 수 없습니다.

  • place_fields (list[str] | str | None) – place_fields

  • poll_fields (list[str] | str | None) – poll_fields

  • since_id (int | str | None) – 지정한 ID값보다 더 큰 ID값을 가지는 (즉, 더 최근의) 트윗들만 검색 결과에 포함합니다. ID값은 비포함적으로 계산됩니다(〈초과’를 의미, 즉 기준값을 포함하지 않음). 같은 요청에 start_time 값을 같이 전달할 경우, since_id 값만 사용됩니다.

  • sort_order (str | None) – This parameter is used to specify the order in which you want the Tweets returned. By default, a request will return the most recent Tweets first (sorted by recency).

  • start_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗 검색 범위의 시작점(단, 최근 7일 이내)을 지정하는 UTC 타임스탬프값입니다. 이분법적·포함적으로 계산되며(〈이상’을 의미, 즉 기준값을 포함함 - 예: 12:00:01로 지정하면 01초가 검색 범위에 포함됨), 이 매개변수에 값을 지정하지 않으면 기본적으로 현재로부터 7일 이전까지의 결과를 반환합니다. 같은 요청에 since_id 값을 같이 전달할 경우, since_id 값만 사용됩니다.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • until_id (int | str | None) – 지정한 ID값보다 더 작은 ID값을 가지는 (즉, 더 이전의) 트윗들만 검색 결과에 포함합니다. ID값은 비포함적으로 계산됩니다(〈미만’을 의미, 즉 기준값을 포함하지 않음).

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent

타임라인

Client.get_users_mentions(id, *, end_time=None, expansions=None, max_results=None, media_fields=None, pagination_token=None, place_fields=None, poll_fields=None, since_id=None, start_time=None, tweet_fields=None, until_id=None, user_fields=None, user_auth=False)

지정한 사용자에게 멘션하고 있는 트윗을 반환합니다. 따로 값을 지정하지 않으면, 요청당 최근 10개의 트윗을 반환합니다. 페이지화(Pagination)를 이용하면, 최대 최근 800개의 결과를 가져올 수 있습니다.

이 엔드포인트를 통해 반환된 트윗은, 프로젝트 수준(Project-level)의 트윗 한도 에 계산됩니다.

매개변수
  • id (int | str) – 지정할 사용자의 고유 ID값. 사용자의 ID값은 user/lookup 엔드포인트를 이용해 참조해올 수 있습니다. 트위터 ID값에 대한 자세한 설명은 여기 를 참고하세요.

  • end_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗 검색 범위의 시작점을 지정하는 UTC 타임스탬프값입니다. 이분법적·포함적으로 계산됩니다(〈이상’을 의미, 즉 기준값을 포함함 - 예: 12:00:01로 지정하면 01초는 검색 범위에 포함됨). 밀리세컨드값을 지원하지 않습니다.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 요청 당 가져올 트윗의 개수(최대 100개)를 지정할 수 있는 매개변수. 따로 설정하지 않으면 기본적으로 요청 당 최대 10개의 결과만 반환하며, 최솟값은 5입니다. 페이지화(Pagination)를 이용해 요청당 max_results 보다 적은 결과값을 받아오는 것이 가능합니다.

  • media_fields (list[str] | str | None) – media_fields

  • pagination_token (str | None) – 이 매개변수는 next_token 이나 previous_token 값을 이용해, 결과값의 이전 혹은 다음 페이지를 조회하는 데 사용되는 매개변수입니다. 이 매개변수의 값은 API에서 제공된 값으로만 사용 가능하며, 이는 수정할 수 없습니다.

  • place_fields (list[str] | str | None) – place_fields

  • poll_fields (list[str] | str | None) – poll_fields

  • since_id (int | str | None) – 지정한 ID값보다 더 큰 ID값을 가지는 (즉, 더 최근의) 트윗들만 검색 결과에 포함합니다. 단, 트위터 API를 통해 가져올 수 있는 트윗 수에 한계가 있다는 것을 유의해야 합니다. 만약 이 값 때문에 API 호출 제한에 도달할 경우, 이 값인 since_id 가 가능한 선에서 최대한 작은(즉, 최대한 예전의) ID값으로 강제 변경됩니다. 트위터 ID값에 대한 자세한 설명은 여기 를 참고하세요.

  • start_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗 검색 범위의 시작점을 지정하는 UTC 타임스탬프값입니다. 이분법적·포함적으로 계산됩니다(〈이상’을 의미, 즉 기준값을 포함함 - 예: 12:00:01로 지정하면 01초는 검색 범위에 포함됨). 밀리세컨드값을 지원하지 않습니다.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • until_id (int | str | None) – 지정한 ID값보다 더 작은 ID값을 가지는 (즉, 더 오래된) 트윗들만 검색 결과에 포함합니다. 단, 트위터 API를 통해 가져올 수 있는 트윗 수에 한계가 있다는 것을 유의해야 합니다. 만약 이 값 때문에 API 호출 제한에 도달할 경우, 이 값인 until_id 가 가능한 선에서 약간 더 큰(즉, 최대한 오래된) ID값으로 강제 변경됩니다. 트위터 ID값에 대한 자세한 설명은 여기 를 참고하세요.

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/api-reference/get-users-id-mentions

Client.get_home_timeline(*, end_time=None, exclude=None, expansions=None, max_results=None, media_fields=None, pagination_token=None, place_fields=None, poll_fields=None, since_id=None, start_time=None, tweet_fields=None, until_id=None, user_fields=None, user_auth=True)

Allows you to retrieve a collection of the most recent Tweets and Retweets posted by you and users you follow. This endpoint returns up to the last 3200 Tweets.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

매개변수
  • end_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗 검색 범위의 시작점을 지정하는 UTC 타임스탬프값입니다. 이분법적·포함적으로 계산됩니다(〈이상’을 의미, 즉 기준값을 포함함 - 예: 12:00:01로 지정하면 01초는 검색 범위에 포함됨). 밀리세컨드값을 지원하지 않습니다.

  • exclude (list[str] | str | None) – Comma-separated list of the types of Tweets to exclude from the response.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – Specifies the number of Tweets to try and retrieve, up to a maximum of 100 per distinct request. By default, 100 results are returned if this parameter is not supplied. The minimum permitted value is 1. It is possible to receive less than the max_results per request throughout the pagination process.

  • media_fields (list[str] | str | None) – media_fields

  • pagination_token (str | None) – 이 매개변수는 next_token 이나 previous_token 값을 이용해, 결과값의 이전 혹은 다음 페이지를 조회하는 데 사용되는 매개변수입니다. 이 매개변수의 값은 API에서 제공된 값으로만 사용 가능하며, 이는 수정할 수 없습니다.

  • place_fields (list[str] | str | None) – place_fields

  • poll_fields (list[str] | str | None) – poll_fields

  • since_id (int | str | None) – 지정한 ID값보다 더 큰 ID값을 가지는 (즉, 더 최근의) 트윗들만 검색 결과에 포함합니다. 단, 트위터 API를 통해 가져올 수 있는 트윗 수에 한계가 있다는 것을 유의해야 합니다. 만약 이 값 때문에 API 호출 제한에 도달할 경우, 이 값인 since_id 가 가능한 선에서 최대한 작은(즉, 최대한 예전의) ID값으로 강제 변경됩니다. 트위터 ID값에 대한 자세한 설명은 여기 를 참고하세요.

  • start_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗 검색 범위의 시작점을 지정하는 UTC 타임스탬프값입니다. 이분법적·포함적으로 계산됩니다(〈이상’을 의미, 즉 기준값을 포함함 - 예: 12:00:01로 지정하면 01초는 검색 범위에 포함됨). 밀리세컨드값을 지원하지 않습니다.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • until_id (int | str | None) – Returns results with a Tweet ID less than (that is, older than) the specified 〈until〉 Tweet ID. There are limits to the number of Tweets that can be accessed through the API. If the limit of Tweets has occurred since the until_id, the until_id will be forced to the most recent ID available. More information on Twitter IDs is here.

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/api-reference/get-users-id-reverse-chronological

Client.get_users_tweets(id, *, end_time=None, exclude=None, expansions=None, max_results=None, media_fields=None, pagination_token=None, place_fields=None, poll_fields=None, since_id=None, start_time=None, tweet_fields=None, until_id=None, user_fields=None, user_auth=False)

ID로 지정한 사용자가 작성 또는 리트윗한 트윗들을 반환합니다. 기본적으로, 요청 당 10개의 결과를 반환합니다. 페이지화(Pagination)를 이용하면, 최대 최근 3,200개의 결과를 가져올 수 있습니다.

이 엔드포인트를 통해 반환된 트윗은, 프로젝트 수준(Project-level)의 트윗 한도 에 계산됩니다.

매개변수
  • id (int | str) – 지정할 사용자의 고유 ID값. 사용자의 ID값은 user/lookup 엔드포인트를 이용해 참조해올 수 있습니다. 트위터 ID값에 대한 자세한 설명은 여기 를 참고하세요.

  • end_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗 검색 범위의 끝점을 지정하는 UTC 타임스탬프값입니다. 최대 최근 3200개의 결과를 받아올 수 있습니다. 이분법적·포함적으로 계산되며(〈이하’를 의미, 즉 기준값을 포함함 - 예: 12:00:01로 지정하면 01초는 검색 범위에 포함됨), 최솟값은 2010-11-06T00:00:01Z 입니다. 밀리세컨드값을 지원하지 않습니다.

  • exclude (list[str] | str | None) – 결과값에서 제외할 트윗 종류를 구분하는, 쉼표(,)로 구분된 리스트입니다. exclude=retweets 를 사용해도, 최대 3200개까지의 결과를 반환받을 수 있습니다. 단, exclude=replies 를 같이 사용하면, 최대 800개까지의 결과만을 반환받을 수 있습니다.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 요청 당 가져올 트윗의 개수(최대 100개)를 지정할 수 있는 매개변수. 따로 설정하지 않으면 기본적으로 요청 당 최대 10개의 결과만 반환하며, 최솟값은 5입니다. 페이지화(Pagination)를 이용해 요청당 max_results 보다 적은 결과값을 받아오는 것이 가능합니다.

  • media_fields (list[str] | str | None) – media_fields

  • pagination_token (str | None) – 이 매개변수는 next_token 이나 previous_token 값을 이용해, 결과값의 이전 혹은 다음 페이지를 조회하는 데 사용되는 매개변수입니다. 이 매개변수의 값은 API에서 제공된 값으로만 사용 가능하며, 이는 수정할 수 없습니다.

  • place_fields (list[str] | str | None) – place_fields

  • poll_fields (list[str] | str | None) – poll_fields

  • since_id (int | str | None) – 지정한 ID값보다 더 큰 ID값을 가지는 (즉, 더 최근의) 트윗들만 결과에 포함합니다. ID값은 비포함적으로 계산됩니다(〈초과’를 의미, 즉 기준값을 포함하지 않음). 같은 요청에 start_time 값을 같이 전달할 경우, since_id 값만 사용됩니다.

  • start_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗을 가져올 범위의 시작점을 지정하는 UTC 타임스탬프값입니다. 최대 최근 3200개의 트윗만을 가져올 수 있습니다. 이분법적·포함적으로 계산되며(〈이상’을 의미, 즉 기준값을 포함 - 예: 12:00:01로 지정하면 01초도 검색 범위에 포함됨), 최솟값은 2010-11-06T00:00:00Z 입니다. 밀리세컨드값을 지원하지 않습니다.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • until_id (int | str | None) – 지정한 ID값보다 더 작은 ID값을 가지는 (즉, 더 오래된) 트윗들만 결과에 포함합니다. 최대 최근 3200개의 트윗만을 가져올 수 있습니다. 비포함적으로 계산됩니다. (〈미만’을 의미) 만약 이 값 때문에 API 호출 제한에 도달할 경우, 이 값인 until_id 가 가능한 선에서 약간 더 큰(즉, 최대한 오래된) ID값으로 강제 변경됩니다.

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/api-reference/get-users-id-tweets

트윗 카운트

Client.get_all_tweets_count(query, *, end_time=None, granularity=None, next_token=None, since_id=None, start_time=None, until_id=None)

이 엔드포인트는 학술 연구 제품 트랙 사용이 승인된 사용자만 사용할 수 있습니다.

이 전체 아카이브 검색 엔드포인트는 모든 공개 트윗의 전체 기록 중 검색 쿼리와 맞는 전체 트윗을 반환합니다. 범위는 트위터의 첫 번째 트윗부터이며, 이는 2006년 3월 26일에 작성되었습니다.

매개변수
  • query (str) – 트윗 검색에 사용할 쿼리. 최대 1024자.

  • end_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴로 입력하는 매개변수. start_time 매개변수와 같이 사용하는 것이 권장됩니다.트윗 검색 기간의 끝을 의미하며, 두 개로 세분화되었고 계산에 기준값을 포함하지 않습니다. (예: 12:00:01로 설정하면 검색 기간에 12:00:00까지만 고려되고 그 다음 초는 고려되지 않음) start_time 매개변수가 주어지지 않은 경우, end_time 으로부터 30일 전까지가 검색 기간이 됩니다. 이 매개변수가 지정되지 않은 경우의 기본값은 〈현재 시점으로부터 30초 전’입니다.

  • granularity (str | None) – This is the granularity that you want the timeseries count data to be grouped by. You can request minute, hour, or day granularity. The default granularity, if not specified is hour.

  • next_token (str | None) – 이 매개변수는 결과의 다음 〈page〉 (페이지) 를 가져오는 데 사용됩니다. 이 매개변수의 값은 API에서 제공된 값으로만 사용 가능하며, 이는 수정할 수 없습니다. 자세한 사항은 Pagination 페이지를 참고하시기 바랍니다.

  • since_id (int | str | None) – 지정한 ID값보다 더 큰 ID값을 가지는 (즉, 더 최근의) 트윗들만 검색 결과에 포함합니다. ID값은 비포함적으로 계산됩니다(〈초과’를 의미, 즉 기준값을 포함하지 않음). 같은 요청에 start_time 값을 같이 전달할 경우, since_id 값만 사용됩니다.

  • start_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗 검색 범위의 시작점을 지정하는 UTC 타임스탬프값입니다. 포함적으로 계산되며(〈이상’을 의미, 즉 기준값을 포함 - 예: 12:00:01로 지정하면 01초도 검색 범위에 포함됨), 이 매개변수에 값을 지정하지 않으면 기본적으로 30일 이전까지의 결과를 반환합니다.

  • until_id (int | str | None) – 지정한 ID값보다 더 작은 ID값을 가지는 (즉, 더 이전의) 트윗들만 검색 결과에 포함합니다. ID값은 비포함적으로 계산됩니다(〈미만’을 의미, 즉 기준값을 포함하지 않음). 같은 요청에 since_id 값을 같이 전달할 경우, since_id 값만 사용됩니다.

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-all

Client.get_recent_tweets_count(query, *, end_time=None, granularity=None, since_id=None, start_time=None, until_id=None)

이 엔드포인트는 지정한 조건에 맞는 최근 7일간의 트윗 관련 데이터를 반환합니다.

매개변수
  • query (str) – 트윗 검색에 사용할 쿼리(조건). 일반(Standard) 프로젝트 를 기본(Basic) 권한(Access level) 에서 사용 중인 경우, 기본적인 연산자 를 포함해 최대 512자까지의 쿼리를 사용할 수 있습니다. 학술 연구용 프로젝트 를 기본 권한(Basic access level) 에서 사용 중인 경우, 기본적인 연산자를 포함해 최대 1,024자까지의 쿼리를 사용할 수 있습니다.

  • end_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗 검색 범위의 끝점을 지정하는 UTC 타임스탬프값입니다. 이분법적·비포함적으로 계산되며(〈미만’을 의미, 즉 기준값을 포함하지 않음 - 예: 12:00:01로 지정하면 01초는 검색 범위에서 제외됨), 이 매개변수에 값을 지정하지 않으면 기본적으로 30초 이전까지의 결과를 반환합니다.

  • granularity (str | None) – This is the granularity that you want the timeseries count data to be grouped by. You can request minute, hour, or day granularity. The default granularity, if not specified is hour.

  • since_id (int | str | None) – 지정한 ID값보다 더 큰 ID값을 가지는 (즉, 더 최근의) 트윗들만 검색 결과에 포함합니다. ID값은 비포함적으로 계산됩니다(〈초과’를 의미, 즉 기준값을 포함하지 않음). 같은 요청에 start_time 값을 같이 전달할 경우, since_id 값만 사용됩니다.

  • start_time (datetime.datetime | str | None) – YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339) 꼴의 값. 트윗 검색 범위의 시작점(단, 최근 7일 이내)을 지정하는 UTC 타임스탬프값입니다. 이분법적·포함적으로 계산되며(〈이상’을 의미, 즉 기준값을 포함함 - 예: 12:00:01로 지정하면 01초가 검색 범위에 포함됨), 이 매개변수에 값을 지정하지 않으면 기본적으로 현재로부터 7일 이전까지의 결과를 반환합니다. 같은 요청에 since_id 값을 같이 전달할 경우, since_id 값만 사용됩니다.

  • until_id (int | str | None) – 지정한 ID값보다 더 작은 ID값을 가지는 (즉, 더 이전의) 트윗들만 검색 결과에 포함합니다. ID값은 비포함적으로 계산됩니다(〈미만’을 의미, 즉 기준값을 포함하지 않음).

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-recent

트윗 자세히보기

Client.get_tweet(id, *, expansions=None, media_fields=None, place_fields=None, poll_fields=None, tweet_fields=None, user_fields=None, user_auth=False)

ID로 지정한 하나의 트윗에 대한 다양한 정보를 반환합니다.

매개변수
반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets-id

Client.get_tweets(ids, *, expansions=None, media_fields=None, place_fields=None, poll_fields=None, tweet_fields=None, user_fields=None, user_auth=False)

ID값으로 지정한 하나의 트윗 또는 ID값의 목록으로 지정한 트윗들에 대한 다양한 정보를 반환합니다.

매개변수
반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets

사용자

차단

Client.get_blocked(*, expansions=None, max_results=None, pagination_token=None, tweet_fields=None, user_fields=None, user_auth=True)

현재 인증된 사용자가 차단한 사용자의 리스트를 반환합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 1000 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/users/blocks/api-reference/get-users-blocking

팔로우

Client.unfollow_user(target_user_id, *, user_auth=True)

지정한 사용자를 팔로우 해제합니다.

팔로우 해제하려는 사용자가 이미 팔로우 해제되어 있거나, 팔로우하고 있지 않던 경우 특별한 처리 없이도 요청이 성공합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.2에서 변경: Client.unfollow() 로부터 이름 변경됨

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • target_user_id (int | str) – 팔로우 해제하려는 사용자의 ID값.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/delete-users-source_id-following

Client.unfollow(target_user_id, *, user_auth=True)

다음 함수와 동일함(Alias): Client.unfollow_user()

버전 4.2부터 폐지됨: Client.unfollow_user() 를 대신 사용해야 함

Client.get_users_followers(id, *, expansions=None, max_results=None, pagination_token=None, tweet_fields=None, user_fields=None, user_auth=False)

ID로 지정한 사용자의 팔로워 리스트를 반환합니다.

참고

The Twitter API endpoint that this method uses has been removed from the Basic and Pro tiers 1.

매개변수
  • id (int | str) – 팔로워 리스트를 가져오려는 사용자의 ID값.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 1000 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다. 바로 다음 페이지를 조회하려면 이전 요청에서 반환된 next_token 값을 전달하고, 바로 이전 페이지를 조회하려면 이전 요청에서 반환된 previous_token 값을 전달하면 됩니다.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-followers

Client.get_users_following(id, *, expansions=None, max_results=None, pagination_token=None, tweet_fields=None, user_fields=None, user_auth=False)

ID로 지정한 사용자가 팔로우중인 사용자들의 리스트를 반환합니다.

참고

The Twitter API endpoint that this method uses has been removed from the Basic and Pro tiers 1.

매개변수
  • id (int | str) – 팔로잉 리스트를 가져오려는 사용자의 ID값.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 1000 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다. 바로 다음 페이지를 조회하려면 이전 요청에서 반환된 next_token 값을 전달하고, 바로 이전 페이지를 조회하려면 이전 요청에서 반환된 previous_token 값을 전달하면 됩니다.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-following

Client.follow_user(target_user_id, *, user_auth=True)

지정한 사용자를 팔로우합니다.

대상 사용자가 비공개 계정인 경우, 이 엔드포인트는 팔로우 요청을 대신 보냅니다.

팔로우하려는 사용자가 이미 팔로우 되어 있거나, 대상 사용자가 비공개 계정이어서 팔로우 요청을 대신 보내는 경우 특별한 처리 없이도 요청이 성공합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.2에서 변경: Client.follow() 로부터 이름 변경됨

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • target_user_id (int | str) – 팔로우하려는 사용자의 ID값.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/post-users-source_user_id-following

Client.follow(target_user_id, *, user_auth=True)

다음 함수와 동일함(Alias): Client.follow_user()

버전 4.2부터 폐지됨: Client.follow_user() 를 대신 사용해야 함

뮤트

Client.unmute(target_user_id, *, user_auth=True)

지정한 사용자를 뮤트 해제합니다.

뮤트 해제하려는 사용자가 이미 뮤트 해제되어 있거나, 뮤트하고 있지 않던 경우 특별한 처리 없이도 요청이 성공합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • target_user_id (int | str) – 뮤트 해제하려는 사용자의 ID값.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/users/mutes/api-reference/delete-users-user_id-muting

Client.get_muted(*, expansions=None, max_results=None, pagination_token=None, tweet_fields=None, user_fields=None, user_auth=True)

현재 인증된 사용자가 뮤트한 사용자의 리스트를 반환합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.1에 추가.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 1000 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/users/mutes/api-reference/get-users-muting

Client.mute(target_user_id, *, user_auth=True)

지정한 사용자를 뮤트합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • target_user_id (int | str) – 뮤트하려는 사용자의 ID값.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/users/mutes/api-reference/post-users-user_id-muting

사용자 자세히보기

Client.get_user(*, id=None, username=None, expansions=None, tweet_fields=None, user_fields=None, user_auth=False)

ID 또는 사용자명(username)로 지정한 하나의 사용자에 대한 다양한 정보를 반환합니다.

매개변수
예외 발생

TypeError – ID값과 사용자명(username)이 둘 다 전달되지 않았거나, 둘 다 전달된 경우

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-id https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-by-username-username

Client.get_users(*, ids=None, usernames=None, expansions=None, tweet_fields=None, user_fields=None, user_auth=False)

ID값 및 사용자명(username)으로 지정한 하나의 사용자 또는 ID값 및 사용자명(username)의 목록으로 지정한 사용자들에 대한 다양한 정보를 반환합니다.

매개변수
  • ids (list[int | str] | str | None) – 쉼표(,)로 구분된 사용자 ID값의 리스트. 요청 당 최대 100개까지만 전달할 수 있습니다. 값과 쉼표(,) 사이에 공백 문자를 넣지 않도록 유의하시기 바랍니다.

  • usernames (list[str] | str | None) – 쉼표(,)로 구분된 사용자명(username)의 리스트. 요청 당 최대 100개까지만 전달할 수 있습니다. 값과 쉼표(,) 사이에 공백 문자를 넣지 않도록 유의하시기 바랍니다.

  • expansions (list[str] | str | None) – expansions Parameter

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – ID값과 사용자명(username)이 둘 다 전달되지 않았거나, 둘 다 전달된 경우

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-by

Client.get_me(*, expansions=None, tweet_fields=None, user_fields=None, user_auth=True)

Returns information about an authorized user.

버전 4.5에 추가.

매개변수
반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-me

스페이스

스페이스 검색

Client.search_spaces(query, *, expansions=None, max_results=None, space_fields=None, state=None, user_fields=None)

지정한 조건에 맞는, 진행 중이거나 진행 예정인 스페이스들을 반환합니다.

버전 4.1에 추가.

버전 4.2에서 변경: 이제 state 가 필수 매개변수가 아님 (Optional)

매개변수
  • query (str) – 스페이스 검색 조건. 스페이스의 제목에서 찾을 문자열을 입력하면 되고, 멘션이나 해시태그도 문자열 형태로 전달할 수 있습니다.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 요청당 반환받을 결과 수의 최댓값. 1에서 100 사이의 자연수로 지정해야 합니다.

  • space_fields (list[str] | str | None) – space_fields

  • state (str | None) – 어떤 상태의 스페이스를 반환받을지를 정하는 매개변수. 이 엔드포인트는 기본적으로 모든 스페이스를 반환합니다. live 로 지정하면 현재 진행 중인 스페이스만 반환받을 수 있고, scheduled 로 지정하면 진행 예정인 스페이스만 반환받을 수 있습니다.

  • user_fields (list[str] | str | None) – user_fields

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/spaces/search/api-reference/get-spaces-search

스페이스 자세히보기

Client.get_spaces(*, ids=None, user_ids=None, expansions=None, space_fields=None, user_fields=None)

여러 개의 진행 중이거나 진행 예정인 스페이스(특정 사용자 ID를 지정하면, 해당 사용자가 개설한 스페이스) 에 대한 다양한 정보를 반환합니다. 이 엔드포인트는 최대 100개의 쉼표(,)로 구분된 사용자 ID나 스페이스를 처리할 수 있습니다.

버전 4.1에 추가.

매개변수
예외 발생

TypeError – ID값과 사용자명(username)이 둘 다 전달되지 않았거나, 둘 다 전달된 경우

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-by-creator-ids

Client.get_space(id, *, expansions=None, space_fields=None, user_fields=None)

ID로 지정한 하나의 스페이스에 대한 다양한 정보를 반환합니다.

버전 4.1에 추가.

매개변수
반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id

Client.get_space_buyers(id, *, expansions=None, media_fields=None, place_fields=None, poll_fields=None, tweet_fields=None, user_fields=None)

지정한 스페이스의 유료 티켓 구매자 리스트를 반환합니다. 현재의 액세스 토큰으로 인증된 사용자가 만든 스페이스에만 사용 가능합니다.

버전 4.4에 추가.

매개변수
반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id-buyers

Client.get_space_tweets(id, *, expansions=None, media_fields=None, place_fields=None, poll_fields=None, tweet_fields=None, user_fields=None)

Returns Tweets shared in the requested Spaces.

버전 4.6에 추가.

매개변수
반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id-tweets

Direct Messages

Direct Messages lookup

Client.get_direct_message_events(*, dm_conversation_id=None, participant_id=None, dm_event_fields=None, event_types=None, expansions=None, max_results=None, media_fields=None, pagination_token=None, tweet_fields=None, user_fields=None, user_auth=True)

If dm_conversation_id is passed, returns a list of Direct Messages within the conversation specified. Messages are returned in reverse chronological order.

If participant_id is passed, returns a list of Direct Messages (DM) events within a 1-1 conversation with the user specified. Messages are returned in reverse chronological order.

If neither is passed, returns a list of Direct Messages for the authenticated user, both sent and received. Direct Message events are returned in reverse chronological order. Supports retrieving events from the previous 30 days.

참고

There is an alias for this method named get_dm_events.

버전 4.12에 추가.

매개변수
  • dm_conversation_id (str | None) – The id of the Direct Message conversation for which events are being retrieved.

  • participant_id (int | str | None) – The participant_id of the user that the authenicating user is having a 1-1 conversation with.

  • dm_event_fields (list[str] | str | None) – Extra fields to include in the event payload. id and event_type are returned by default. The text value isn’t included for ParticipantsJoin and ParticipantsLeave events.

  • event_types (str) – The type of Direct Message event to returm. If not included, all types are returned.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – The maximum number of results to be returned in a page. Must be between 1 and 100. The default is 100.

  • media_fields (list[str] | str | None) – media_fields

  • pagination_token (str | None) – Contains either the next_token or previous_token value.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If both dm_conversation_id and participant_id are passed

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/direct-messages/lookup/api-reference/get-dm_events https://developer.twitter.com/en/docs/twitter-api/direct-messages/lookup/api-reference/get-dm_conversations-with-participant_id-dm_events https://developer.twitter.com/en/docs/twitter-api/direct-messages/lookup/api-reference/get-dm_conversations-dm_conversation_id-dm_events

Manage Direct Messages

Client.create_direct_message(*, dm_conversation_id=None, participant_id=None, media_id=None, text=None, user_auth=True)

If dm_conversation_id is passed, creates a Direct Message on behalf of the authenticated user, and adds it to the specified conversation.

If participant_id is passed, creates a one-to-one Direct Message and adds it to the one-to-one conversation. This method either creates a new one-to-one conversation or retrieves the current conversation and adds the Direct Message to it.

참고

There is an alias for this method named create_dm.

버전 4.12에 추가.

매개변수
  • dm_conversation_id (str | None) – The dm_conversation_id of the conversation to add the Direct Message to. Supports both 1-1 and group conversations.

  • participant_id (int | str | None) – The User ID of the account this one-to-one Direct Message is to be sent to.

  • media_id (int | str | None) – A single Media ID being attached to the Direct Message. This field is required if text is not present. For this launch, only 1 attachment is supported.

  • text (str | None) – Text of the Direct Message being created. This field is required if media_id is not present. Text messages support up to 10,000 characters.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If dm_conversation_id and participant_id are not passed or both are passed

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/direct-messages/manage/api-reference/post-dm_conversations-dm_conversation_id-messages https://developer.twitter.com/en/docs/twitter-api/direct-messages/manage/api-reference/post-dm_conversations-with-participant_id-messages

Client.create_direct_message_conversation(*, media_id=None, text=None, participant_ids, user_auth=True)

Creates a new group conversation and adds a Direct Message to it on behalf of the authenticated user.

참고

There is an alias for this method named create_dm_conversation.

버전 4.12에 추가.

매개변수
  • media_id (int | str | None) – A single Media ID being attached to the Direct Message. This field is required if text is not present. For this launch, only 1 attachment is supported.

  • text (str | None) – Text of the Direct Message being created. This field is required if media_id is not present. Text messages support up to 10,000 characters.

  • participant_ids (list[int | str]) – An array of User IDs that the conversation is created with. Conversations can have up to 50 participants.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/direct-messages/manage/api-reference/post-dm_conversations

리스트

리스트 트윗 자세히보기

Client.get_list_tweets(id, *, expansions=None, max_results=None, media_fields=None, pagination_token=None, place_fields=None, poll_fields=None, tweet_fields=None, user_fields=None, user_auth=False)

지정한 리스트의 트윗 목록을 가져옵니다.

버전 4.4에 추가.

버전 4.10.1에서 변경: Added media_fields, place_fields, and poll_fields parameters

매개변수
  • id (list[str] | str) – 트윗을 가져올 대상 리스트의 ID값.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 100 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • media_fields (list[str] | str | None) – media_fields

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다. 바로 다음 페이지를 조회하려면 이전 요청에서 반환된 next_token 값을 전달하고, 바로 이전 페이지를 조회하려면 이전 요청에서 반환된 previous_token 값을 전달하면 됩니다.

  • place_fields (list[str] | str | None) – place_fields

  • poll_fields (list[str] | str | None) – poll_fields

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/list-tweets/api-reference/get-lists-id-tweets

리스트 구독(Follow)

Client.unfollow_list(list_id, *, user_auth=True)

현재 인증된 사용자로서, 대상 리스트를 구독 해제합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.2에 추가.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • list_id (int | str) – 구독 해제하려는 리스트의 ID값.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/api-reference/delete-users-id-followed-lists-list_id

Client.get_list_followers(id, *, expansions=None, max_results=None, pagination_token=None, tweet_fields=None, user_fields=None, user_auth=False)

지정한 리스트를 구독 중인 사람들의 리스트를 반환합니다.

참고

The Twitter API endpoint that this method uses has been removed from the Basic and Pro tiers 1.

버전 4.4에 추가.

매개변수
  • id (list[str] | str) – 구독 중인 사람들의 리스트를 가져올 대상 리스트의 ID값.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 100 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다. 바로 다음 페이지를 조회하려면 이전 요청에서 반환된 next_token 값을 전달하고, 바로 이전 페이지를 조회하려면 이전 요청에서 반환된 previous_token 값을 전달하면 됩니다.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/api-reference/get-lists-id-followers

Client.get_followed_lists(id, *, expansions=None, list_fields=None, max_results=None, pagination_token=None, user_fields=None, user_auth=False)

지정한 사용자가 구독 중인 모든 리스트를 반환합니다.

참고

The Twitter API endpoint that this method uses has been removed from the Basic and Pro tiers 1.

버전 4.4에 추가.

매개변수
  • id (list[str] | str) – 구독 중인 리스트를 가져올 대상 사용자의 ID값.

  • expansions (list[str] | str | None) – expansions Parameter

  • list_fields (list[str] | str | None) – list_fields

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 100 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다. 바로 다음 페이지를 조회하려면 이전 요청에서 반환된 next_token 값을 전달하고, 바로 이전 페이지를 조회하려면 이전 요청에서 반환된 previous_token 값을 전달하면 됩니다.

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/api-reference/get-users-id-followed_lists

Client.follow_list(list_id, *, user_auth=True)

현재 인증된 사용자로서 대상 리스트를 구독(Follow)합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.2에 추가.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • list_id (int | str) – 구독하려는 대상 리스트의 ID값.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/api-reference/post-users-id-followed-lists

리스트 자세히보기

Client.get_list(id, *, expansions=None, list_fields=None, user_fields=None, user_auth=False)

지정한 하나의 리스트에 대한 다양한 정보를 반환합니다.

버전 4.4에 추가.

매개변수
반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/list-lookup/api-reference/get-lists-id

Client.get_owned_lists(id, *, expansions=None, list_fields=None, max_results=None, pagination_token=None, user_fields=None, user_auth=False)

지정한 사용자가 소유 중인(만든) 모든 리스트를 반환합니다.

버전 4.4에 추가.

매개변수
  • id (list[str] | str) – 소유 중인 리스트를 가져올 대상 사용자의 ID값.

  • expansions (list[str] | str | None) – expansions Parameter

  • list_fields (list[str] | str | None) – list_fields

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 100 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다. 바로 다음 페이지를 조회하려면 이전 요청에서 반환된 next_token 값을 전달하고, 바로 이전 페이지를 조회하려면 이전 요청에서 반환된 previous_token 값을 전달하면 됩니다.

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/list-lookup/api-reference/get-users-id-owned_lists

리스트 구성원

Client.remove_list_member(id, user_id, *, user_auth=True)

현재 인증된 사용자로서, 지정한 사용자를 리스트 구성원에서 제거합니다.

버전 4.2에 추가.

버전 4.5에서 변경: Added user_auth parameter

매개변수
  • id (int | str) – 리스트 구성원을 제거하려는 대상 리스트의 ID값.

  • user_id (int | str) – 리스트 구성원에서 제거하려는 대상 사용자의 ID값.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/list-members/api-reference/delete-lists-id-members-user_id

Client.get_list_members(id, *, expansions=None, max_results=None, pagination_token=None, tweet_fields=None, user_fields=None, user_auth=False)

지정한 리스트의 구성원 리스트를 반환합니다.

버전 4.4에 추가.

매개변수
  • id (list[str] | str) – 구성원 리스트를 가져올 대상 리스트의 ID값.

  • expansions (list[str] | str | None) – expansions Parameter

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 100 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다. 바로 다음 페이지를 조회하려면 이전 요청에서 반환된 next_token 값을 전달하고, 바로 이전 페이지를 조회하려면 이전 요청에서 반환된 previous_token 값을 전달하면 됩니다.

  • tweet_fields (list[str] | str | None) – tweet_fields

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/list-members/api-reference/get-lists-id-members

Client.get_list_memberships(id, *, expansions=None, list_fields=None, max_results=None, pagination_token=None, user_fields=None, user_auth=False)

지정한 사용자가 구성원인 모든 리스트를 반환합니다.

버전 4.4에 추가.

매개변수
  • id (list[str] | str) – 지정한 대상이 구성원인 모든 리스트를 가져올 대상 사용자의 ID값.

  • expansions (list[str] | str | None) – expansions Parameter

  • list_fields (list[str] | str | None) – list_fields

  • max_results (int | None) – 페이지당 반환받을 결과 수의 최댓값. 1에서 100 사이의 자연수로 지정해야 하며, 기본값은 100입니다. (페이지당 100개의 결과 반환)

  • pagination_token (str | None) – 다음 페이지나, 이전 페이지 결과값을 조회하는 데 쓰입니다. 바로 다음 페이지를 조회하려면 이전 요청에서 반환된 next_token 값을 전달하고, 바로 이전 페이지를 조회하려면 이전 요청에서 반환된 previous_token 값을 전달하면 됩니다.

  • user_fields (list[str] | str | None) – user_fields

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/list-members/api-reference/get-users-id-list_memberships

Client.add_list_member(id, user_id, *, user_auth=True)

현재 인증된 사용자로서, 리스트에 구성원을 추가합니다.

버전 4.2에 추가.

버전 4.5에서 변경: Added user_auth parameter

매개변수
  • id (int | str) – 구성원을 추가하려는 대상 리스트의 ID값.

  • user_id (int | str) – 리스트 구성원에 추가하려는 대상 사용자의 ID값.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/list-members/api-reference/post-lists-id-members

리스트 관리

Client.delete_list(id, *, user_auth=True)

현재 인증된 사용자로서, 소유 중인(만든) 리스트를 삭제합니다.

버전 4.2에 추가.

버전 4.5에서 변경: Added user_auth parameter

매개변수
  • id (int | str) – 삭제하려는 대상 리스트의 ID값.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/api-reference/delete-lists-id

Client.update_list(id, *, description=None, name=None, private=None, user_auth=True)

현재 인증된 사용자로서, 소유 중인(만든) 리스트의 메타데이터를 수정합니다.

버전 4.2에 추가.

버전 4.5에서 변경: Added user_auth parameter

매개변수
  • id (int | str) – 갱신할 대상 리스트의 ID값.

  • description (str | None) – 리스트의 설명을 변경합니다.

  • name (str | None) – 리스트의 이름을 변경합니다.

  • private (bool | None) – 리스트를 비공개로 설정할지의 여부.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/api-reference/put-lists-id

Client.create_list(name, *, description=None, private=None, user_auth=True)

현재 인증된 사용자로서 리스트를 만들 수 있도록 합니다.

버전 4.2에 추가.

버전 4.5에서 변경: Added user_auth parameter

매개변수
  • name (str) – 만드려는 리스트의 이름.

  • description (str | None) – 만드려는 리스트의 설명.

  • private (bool | None) – 만드려는 리스트를 비공개로 설정할지의 여부.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/api-reference/post-lists

리스트 고정

Client.unpin_list(list_id, *, user_auth=True)

현재 인증된 사용자로서 리스트를 고정 해제(Unpin)합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.2에 추가.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • list_id (int | str) – 고정 해제하려는 대상 리스트의 ID값.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/api-reference/delete-users-id-pinned-lists-list_id

Client.get_pinned_lists(*, expansions=None, list_fields=None, user_fields=None, user_auth=True)

지정한 사용자가 고정한 리스트를 반환합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.4에 추가.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/api-reference/get-users-id-pinned_lists

Client.pin_list(list_id, *, user_auth=True)

현재 인증된 사용자로서 리스트를 고정(Pin)합니다.

참고

When using OAuth 2.0 Authorization Code Flow with PKCE with user_auth=False, a request is made beforehand to Twitter’s API to determine the authenticating user’s ID. This is cached and only done once per Client instance for each access token used.

버전 4.2에 추가.

버전 4.5에서 변경: Added user_auth parameter

버전 4.8에서 변경: Added support for using OAuth 2.0 Authorization Code Flow with PKCE

버전 4.8에서 변경: Changed to raise TypeError when the access token isn’t set

매개변수
  • list_id (int | str) – 고정하려는 대상 리스트의 ID값.

  • user_auth (bool) – Whether or not to use OAuth 1.0a User Context to authenticate

예외 발생

TypeError – If the access token isn’t set

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/api-reference/post-users-id-pinned-lists

표준 작업(Compliance)

표준 준수 하 일괄 작업(Batch compliance)

Client.get_compliance_jobs(type, *, status=None)

최근 표준 작업의 리스트를 반환합니다.

버전 4.1에 추가.

매개변수
  • type (str) – 트윗이나 사용자 ID 둘 중 하나를 통해 작업별로 구분이 가능합니다. 요청 당 하나의 필터(트윗 또는 사용자)만 지정할 수 있습니다.

  • status (str | None) – 상태에 따라 작업을 구분합니다.요청 당 하나의 필터(트윗 또는 사용자)만 지정할 수 있습니다. 기본값은 all.

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/api-reference/get-compliance-jobs

Client.get_compliance_job(id)

ID값으로 지정한 하나의 표준 작업을 가져옵니다.

버전 4.1에 추가.

매개변수

id (int | str) – 가져오려는 대상 표준 작업의 고유 ID값.

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/api-reference/get-compliance-jobs-id

Client.create_compliance_job(type, *, name=None, resumable=None)

특정 트윗 ID 또는 사용자 ID에 대해 새 표준 작업을 만듭니다.

표준 작업에는 고유 ID값과 경로 URL이 포함됩니다. 경로 URL은 앱에서 사용하는 ID 목록이 포함된 위치를 가리킵니다.

한 번에 하나의 일괄 작업만 실행할 수 있습니다.

버전 4.1에 추가.

매개변수
  • type (str) – 트윗이나 사용자 ID값 중 어느 것을 전달하는지를 정하는 매개변수. 다음 값 중 하나로 입력해야 합니다: tweets, users

  • name (str | None) – 이 작업에 대한 이름. 여러 작업들을 서로 식별하는데 도움이 됩니다.

  • resumable (bool | None) – 재시작 가능한 업로드를 지원하는 URL을 사용할자의 여부를 지정하는 매개변수. true로 설정하면, 이 엔드포인트는 재시작 가능한 업로드를 사용하도록 사전 서명된 URL을 반환합니다.

반환값

반환 형식

dict | requests.Response | Response

참조

https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/api-reference/post-compliance-jobs

Footnotes

1(1,2,3,4)

https://developer.twitter.com/en/updates/changelog