Advertisement
genBTC

tweepy API Reference (full) all functions

Nov 12th, 2020 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 77.13 KB | None | 0 0
  1. tweepy — API Reference
  2. -----------------------
  3. https://github.com/tweepy/tweepy
  4. This page contains some basic documentation for the Tweepy module.
  5. http://docs.tweepy.org/en/latest/api.html
  6.  
  7. 1. Basic Sections
  8. -----------------
  9. ==Timeline methods
  10. ==Status methods
  11. ==User methods
  12. ==Direct Message Methods
  13. ==Friendship Methods
  14. ==Account Methods
  15. ==Favorite Methods
  16. ==Block Methods
  17. ==Mute Methods
  18. ==Spam Reporting Methods
  19. ==Saved Searches Methods
  20. ==Search Methods
  21. ==List Methods
  22. ==Trends Methods
  23. ==Geo Methods
  24. ==Utility methods
  25. ==Media methods
  26.  
  27.  
  28. 2. List of all Methods + Descriptions
  29. -------------------------------------
  30. ==Timeline methods
  31. API.home_timeline([since_id][, max_id][, count][, page])
  32. Returns the 20 most recent statuses, including retweets, posted by the authenticating user and that user’s friends. This is the equivalent of /timeline/home on the Web.
  33. API.statuses_lookup(id_[, include_entities][, trim_user][, map_][, include_ext_alt_text][, include_card_uri])
  34. Returns full Tweet objects for up to 100 tweets per request, specified by the id_ parameter.
  35. API.user_timeline([id/user_id/screen_name][, since_id][, max_id][, count][, page])
  36. Returns the 20 most recent statuses posted from the authenticating user or the user specified. It’s also possible to request another user’s timeline via the id parameter.
  37. API.retweets_of_me([since_id][, max_id][, count][, page])
  38. Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
  39. API.mentions_timeline([since_id][, max_id][, count])
  40. Returns the 20 most recent mentions, including retweets.
  41.  
  42. ==Status methods
  43. API.get_status(id[, trim_user][, include_my_retweet][, include_entities][, include_ext_alt_text][, include_card_uri])
  44. Returns a single status specified by the ID parameter.
  45. API.update_status(status[, in_reply_to_status_id][, auto_populate_reply_metadata][, exclude_reply_user_ids][, attachment_url][, media_ids][, possibly_sensitive][, lat][, long][, place_id][, display_coordinates][, trim_user][, enable_dmcommands][, fail_dmcommands][, card_uri])
  46. Updates the authenticating user’s current status, also known as Tweeting.
  47. API.update_with_media(filename[, status][, in_reply_to_status_id][, auto_populate_reply_metadata][, lat][, long][, source][, place_id][, file])
  48. Deprecated: Use API.media_upload() instead. Update the authenticated user’s status. Statuses that are duplicates or too long will be silently ignored.
  49. API.destroy_status(id)
  50. Destroy the status specified by the id parameter. The authenticated user must be the author of the status to destroy.
  51. API.retweet(id)
  52. Retweets a tweet. Requires the id of the tweet you are retweeting.
  53. API.retweeters(id[, cursor][, stringify_ids])
  54. Returns up to 100 user IDs belonging to users who have retweeted the Tweet specified by the id parameter.
  55. API.retweets(id[, count])
  56. Returns up to 100 of the first retweets of the given tweet.
  57. API.unretweet(id)
  58. Untweets a retweeted status. Requires the id of the retweet to unretweet.
  59. API.get_oembed(id/url[, maxwidth][, hide_media][, omit_script][, align][, related][, lang])
  60. Requests the Twitter oembed HTML for a given tweet.
  61.  
  62. ==User methods
  63. API.get_user(id/user_id/screen_name)
  64. Returns information about the specified user.
  65. API.me()
  66. Returns the authenticated user’s information.
  67. API.friends([id/user_id/screen_name][, cursor][, skip_status][, include_user_entities])
  68. Returns a user’s friends ordered in which they were added 100 at a time. If no user is specified it defaults to the authenticated user.
  69. API.followers([id/screen_name/user_id][, cursor])
  70. Returns a user’s followers ordered in which they were added. If no user is specified by id/screen name, it defaults to the authenticated user.
  71. API.lookup_users([user_ids][, screen_names][, include_entities][, tweet_mode])
  72. Returns fully-hydrated user objects for up to 100 users per request.
  73. API.search_users(q[, count][, page])
  74. Run a search for users similar to Find People button on Twitter.com; the same results returned by people search on Twitter.com will be returned by using this API (about being listed in the People Search). It is only possible to retrieve the first 1000 matches from this API.
  75.  
  76. ==Direct Message Methods
  77. API.get_direct_message([id][, full_text])
  78. Returns a specific direct message.
  79. API.list_direct_messages([count][, cursor])
  80. Returns all Direct Message events (both sent and received) within the last 30 days. Sorted in reverse-chronological order.
  81. API.send_direct_message(recipient_id, text[, quick_reply_type][, attachment_type][, attachment_media_id])
  82. Sends a new direct message to the specified user from the authenticating user.
  83. API.destroy_direct_message(id)
  84. Deletes the direct message specified in the required ID parameter. The authenticating user must be the recipient of the specified direct message. Direct Messages are only removed from the interface of the user context provided. Other members of the conversation can still access the Direct Messages.
  85.  
  86. ==Friendship Methods
  87. API.create_friendship(id/screen_name/user_id[, follow])
  88. Create a new friendship with the specified user (aka follow).
  89. API.destroy_friendship(id/screen_name/user_id)
  90. Destroy a friendship with the specified user (aka unfollow).
  91. API.show_friendship(source_id/source_screen_name, target_id/target_screen_name)
  92. Returns detailed information about the relationship between two users.
  93. API.lookup_friendships(user_ids/screen_names)
  94. Returns the relationships of the authenticated user to the list of up to 100 screen_names or user_ids provided.
  95. API.friends_ids(id/screen_name/user_id[, cursor])
  96. Returns an array containing the IDs of users being followed by the specified user.
  97. API.followers_ids(id/screen_name/user_id)
  98. Returns an array containing the IDs of users following the specified user.
  99.  
  100. ==Account Methods
  101. API.verify_credentials([include_entities][, skip_status][, include_email])
  102. Verify the supplied user credentials are valid.
  103. API.rate_limit_status()
  104. Returns the current rate limits for methods belonging to the specified resource families. When using application-only auth, this method’s response indicates the application-only auth rate limiting context.
  105. API.update_profile_image(filename)
  106. Update the authenticating user’s profile image. Valid formats: GIF, JPG, or PNG
  107. API.update_profile_background_image(filename)
  108. Update authenticating user’s background image. Valid formats: GIF, JPG, or PNG
  109. API.update_profile([name][, url][, location][, description])
  110. Sets values that users are able to set under the “Account” tab of their settings page.
  111.  
  112. ==Favorite Methods
  113. API.favorites([id][, page])
  114. Returns the favorite statuses for the authenticating user or user specified by the ID parameter.
  115. API.create_favorite(id)
  116. Favorites the status specified in the ID parameter as the authenticating user.
  117. API.destroy_favorite(id)
  118. Un-favorites the status specified in the ID parameter as the authenticating user.
  119.  
  120. ==Block Methods
  121. API.create_block(id/screen_name/user_id)
  122. Blocks the user specified in the ID parameter as the authenticating user. Destroys a friendship to the blocked user if it exists.
  123. API.destroy_block(id/screen_name/user_id)
  124. Un-blocks the user specified in the ID parameter for the authenticating user.
  125. API.blocks([page])
  126. Returns an array of user objects that the authenticating user is blocking.
  127. API.blocks_ids([cursor])
  128. Returns an array of numeric user ids the authenticating user is blocking.
  129.  
  130. ==Mute Methods
  131. API.create_mute(id/screen_name/user_id)
  132. Mutes the user specified in the ID parameter for the authenticating user.
  133. API.destroy_mute(id/screen_name/user_id)
  134. Un-mutes the user specified in the ID parameter for the authenticating user.
  135. API.mutes([cursor][, include_entities][, skip_status])
  136. Returns an array of user objects the authenticating user has muted.
  137. API.mutes_ids([cursor])
  138. Returns an array of numeric user ids the authenticating user has muted.
  139.  
  140. ==Spam Reporting Methods
  141. API.report_spam(id/screen_name/user_id[, perform_block])
  142. The user specified in the id is blocked by the authenticated user and reported as a spammer.
  143.  
  144. ==Saved Searches Methods
  145. API.saved_searches()
  146. Returns the authenticated user’s saved search queries.
  147. API.get_saved_search(id)
  148. Retrieve the data for a saved search owned by the authenticating user specified by the given id.
  149. API.create_saved_search(query)
  150. Creates a saved search for the authenticated user.
  151. API.destroy_saved_search(id)
  152. Destroys a saved search for the authenticated user. The search specified by id must be owned by the authenticating user.
  153.  
  154. ==Search Methods
  155. API.search(q[, geocode][, lang][, locale][, result_type][, count][, until][, since_id][, max_id][, include_entities])
  156. Returns a collection of relevant Tweets matching a specified query.
  157. API.search_30_day(environment_name, query[, tag][, fromDate][, toDate][, maxResults][, next])
  158. Premium search that provides Tweets posted within the last 30 days.
  159. API.search_full_archive(environment_name, query[, tag][, fromDate][, toDate][, maxResults][, next])
  160. Premium search that provides Tweets from as early as 2006, starting with the first Tweet posted in March 2006.
  161.  
  162. ==List Methods
  163. API.create_list(name[, mode][, description])
  164. Creates a new list for the authenticated user. Note that you can create up to 1000 lists per account.
  165. API.destroy_list([owner_screen_name/owner_id, ]list_id/slug)
  166. Deletes the specified list. The authenticated user must own the list to be able to destroy it.
  167. API.update_list(list_id/slug[, name][, mode][, description][, owner_screen_name/owner_id])
  168. Updates the specified list. The authenticated user must own the list to be able to update it.
  169. API.lists_all([screen_name][, user_id][, reverse])
  170. Returns all lists the authenticating or specified user subscribes to, including their own. The user is specified using the user_id or screen_name parameters. If no user is given, the authenticating user is used.
  171. API.lists_memberships([screen_name][, user_id][, filter_to_owned_lists][, cursor][, count])
  172. Returns the lists the specified user has been added to. If user_id or screen_name are not provided, the memberships for the authenticating user are returned.
  173. API.lists_subscriptions([screen_name][, user_id][, cursor][, count])
  174. Obtain a collection of the lists the specified user is subscribed to, 20 lists per page by default. Does not include the user’s own lists.
  175. API.list_timeline(list_id/slug[, owner_id/owner_screen_name][, since_id][, max_id][, count][, include_entities][, include_rts])
  176. Returns a timeline of tweets authored by members of the specified list. Retweets are included by default. Use the include_rts=false parameter to omit retweets.
  177. API.get_list(list_id/slug[, owner_id/owner_screen_name])
  178. Returns the specified list. Private lists will only be shown if the authenticated user owns the specified list.
  179. API.add_list_member(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  180. Add a member to a list. The authenticated user must own the list to be able to add members to it. Lists are limited to 5,000 members.
  181. API.add_list_members(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  182. Add up to 100 members to a list. The authenticated user must own the list to be able to add members to it. Lists are limited to 5,000 members.
  183. API.remove_list_member(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  184. Removes the specified member from the list. The authenticated user must be the list’s owner to remove members from the list.
  185. API.remove_list_members(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  186. Remove up to 100 members from a list. The authenticated user must own the list to be able to remove members from it. Lists are limited to 5,000 members.
  187. API.list_members(list_id/slug[, owner_id/owner_screen_name][, cursor])
  188. Returns the members of the specified list.
  189. API.show_list_member(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  190. Check if the specified user is a member of the specified list.
  191. API.subscribe_list(list_id/slug[, owner_id/owner_screen_name])
  192. Subscribes the authenticated user to the specified list.
  193. API.unsubscribe_list(list_id/slug[, owner_id/owner_screen_name])
  194. Unsubscribes the authenticated user from the specified list.
  195. API.list_subscribers(list_id/slug[, owner_id/owner_screen_name][, cursor][, count][, include_entities][, skip_status])
  196. Returns the subscribers of the specified list. Private list subscribers will only be shown if the authenticated user owns the specified list.
  197. API.show_list_subscriber(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  198. Check if the specified user is a subscriber of the specified list.
  199.  
  200. ==Trends Methods
  201. API.trends_available()
  202. Returns the locations that Twitter has trending topic information for. The response is an array of “locations” that encode the location’s WOEID (a Yahoo! Where On Earth ID) and some other human-readable information such as a canonical name and country the location belongs in.
  203. API.trends_place(id[, exclude])
  204. Returns the top 50 trending topics for a specific WOEID, if trending information is available for it.
  205. API.trends_closest(lat, long)
  206. Returns the locations that Twitter has trending topic information for, closest to a specified location.
  207. API.reverse_geocode([lat][, long][, accuracy][, granularity][, max_results])
  208. Given a latitude and longitude, looks for places (cities and neighbourhoods) whose IDs can be specified in a call to update_status() to appear as the name of the location. This call provides a detailed response about the location in question; the nearby_places() function should be preferred for getting a list of places nearby without great detail.
  209.  
  210. ==Geo Methods
  211. API.geo_id(id)
  212. Given id of a place, provide more details about that place.
  213.  
  214. ==Utility methods
  215. API.configuration()
  216. Returns the current configuration used by Twitter including twitter.com slugs which are not usernames, maximum photo resolutions, and t.co shortened URL length. It is recommended applications request this endpoint when they are loaded, but no more than once a day.
  217.  
  218. ==Utility methods
  219. API.media_upload(filename[, file])
  220. Use this endpoint to upload images to Twitter.
  221. API.create_media_metadata(media_id, alt_text)
  222. This endpoint can be used to provide additional information about the uploaded media_id. This feature is currently only supported for images and GIFs. Call this endpoint to attach additional metadata such as image alt text.
  223.  
  224.  
  225. 3. Full Documentation
  226. ---------------------
  227. tweepy.api — Twitter API wrapper
  228.  
  229. class API([auth_handler=None][, host='api.twitter.com'][, search_host='search.twitter.com'][, cache=None][, api_root='/1'][, search_root=''][, retry_count=0][, retry_delay=0][, retry_errors=None][, timeout=60][, parser=ModelParser][, compression=False][, wait_on_rate_limit=False][, wait_on_rate_limit_notify=False][, proxy=None])
  230.  
  231. This class provides a wrapper for the API as provided by Twitter. The functions provided in this class are listed below.
  232.  
  233. Parameters:
  234. auth_handler – authentication handler to be used
  235. host – general API host
  236. search_host – search API host
  237. cache – cache backend to use
  238. api_root – general API path root
  239. search_root – search API path root
  240. retry_count – default number of retries to attempt when error occurs
  241. retry_delay – number of seconds to wait between retries
  242. retry_errors – which HTTP status codes to retry
  243. timeout – The maximum amount of time to wait for a response from Twitter
  244. parser – The object to use for parsing the response from Twitter
  245. compression – Whether or not to use GZIP compression for requests
  246. wait_on_rate_limit – Whether or not to automatically wait for rate limits to replenish
  247. wait_on_rate_limit_notify – Whether or not to print a notification when Tweepy is waiting for rate limits to replenish
  248. proxy – The full url to an HTTPS proxy to use for connecting to Twitter.
  249.  
  250. ==Timeline methods
  251.  
  252. API.home_timeline([since_id][, max_id][, count][, page])
  253.  
  254. Returns the 20 most recent statuses, including retweets, posted by the authenticating user and that user’s friends. This is the equivalent of /timeline/home on the Web.
  255.  
  256. Parameters:
  257. since_id – Returns only statuses with an ID greater than (that is, more recent than) the specified ID.
  258. max_id – Returns only statuses with an ID less than (that is, older than) or equal to the specified ID.
  259. count – The number of results to try and retrieve per page.
  260. page – Specifies the page of results to retrieve. Note: there are pagination limits.
  261.  
  262. Return type: list of Status objects
  263.  
  264. API.statuses_lookup(id_[, include_entities][, trim_user][, map_][, include_ext_alt_text][, include_card_uri])
  265.  
  266. Returns full Tweet objects for up to 100 tweets per request, specified by the id_ parameter.
  267.  
  268. Parameters:
  269. id_ – A list of Tweet IDs to lookup, up to 100
  270. include_entities – The entities node will not be included when set to false. Defaults to true.
  271. trim_user – A boolean indicating if user IDs should be provided, instead of complete user objects. Defaults to False.
  272. map_ – A boolean indicating whether or not to include tweets that cannot be shown. Defaults to False.
  273. include_ext_alt_text – If alt text has been added to any attached media entities, this parameter will return an ext_alt_text value in the top-level key for the media entity.
  274. include_card_uri – A boolean indicating if the retrieved Tweet should include a card_uri attribute when there is an ads card attached to the Tweet and when that card was attached using the card_uri value.
  275.  
  276. Return type: list of Status objects
  277.  
  278. API.user_timeline([id/user_id/screen_name][, since_id][, max_id][, count][, page])
  279.  
  280. Returns the 20 most recent statuses posted from the authenticating user or the user specified. It’s also possible to request another user’s timeline via the id parameter.
  281.  
  282. Parameters:
  283. id – Specifies the ID or screen name of the user.
  284. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  285. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  286. since_id – Returns only statuses with an ID greater than (that is, more recent than) the specified ID.
  287. max_id – Returns only statuses with an ID less than (that is, older than) or equal to the specified ID.
  288. count – The number of results to try and retrieve per page.
  289. page – Specifies the page of results to retrieve. Note: there are pagination limits.
  290.  
  291. Return type: list of Status objects
  292.  
  293. API.retweets_of_me([since_id][, max_id][, count][, page])
  294.  
  295. Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
  296.  
  297. Parameters:
  298. since_id – Returns only statuses with an ID greater than (that is, more recent than) the specified ID.
  299. max_id – Returns only statuses with an ID less than (that is, older than) or equal to the specified ID.
  300. count – The number of results to try and retrieve per page.
  301. page – Specifies the page of results to retrieve. Note: there are pagination limits.
  302.  
  303. Return type: list of Status objects
  304.  
  305. API.mentions_timeline([since_id][, max_id][, count])
  306.  
  307. Returns the 20 most recent mentions, including retweets.
  308.  
  309. Parameters:
  310. since_id – Returns only statuses with an ID greater than (that is, more recent than) the specified ID.
  311. max_id – Returns only statuses with an ID less than (that is, older than) or equal to the specified ID.
  312. count – The number of results to try and retrieve per page.
  313.  
  314. Return type: list of Status objects
  315.  
  316. ==Status methods
  317.  
  318. API.get_status(id[, trim_user][, include_my_retweet][, include_entities][, include_ext_alt_text][, include_card_uri])
  319.  
  320. Returns a single status specified by the ID parameter.
  321.  
  322. Parameters:
  323. id – The numerical ID of the status.
  324. trim_user – A boolean indicating if user IDs should be provided, instead of complete user objects. Defaults to False.
  325. include_my_retweet – A boolean indicating if any Tweets returned that have been retweeted by the authenticating user should include an additional current_user_retweet node, containing the ID of the source status for the retweet.
  326. include_entities – The entities node will not be included when set to false. Defaults to true.
  327. include_ext_alt_text – If alt text has been added to any attached media entities, this parameter will return an ext_alt_text value in the top-level key for the media entity.
  328. include_card_uri – A boolean indicating if the retrieved Tweet should include a card_uri attribute when there is an ads card attached to the Tweet and when that card was attached using the card_uri value.
  329.  
  330. Return type: Status object
  331.  
  332. API.update_status(status[, in_reply_to_status_id][, auto_populate_reply_metadata][, exclude_reply_user_ids][, attachment_url][, media_ids][, possibly_sensitive][, lat][, long][, place_id][, display_coordinates][, trim_user][, enable_dmcommands][, fail_dmcommands][, card_uri])
  333.  
  334. Updates the authenticating user’s current status, also known as Tweeting.
  335. For each update attempt, the update text is compared with the authenticating user’s recent Tweets. Any attempt that would result in duplication will be blocked, resulting in a 403 error. A user cannot submit the same status twice in a row.
  336. While not rate limited by the API, a user is limited in the number of Tweets they can create at a time. If the number of updates posted by the user reaches the current allowed limit this method will return an HTTP 403 error.
  337.  
  338. Parameters:
  339. status – The text of your status update.
  340. in_reply_to_status_id – The ID of an existing status that the update is in reply to. Note: This parameter will be ignored unless the author of the Tweet this parameter references is mentioned within the status text. Therefore, you must include @username, where username is the author of the referenced Tweet, within the update.
  341. auto_populate_reply_metadata – If set to true and used with in_reply_to_status_id, leading @mentions will be looked up from the original Tweet, and added to the new Tweet from there. This wil append @mentions into the metadata of an extended Tweet as a reply chain grows, until the limit on @mentions is reached. In cases where the original Tweet has been deleted, the reply will fail.
  342. exclude_reply_user_ids – When used with auto_populate_reply_metadata, a comma-separated list of user ids which will be removed from the server-generated @mentions prefix on an extended Tweet. Note that the leading @mention cannot be removed as it would break the in-reply-to-status-id semantics. Attempting to remove it will be silently ignored.
  343. attachment_url – In order for a URL to not be counted in the status body of an extended Tweet, provide a URL as a Tweet attachment. This URL must be a Tweet permalink, or Direct Message deep link. Arbitrary, non-Twitter URLs must remain in the status text. URLs passed to the attachment_url parameter not matching either a Tweet permalink or Direct Message deep link will fail at Tweet creation and cause an exception.
  344. media_ids – A list of media_ids to associate with the Tweet. You may include up to 4 photos or 1 animated GIF or 1 video in a Tweet.
  345. possibly_sensitive – If you upload Tweet media that might be considered sensitive content such as nudity, or medical procedures, you must set this value to true.
  346. lat – The latitude of the location this Tweet refers to. This parameter will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there is no corresponding long parameter.
  347. long – The longitude of the location this Tweet refers to. The valid ranges for longitude are -180.0 to +180.0 (East is positive) inclusive. This parameter will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there no corresponding lat parameter.
  348. place_id – A place in the world.
  349. display_coordinates – Whether or not to put a pin on the exact coordinates a Tweet has been sent from.
  350. trim_user – A boolean indicating if user IDs should be provided, instead of complete user objects. Defaults to False.
  351. enable_dmcommands – When set to true, enables shortcode commands for sending Direct Messages as part of the status text to send a Direct Message to a user. When set to false, disables this behavior and includes any leading characters in the status text that is posted
  352. fail_dmcommands – When set to true, causes any status text that starts with shortcode commands to return an API error. When set to false, allows shortcode commands to be sent in the status text and acted on by the API.
  353. card_uri – Associate an ads card with the Tweet using the card_uri value from any ads card response.
  354.  
  355. Return type: Status object
  356.  
  357. API.update_with_media(filename[, status][, in_reply_to_status_id][, auto_populate_reply_metadata][, lat][, long][, source][, place_id][, file])
  358.  
  359. Deprecated: Use API.media_upload() instead. Update the authenticated user’s status. Statuses that are duplicates or too long will be silently ignored.
  360.  
  361. Parameters:
  362. filename – The filename of the image to upload. This will automatically be opened unless file is specified
  363. status – The text of your status update.
  364. in_reply_to_status_id – The ID of an existing status that the update is in reply to.
  365. auto_populate_reply_metadata – Whether to automatically include the @mentions in the status metadata.
  366. lat – The location’s latitude that this tweet refers to.
  367. long – The location’s longitude that this tweet refers to.
  368. source – Source of the update. Only supported by Identi.ca. Twitter ignores this parameter.
  369. place_id – Twitter ID of location which is listed in the Tweet if geolocation is enabled for the user.
  370. file – A file object, which will be used instead of opening filename. filename is still required, for MIME type detection and to use as a form field in the POST data
  371.  
  372. Return type: Status object
  373.  
  374. API.destroy_status(id)
  375.  
  376. Destroy the status specified by the id parameter. The authenticated user must be the author of the status to destroy.
  377.  
  378. Parameters:
  379. id – The numerical ID of the status.
  380.  
  381. Return type: Status object
  382.  
  383. API.retweet(id)
  384.  
  385. Retweets a tweet. Requires the id of the tweet you are retweeting.
  386.  
  387. Parameters:
  388. id – The numerical ID of the status.
  389.  
  390. Return type: Status object
  391.  
  392. API.retweeters(id[, cursor][, stringify_ids])
  393.  
  394. Returns up to 100 user IDs belonging to users who have retweeted the Tweet specified by the id parameter.
  395.  
  396. Parameters:
  397. id – The numerical ID of the status.
  398. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  399. stringify_ids – Have ids returned as strings instead.
  400.  
  401. Return type: list of Integers
  402.  
  403. API.retweets(id[, count])
  404.  
  405. Returns up to 100 of the first retweets of the given tweet.
  406.  
  407. Parameters:
  408. id – The numerical ID of the status.
  409. count – Specifies the number of retweets to retrieve.
  410.  
  411. Return type: list of Status objects
  412.  
  413. API.unretweet(id)
  414.  
  415. Untweets a retweeted status. Requires the id of the retweet to unretweet.
  416.  
  417. Parameters:
  418. id – The numerical ID of the status.
  419.  
  420. Return type: Status object
  421.  
  422. API.get_oembed(id/url[, maxwidth][, hide_media][, omit_script][, align][, related][, lang])
  423.  
  424. Requests the Twitter oembed HTML for a given tweet.
  425.  
  426. Parameters:
  427. id – The numerical ID of the status.
  428. url – The URL of the Tweet to be embedded
  429. maxwidth – The maximum width of a rendered Tweet in whole pixels.
  430. hide_media – When set to true, links in a Tweet are not expanded to photo, video, or link previews.
  431. omit_script – When set to true, the <script> responsible for loading widgets.js will not be returned. Your webpages should include their own reference to widgets.js
  432. align – Specifies whether the embedded Tweet should be floated left, right, or center in the page relative to the parent element.
  433. related – A comma-separated list of Twitter usernames related to your content.
  434. lang – Request returned HTML and a rendered Tweet in the specified Twitter language supported by embedded Tweets.
  435.  
  436. Return type: JSON object
  437.  
  438. ==User methods
  439.  
  440. API.get_user(id/user_id/screen_name)
  441.  
  442. Returns information about the specified user.
  443.  
  444. Parameters:
  445. id – Specifies the ID or screen name of the user.
  446. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  447. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  448.  
  449. Return type: User object
  450.  
  451. API.me()
  452.  
  453. Returns the authenticated user’s information.
  454.  
  455. Return type: User object
  456.  
  457. API.friends([id/user_id/screen_name][, cursor][, skip_status][, include_user_entities])
  458.  
  459. Returns a user’s friends ordered in which they were added 100 at a time. If no user is specified it defaults to the authenticated user.
  460.  
  461. Parameters:
  462. id – Specifies the ID or screen name of the user.
  463. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  464. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  465. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  466. count – The number of results to try and retrieve per page.
  467. skip_status – A boolean indicating whether statuses will not be included in the returned user objects. Defaults to false.
  468. include_user_entities – The user object entities node will not be included when set to false. Defaults to true.
  469.  
  470. Return type: list of User objects
  471.  
  472. API.followers([id/screen_name/user_id][, cursor])
  473.  
  474. Returns a user’s followers ordered in which they were added. If no user is specified by id/screen name, it defaults to the authenticated user.
  475.  
  476. Parameters:
  477. id – Specifies the ID or screen name of the user.
  478. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  479. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  480. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  481. count – The number of results to try and retrieve per page.
  482. skip_status – A boolean indicating whether statuses will not be included in the returned user objects. Defaults to false.
  483. include_user_entities – The user object entities node will not be included when set to false. Defaults to true.
  484.  
  485. Return type: list of User objects
  486.  
  487. API.lookup_users([user_ids][, screen_names][, include_entities][, tweet_mode])
  488.  
  489. Returns fully-hydrated user objects for up to 100 users per request.
  490.  
  491. There are a few things to note when using this method:
  492. You must be following a protected user to be able to see their most recent status update. If you don’t follow a protected user their status will be removed.
  493. The order of user IDs or screen names may not match the order of users in the returned array.
  494. If a requested user is unknown, suspended, or deleted, then that user will not be returned in the results list.
  495. If none of your lookup criteria can be satisfied by returning a user object, a HTTP 404 will be thrown.
  496.  
  497. Parameters:
  498. user_ids – A list of user IDs, up to 100 are allowed in a single request.
  499. screen_names – A list of screen names, up to 100 are allowed in a single request.
  500. include_entities – The entities node will not be included when set to false. Defaults to true.
  501. tweet_mode – Valid request values are compat and extended, which give compatibility mode and extended mode, respectively for Tweets that contain over 140 characters.
  502.  
  503. Return type: list of User objects
  504.  
  505. API.search_users(q[, count][, page])
  506.  
  507. Run a search for users similar to Find People button on Twitter.com; the same results returned by people search on Twitter.com will be returned by using this API (about being listed in the People Search). It is only possible to retrieve the first 1000 matches from this API.
  508.  
  509. Parameters:
  510. q – The query to run against people search.
  511. count – Specifies the number of statuses to retrieve. May not be greater than 20.
  512. page – Specifies the page of results to retrieve. Note: there are pagination limits.
  513.  
  514. Return type: list of User objects
  515.  
  516. ==Direct Message Methods
  517.  
  518. API.get_direct_message([id][, full_text])
  519.  
  520. Returns a specific direct message.
  521.  
  522. Parameters:
  523. id – The id of the Direct Message event that should be returned.
  524. full_text – A boolean indicating whether or not the full text of a message should be returned. If False the message text returned will be truncated to 140 chars. Defaults to False.
  525.  
  526. Return type: DirectMessage object
  527.  
  528. API.list_direct_messages([count][, cursor])
  529.  
  530. Returns all Direct Message events (both sent and received) within the last 30 days. Sorted in reverse-chronological order.
  531.  
  532. Parameters:
  533. count – The number of results to try and retrieve per page.
  534. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  535.  
  536. Return type: list of DirectMessage objects
  537.  
  538. API.send_direct_message(recipient_id, text[, quick_reply_type][, attachment_type][, attachment_media_id])
  539.  
  540. Sends a new direct message to the specified user from the authenticating user.
  541.  
  542. Parameters:
  543. recipient_id – The ID of the user who should receive the direct message.
  544. text – The text of your Direct Message. Max length of 10,000 characters.
  545. quick_reply_type –
  546.  
  547. The Quick Reply type to present to the user:
  548. options - Array of Options objects (20 max).
  549. text_input - Text Input object.
  550. location - Location object.
  551. attachment_type – The attachment type. Can be media or location.
  552. attachment_media_id – A media id to associate with the message. A Direct Message may only reference a single media_id.
  553.  
  554. Return type: DirectMessage object
  555.  
  556. API.destroy_direct_message(id)
  557.  
  558. Deletes the direct message specified in the required ID parameter. The authenticating user must be the recipient of the specified direct message. Direct Messages are only removed from the interface of the user context provided. Other members of the conversation can still access the Direct Messages.
  559.  
  560. Parameters:
  561. id – The id of the Direct Message that should be deleted.
  562.  
  563. Return type: None
  564.  
  565. ==Friendship Methods
  566.  
  567. API.create_friendship(id/screen_name/user_id[, follow])
  568.  
  569. Create a new friendship with the specified user (aka follow).
  570.  
  571. Parameters:
  572. id – Specifies the ID or screen name of the user.
  573. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  574. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  575. follow – Enable notifications for the target user in addition to becoming friends.
  576.  
  577. Return type: User object
  578.  
  579. API.destroy_friendship(id/screen_name/user_id)
  580.  
  581. Destroy a friendship with the specified user (aka unfollow).
  582.  
  583. Parameters:
  584. id – Specifies the ID or screen name of the user.
  585. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  586. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  587.  
  588. Return type: User object
  589.  
  590. API.show_friendship(source_id/source_screen_name, target_id/target_screen_name)
  591.  
  592. Returns detailed information about the relationship between two users.
  593.  
  594. Parameters:
  595. source_id – The user_id of the subject user.
  596. source_screen_name – The screen_name of the subject user.
  597. target_id – The user_id of the target user.
  598. target_screen_name – The screen_name of the target user.
  599.  
  600. Return type: Friendship object
  601.  
  602. API.lookup_friendships(user_ids/screen_names)
  603.  
  604. Returns the relationships of the authenticated user to the list of up to 100 screen_names or user_ids provided.
  605.  
  606. Parameters:
  607. user_ids – A list of user IDs, up to 100 are allowed in a single request.
  608. screen_names – A list of screen names, up to 100 are allowed in a single request.
  609.  
  610. Return type: Relationship object
  611.  
  612. API.friends_ids(id/screen_name/user_id[, cursor])
  613.  
  614. Returns an array containing the IDs of users being followed by the specified user.
  615.  
  616. Parameters:
  617. id – Specifies the ID or screen name of the user.
  618. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  619. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  620. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  621.  
  622. Return type: list of Integers
  623.  
  624. API.followers_ids(id/screen_name/user_id)
  625.  
  626. Returns an array containing the IDs of users following the specified user.
  627.  
  628. Parameters:
  629. id – Specifies the ID or screen name of the user.
  630. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  631. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  632. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  633.  
  634. Return type: list of Integers
  635.  
  636. ==Account Methods
  637.  
  638. API.verify_credentials([include_entities][, skip_status][, include_email])
  639.  
  640. Verify the supplied user credentials are valid.
  641.  
  642. Parameters:
  643. include_entities – The entities node will not be included when set to false. Defaults to true.
  644. skip_status – A boolean indicating whether statuses will not be included in the returned user objects. Defaults to false.
  645. include_email – When set to true email will be returned in the user objects as a string.
  646.  
  647. Return type: User object if credentials are valid, otherwise False
  648.  
  649. API.rate_limit_status()
  650.  
  651. Returns the current rate limits for methods belonging to the specified resource families. When using application-only auth, this method’s response indicates the application-only auth rate limiting context.
  652.  
  653. Parameters:
  654. resources – A comma-separated list of resource families you want to know the current rate limit disposition for.
  655.  
  656. Return type: JSON object
  657.  
  658. API.update_profile_image(filename)
  659.  
  660. Update the authenticating user’s profile image. Valid formats: GIF, JPG, or PNG
  661.  
  662. Parameters:
  663. filename – local path to image file to upload. Not a remote URL!
  664.  
  665. Return type: User object
  666.  
  667. API.update_profile_background_image(filename)
  668.  
  669. Update authenticating user’s background image. Valid formats: GIF, JPG, or PNG
  670.  
  671. Parameters:
  672. filename – local path to image file to upload. Not a remote URL!
  673.  
  674. Return type: User object
  675.  
  676. API.update_profile([name][, url][, location][, description])
  677.  
  678. Sets values that users are able to set under the “Account” tab of their settings page.
  679.  
  680. Parameters:
  681. name – Maximum of 20 characters
  682. url – Maximum of 100 characters. Will be prepended with “http://” if not present
  683. location – Maximum of 30 characters
  684. description – Maximum of 160 characters
  685.  
  686. Return type: User object
  687.  
  688. ==Favorite Methods
  689.  
  690. API.favorites([id][, page])
  691.  
  692. Returns the favorite statuses for the authenticating user or user specified by the ID parameter.
  693.  
  694. Parameters:
  695. id – The ID or screen name of the user to request favorites
  696. page – Specifies the page of results to retrieve. Note: there are pagination limits.
  697.  
  698. Return type: list of Status objects
  699.  
  700. API.create_favorite(id)
  701.  
  702. Favorites the status specified in the ID parameter as the authenticating user.
  703.  
  704. Parameters:
  705. id – The numerical ID of the status.
  706.  
  707. Return type: Status object
  708.  
  709. API.destroy_favorite(id)
  710.  
  711. Un-favorites the status specified in the ID parameter as the authenticating user.
  712.  
  713. Parameters:
  714. id – The numerical ID of the status.
  715.  
  716. Return type: Status object
  717.  
  718. ==Block Methods
  719.  
  720. API.create_block(id/screen_name/user_id)
  721.  
  722. Blocks the user specified in the ID parameter as the authenticating user. Destroys a friendship to the blocked user if it exists.
  723.  
  724. Parameters:
  725. id – Specifies the ID or screen name of the user.
  726. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  727. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  728.  
  729. Return type: User object
  730.  
  731. API.destroy_block(id/screen_name/user_id)
  732.  
  733. Un-blocks the user specified in the ID parameter for the authenticating user.
  734.  
  735. Parameters:
  736. id – Specifies the ID or screen name of the user.
  737. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  738. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  739.  
  740. Return type: User object
  741.  
  742. API.blocks([page])
  743.  
  744. Returns an array of user objects that the authenticating user is blocking.
  745.  
  746. Parameters:
  747. page – Specifies the page of results to retrieve. Note: there are pagination limits.
  748.  
  749. Return type: list of User objects
  750.  
  751. API.blocks_ids([cursor])
  752.  
  753. Returns an array of numeric user ids the authenticating user is blocking.
  754.  
  755. Parameters:
  756. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  757.  
  758. Return type: list of Integers
  759.  
  760. ==Mute Methods
  761.  
  762. API.create_mute(id/screen_name/user_id)
  763.  
  764. Mutes the user specified in the ID parameter for the authenticating user.
  765.  
  766. Parameters:
  767. id – Specifies the ID or screen name of the user.
  768. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  769. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  770.  
  771. Return type: User object
  772.  
  773. API.destroy_mute(id/screen_name/user_id)
  774.  
  775. Un-mutes the user specified in the ID parameter for the authenticating user.
  776.  
  777. Parameters:
  778. id – Specifies the ID or screen name of the user.
  779. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  780. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  781.  
  782. Return type: User object
  783.  
  784. API.mutes([cursor][, include_entities][, skip_status])
  785.  
  786. Returns an array of user objects the authenticating user has muted.
  787.  
  788. Parameters:
  789. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  790. include_entities – The entities node will not be included when set to false. Defaults to true.
  791. skip_status – A boolean indicating whether statuses will not be included in the returned user objects. Defaults to false.
  792.  
  793. Return type: list of User objects
  794.  
  795. API.mutes_ids([cursor])
  796.  
  797. Returns an array of numeric user ids the authenticating user has muted.
  798.  
  799. Parameters:
  800. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  801.  
  802. Return type: list of Integers
  803.  
  804. ==Spam Reporting Methods
  805.  
  806. API.report_spam(id/screen_name/user_id[, perform_block])
  807.  
  808. The user specified in the id is blocked by the authenticated user and reported as a spammer.
  809.  
  810. Parameters:
  811. id – Specifies the ID or screen name of the user.
  812. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  813. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  814. perform_block – A boolean indicating if the reported account should be blocked. Defaults to True.
  815.  
  816. Return type: User object
  817.  
  818. ==Saved Searches Methods
  819.  
  820. API.saved_searches()
  821.  
  822. Returns the authenticated user’s saved search queries.
  823.  
  824. Return type: list of SavedSearch objects
  825.  
  826. API.get_saved_search(id)
  827.  
  828. Retrieve the data for a saved search owned by the authenticating user specified by the given id.
  829.  
  830. Parameters:
  831. id – The id of the saved search to be retrieved.
  832.  
  833. Return type: SavedSearch object
  834.  
  835. API.create_saved_search(query)
  836.  
  837. Creates a saved search for the authenticated user.
  838.  
  839. Parameters:
  840. query – The query of the search the user would like to save.
  841.  
  842. Return type: SavedSearch object
  843.  
  844. API.destroy_saved_search(id)
  845.  
  846. Destroys a saved search for the authenticated user. The search specified by id must be owned by the authenticating user.
  847.  
  848. Parameters:
  849. id – The id of the saved search to be deleted.
  850.  
  851. Return type: SavedSearch object
  852.  
  853. ==Search Methods
  854.  
  855. API.search(q[, geocode][, lang][, locale][, result_type][, count][, until][, since_id][, max_id][, include_entities])
  856.  
  857. Returns a collection of relevant Tweets matching a specified query.
  858. Please note that Twitter’s search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.
  859. In API v1.1, the response format of the Search API has been improved to return Tweet objects more similar to the objects you’ll find across the REST API and platform. However, perspectival attributes (fields that pertain to the perspective of the authenticating user) are not currently supported on this endpoint.[1][2]
  860.  
  861. Parameters:
  862. q – the search query string of 500 characters maximum, including operators. Queries may additionally be limited by complexity.
  863. geocode – Returns tweets by users located within a given radius of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by “latitide,longitude,radius”, where radius units must be specified as either “mi” (miles) or “km” (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly. A maximum of 1,000 distinct “sub-regions” will be considered when using the radius modifier.
  864. lang – Restricts tweets to the given language, given by an ISO 639-1 code. Language detection is best-effort.
  865. locale – Specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific consumers and the default should work in the majority of cases.
  866. result_type –
  867.  
  868. Specifies what type of search results you would prefer to receive. The current default is “mixed.” Valid values include:
  869. mixed : include both popular and real time results in the response
  870. recent : return only the most recent results in the response
  871. popular : return only the most popular results in the response
  872. count – The number of results to try and retrieve per page.
  873. until – Returns tweets created before the given date. Date should be formatted as YYYY-MM-DD. Keep in mind that the search index has a 7-day limit. In other words, no tweets will be found for a date older than one week.
  874. since_id – Returns only statuses with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occurred since the since_id, the since_id will be forced to the oldest ID available.
  875. max_id – Returns only statuses with an ID less than (that is, older than) or equal to the specified ID.
  876. include_entities – The entities node will not be included when set to false. Defaults to true.
  877.  
  878. Return type: SearchResults object
  879.  
  880. API.search_30_day(environment_name, query[, tag][, fromDate][, toDate][, maxResults][, next])
  881.  
  882. Premium search that provides Tweets posted within the last 30 days.
  883.  
  884. Parameters:
  885. environment_name – The (case-sensitive) label associated with your search developer environment, as displayed at https://developer.twitter.com/en/account/environments.
  886. query – The equivalent of one premium rule/filter, with up to 1,024 characters (256 with Sandbox dev environments). This parameter should include ALL portions of the rule/filter, including all operators, and portions of the rule should not be separated into other parameters of the query.
  887. tag – Tags can be used to segregate rules and their matching data into different logical groups. If a rule tag is provided, the rule tag is included in the ‘matching_rules’ attribute. It is recommended to assign rule-specific UUIDs to rule tags and maintain desired mappings on the client side.
  888. fromDate – The oldest UTC timestamp (from most recent 30 days) from which the Tweets will be provided. Timestamp is in minute granularity and is inclusive (i.e. 12:00 includes the 00 minute). Specified: Using only the fromDate with no toDate parameter will deliver results for the query going back in time from now( ) until the fromDate. Not Specified: If a fromDate is not specified, the API will deliver all of the results for 30 days prior to now( ) or the toDate (if specified). If neither the fromDate or toDate parameter is used, the API will deliver all results for the most recent 30 days, starting at the time of the request, going backwards.
  889. toDate – The latest, most recent UTC timestamp to which the Tweets will be provided. Timestamp is in minute granularity and is not inclusive (i.e. 11:59 does not include the 59th minute of the hour). Specified: Using only the toDate with no fromDate parameter will deliver the most recent 30 days of data prior to the toDate. Not Specified: If a toDate is not specified, the API will deliver all of the results from now( ) for the query going back in time to the fromDate. If neither the fromDate or toDate parameter is used, the API will deliver all results for the entire 30-day index, starting at the time of the request, going backwards.
  890. maxResults – The maximum number of search results to be returned by a request. A number between 10 and the system limit (currently 500, 100 for Sandbox environments). By default, a request response will return 100 results.
  891. next – This parameter is used to get the next ‘page’ of results. The value used with the parameter is pulled directly from the response provided by the API, and should not be modified.
  892.  
  893. API.search_full_archive(environment_name, query[, tag][, fromDate][, toDate][, maxResults][, next])
  894.  
  895. Premium search that provides Tweets from as early as 2006, starting with the first Tweet posted in March 2006.
  896.  
  897. Parameters:
  898. environment_name – The (case-sensitive) label associated with your search developer environment, as displayed at https://developer.twitter.com/en/account/environments.
  899. query – The equivalent of one premium rule/filter, with up to 1,024 characters (256 with Sandbox dev environments). This parameter should include ALL portions of the rule/filter, including all operators, and portions of the rule should not be separated into other parameters of the query.
  900. tag – Tags can be used to segregate rules and their matching data into different logical groups. If a rule tag is provided, the rule tag is included in the ‘matching_rules’ attribute. It is recommended to assign rule-specific UUIDs to rule tags and maintain desired mappings on the client side.
  901. fromDate – The oldest UTC timestamp (from most recent 30 days) from which the Tweets will be provided. Timestamp is in minute granularity and is inclusive (i.e. 12:00 includes the 00 minute). Specified: Using only the fromDate with no toDate parameter will deliver results for the query going back in time from now( ) until the fromDate. Not Specified: If a fromDate is not specified, the API will deliver all of the results for 30 days prior to now( ) or the toDate (if specified). If neither the fromDate or toDate parameter is used, the API will deliver all results for the most recent 30 days, starting at the time of the request, going backwards.
  902. toDate – The latest, most recent UTC timestamp to which the Tweets will be provided. Timestamp is in minute granularity and is not inclusive (i.e. 11:59 does not include the 59th minute of the hour). Specified: Using only the toDate with no fromDate parameter will deliver the most recent 30 days of data prior to the toDate. Not Specified: If a toDate is not specified, the API will deliver all of the results from now( ) for the query going back in time to the fromDate. If neither the fromDate or toDate parameter is used, the API will deliver all results for the entire 30-day index, starting at the time of the request, going backwards.
  903. maxResults – The maximum number of search results to be returned by a request. A number between 10 and the system limit (currently 500, 100 for Sandbox environments). By default, a request response will return 100 results.
  904. next – This parameter is used to get the next ‘page’ of results. The value used with the parameter is pulled directly from the response provided by the API, and should not be modified.
  905.  
  906. ==List Methods
  907.  
  908. API.create_list(name[, mode][, description])
  909.  
  910. Creates a new list for the authenticated user. Note that you can create up to 1000 lists per account.
  911.  
  912. Parameters:
  913. name – The name of the new list.
  914. mode – Whether your list is public or private. Values can be public or private. Lists are public by default if no mode is specified.
  915. description – The description of the list you are creating.
  916.  
  917. Return type: List object
  918.  
  919. API.destroy_list([owner_screen_name/owner_id, ]list_id/slug)
  920.  
  921. Deletes the specified list. The authenticated user must own the list to be able to destroy it.
  922.  
  923. Parameters:
  924. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  925. owner_id – The user ID of the user who owns the list being requested by a slug.
  926. list_id – The numerical id of the list.
  927. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  928.  
  929. Return type: List object
  930.  
  931. API.update_list(list_id/slug[, name][, mode][, description][, owner_screen_name/owner_id])
  932.  
  933. Updates the specified list. The authenticated user must own the list to be able to update it.
  934.  
  935. Parameters:
  936. list_id – The numerical id of the list.
  937. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  938. name – The name for the list.
  939. mode – Whether your list is public or private. Values can be public or private. Lists are public by default if no mode is specified.
  940. description – The description to give the list.
  941. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  942. owner_id – The user ID of the user who owns the list being requested by a slug.
  943.  
  944. Return type: List object
  945.  
  946. API.lists_all([screen_name][, user_id][, reverse])
  947.  
  948. Returns all lists the authenticating or specified user subscribes to, including their own. The user is specified using the user_id or screen_name parameters. If no user is given, the authenticating user is used.
  949.  
  950. A maximum of 100 results will be returned by this call. Subscribed lists are returned first, followed by owned lists. This means that if a user subscribes to 90 lists and owns 20 lists, this method returns 90 subscriptions and 10 owned lists. The reverse method returns owned lists first, so with reverse=true, 20 owned lists and 80 subscriptions would be returned.
  951.  
  952. Parameters:
  953. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  954. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  955. reverse – A boolean indicating if you would like owned lists to be returned first. See description above for information on how this parameter works.
  956.  
  957. Return type: list of List objects
  958.  
  959. API.lists_memberships([screen_name][, user_id][, filter_to_owned_lists][, cursor][, count])
  960.  
  961. Returns the lists the specified user has been added to. If user_id or screen_name are not provided, the memberships for the authenticating user are returned.
  962.  
  963. Parameters:
  964. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  965. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  966. filter_to_owned_lists – A boolean indicating whether to return just lists the authenticating user owns, and the user represented by user_id or screen_name is a member of.
  967. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  968. count – The number of results to try and retrieve per page.
  969.  
  970. Return type: list of List objects
  971.  
  972. API.lists_subscriptions([screen_name][, user_id][, cursor][, count])
  973.  
  974. Obtain a collection of the lists the specified user is subscribed to, 20 lists per page by default. Does not include the user’s own lists.
  975.  
  976. Parameters:
  977. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  978. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  979. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  980. count – The number of results to try and retrieve per page.
  981.  
  982. Return type: list of List objects
  983.  
  984. API.list_timeline(list_id/slug[, owner_id/owner_screen_name][, since_id][, max_id][, count][, include_entities][, include_rts])
  985.  
  986. Returns a timeline of tweets authored by members of the specified list. Retweets are included by default. Use the include_rts=false parameter to omit retweets.
  987.  
  988. Parameters:
  989. list_id – The numerical id of the list.
  990. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  991. owner_id – The user ID of the user who owns the list being requested by a slug.
  992. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  993. since_id – Returns only statuses with an ID greater than (that is, more recent than) the specified ID.
  994. max_id – Returns only statuses with an ID less than (that is, older than) or equal to the specified ID.
  995. count – The number of results to try and retrieve per page.
  996. include_entities – The entities node will not be included when set to false. Defaults to true.
  997. include_rts – A boolean indicating whether the list timeline will contain native retweets (if they exist) in addition to the standard stream of tweets. The output format of retweeted tweets is identical to the representation you see in home_timeline.
  998.  
  999. Return type: list of Status objects
  1000.  
  1001. API.get_list(list_id/slug[, owner_id/owner_screen_name])
  1002.  
  1003. Returns the specified list. Private lists will only be shown if the authenticated user owns the specified list.
  1004.  
  1005. Parameters:
  1006. list_id – The numerical id of the list.
  1007. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  1008. owner_id – The user ID of the user who owns the list being requested by a slug.
  1009. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  1010.  
  1011. Return type: List object
  1012.  
  1013. API.add_list_member(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  1014.  
  1015. Add a member to a list. The authenticated user must own the list to be able to add members to it. Lists are limited to 5,000 members.
  1016.  
  1017. Parameters:
  1018. list_id – The numerical id of the list.
  1019. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  1020. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  1021. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  1022. owner_id – The user ID of the user who owns the list being requested by a slug.
  1023. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  1024.  
  1025. Return type: List object
  1026.  
  1027. API.add_list_members(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  1028.  
  1029. Add up to 100 members to a list. The authenticated user must own the list to be able to add members to it. Lists are limited to 5,000 members.
  1030.  
  1031. Parameters:
  1032. list_id – The numerical id of the list.
  1033. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  1034. screen_name – A comma separated list of screen names, up to 100 are allowed in a single request
  1035. user_id – A comma separated list of user IDs, up to 100 are allowed in a single request
  1036. owner_id – The user ID of the user who owns the list being requested by a slug.
  1037. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  1038.  
  1039. Return type: List object
  1040.  
  1041. API.remove_list_member(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  1042.  
  1043. Removes the specified member from the list. The authenticated user must be the list’s owner to remove members from the list.
  1044.  
  1045. Parameters:
  1046. list_id – The numerical id of the list.
  1047. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  1048. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  1049. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  1050. owner_id – The user ID of the user who owns the list being requested by a slug.
  1051. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  1052.  
  1053. Return type: List object
  1054.  
  1055. API.remove_list_members(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  1056.  
  1057. Remove up to 100 members from a list. The authenticated user must own the list to be able to remove members from it. Lists are limited to 5,000 members.
  1058.  
  1059. Parameters:
  1060. list_id – The numerical id of the list.
  1061. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  1062. screen_name – A comma separated list of screen names, up to 100 are allowed in a single request
  1063. user_id – A comma separated list of user IDs, up to 100 are allowed in a single request
  1064. owner_id – The user ID of the user who owns the list being requested by a slug.
  1065. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  1066.  
  1067. Return type: List object
  1068.  
  1069. API.list_members(list_id/slug[, owner_id/owner_screen_name][, cursor])
  1070.  
  1071. Returns the members of the specified list.
  1072.  
  1073. Parameters:
  1074. list_id – The numerical id of the list.
  1075. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  1076. owner_id – The user ID of the user who owns the list being requested by a slug.
  1077. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  1078. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  1079.  
  1080. Return type: list of User objects
  1081.  
  1082. API.show_list_member(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  1083.  
  1084. Check if the specified user is a member of the specified list.
  1085.  
  1086. Parameters:
  1087. list_id – The numerical id of the list.
  1088. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  1089. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  1090. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  1091. owner_id – The user ID of the user who owns the list being requested by a slug.
  1092. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  1093.  
  1094. Return type: User object if user is a member of list
  1095.  
  1096. API.subscribe_list(list_id/slug[, owner_id/owner_screen_name])
  1097.  
  1098. Subscribes the authenticated user to the specified list.
  1099.  
  1100. Parameters:
  1101. list_id – The numerical id of the list.
  1102. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  1103. owner_id – The user ID of the user who owns the list being requested by a slug.
  1104. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  1105.  
  1106. Return type: List object
  1107.  
  1108. API.unsubscribe_list(list_id/slug[, owner_id/owner_screen_name])
  1109.  
  1110. Unsubscribes the authenticated user from the specified list.
  1111.  
  1112. Parameters:
  1113. list_id – The numerical id of the list.
  1114. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  1115. owner_id – The user ID of the user who owns the list being requested by a slug.
  1116. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  1117.  
  1118. Return type: List object
  1119.  
  1120. API.list_subscribers(list_id/slug[, owner_id/owner_screen_name][, cursor][, count][, include_entities][, skip_status])
  1121.  
  1122. Returns the subscribers of the specified list. Private list subscribers will only be shown if the authenticated user owns the specified list.
  1123.  
  1124. Parameters:
  1125. list_id – The numerical id of the list.
  1126. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  1127. owner_id – The user ID of the user who owns the list being requested by a slug.
  1128. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  1129. cursor – Breaks the results into pages. Provide a value of -1 to begin paging. Provide values as returned to in the response body’s next_cursor and previous_cursor attributes to page back and forth in the list.
  1130. count – The number of results to try and retrieve per page.
  1131. include_entities – The entities node will not be included when set to false. Defaults to true.
  1132. skip_status – A boolean indicating whether statuses will not be included in the returned user objects. Defaults to false.
  1133.  
  1134. Return type: list of User objects
  1135.  
  1136. API.show_list_subscriber(list_id/slug, screen_name/user_id[, owner_id/owner_screen_name])
  1137.  
  1138. Check if the specified user is a subscriber of the specified list.
  1139.  
  1140. Parameters:
  1141. list_id – The numerical id of the list.
  1142. slug – You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you’ll also have to specify the list owner using the owner_id or owner_screen_name parameters.
  1143. screen_name – Specifies the screen name of the user. Helpful for disambiguating when a valid screen name is also a user ID.
  1144. user_id – Specifies the ID of the user. Helpful for disambiguating when a valid user ID is also a valid screen name.
  1145. owner_id – The user ID of the user who owns the list being requested by a slug.
  1146. owner_screen_name – The screen name of the user who owns the list being requested by a slug.
  1147.  
  1148. Return type: User object if user is subscribed to list
  1149.  
  1150. ==Trends Methods
  1151.  
  1152. API.trends_available()
  1153.  
  1154. Returns the locations that Twitter has trending topic information for. The response is an array of “locations” that encode the location’s WOEID (a Yahoo! Where On Earth ID) and some other human-readable information such as a canonical name and country the location belongs in.
  1155. Return type: JSON object
  1156.  
  1157. API.trends_place(id[, exclude])
  1158.  
  1159. Returns the top 50 trending topics for a specific WOEID, if trending information is available for it.
  1160. The response is an array of “trend” objects that encode the name of the trending topic, the query parameter that can be used to search for the topic on Twitter Search, and the Twitter Search URL.
  1161. This information is cached for 5 minutes. Requesting more frequently than that will not return any more data, and will count against your rate limit usage.
  1162. The tweet_volume for the last 24 hours is also returned for many trends if this is available.
  1163.  
  1164. Parameters:
  1165. id – The Yahoo! Where On Earth ID of the location to return trending information for. Global information is available by using 1 as the WOEID.
  1166. exclude – Setting this equal to hashtags will remove all hashtags from the trends list.
  1167.  
  1168. Return type: JSON object
  1169.  
  1170. API.trends_closest(lat, long)
  1171.  
  1172. Returns the locations that Twitter has trending topic information for, closest to a specified location.
  1173. The response is an array of “locations” that encode the location’s WOEID and some other human-readable information such as a canonical name and country the location belongs in.
  1174. A WOEID is a Yahoo! Where On Earth ID.
  1175.  
  1176. Parameters:
  1177. lat – If provided with a long parameter the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair. The valid ranges for longitude is -180.0 to +180.0 (West is negative, East is positive) inclusive.
  1178. long – If provided with a lat parameter the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair. The valid ranges for longitude is -180.0 to +180.0 (West is negative, East is positive) inclusive.
  1179.  
  1180. Return type: JSON object
  1181.  
  1182. ==Geo Methods
  1183.  
  1184. API.reverse_geocode([lat][, long][, accuracy][, granularity][, max_results])
  1185.  
  1186. Given a latitude and longitude, looks for places (cities and neighbourhoods) whose IDs can be specified in a call to update_status() to appear as the name of the location. This call provides a detailed response about the location in question; the nearby_places() function should be preferred for getting a list of places nearby without great detail.
  1187.  
  1188. Parameters:
  1189. lat – The location’s latitude.
  1190. long – The location’s longitude.
  1191. accuracy – Specify the “region” in which to search, such as a number (then this is a radius in meters, but it can also take a string that is suffixed with ft to specify feet). If this is not passed in, then it is assumed to be 0m
  1192. granularity – Assumed to be neighborhood by default; can also be city.
  1193. max_results – A hint as to the maximum number of results to return. This is only a guideline, which may not be adhered to.
  1194.  
  1195. API.geo_id(id)
  1196.  
  1197. Given id of a place, provide more details about that place.
  1198.  
  1199. Parameters:
  1200. id – Valid Twitter ID of a location.
  1201.  
  1202. ==Utility methods
  1203.  
  1204. API.configuration()
  1205.  
  1206. Returns the current configuration used by Twitter including twitter.com slugs which are not usernames, maximum photo resolutions, and t.co shortened URL length. It is recommended applications request this endpoint when they are loaded, but no more than once a day.
  1207.  
  1208. ==Media methods
  1209.  
  1210. API.media_upload(filename[, file])
  1211.  
  1212. Use this endpoint to upload images to Twitter.
  1213.  
  1214. Parameters:
  1215. filename – The filename of the image to upload. This will automatically be opened unless file is specified.
  1216. file – A file object, which will be used instead of opening filename. filename is still required, for MIME type detection and to use as a form field in the POST data.
  1217.  
  1218. Return type: Media object
  1219.  
  1220. API.create_media_metadata(media_id, alt_text)
  1221.  
  1222. This endpoint can be used to provide additional information about the uploaded media_id. This feature is currently only supported for images and GIFs. Call this endpoint to attach additional metadata such as image alt text.
  1223.  
  1224. Parameters:
  1225. media_id – The ID of the media to add alt text to.
  1226. alt_text – The alt text to add to the image.
  1227.  
  1228. tweepy.error — Exceptions
  1229.  
  1230. The exceptions are available in the tweepy module directly, which means tweepy.error itself does not need to be imported. For example, tweepy.error.TweepError is available as tweepy.TweepError.
  1231.  
  1232. exception TweepError
  1233.  
  1234. The main exception Tweepy uses. Is raised for a number of things.
  1235. When a TweepError is raised due to an error Twitter responded with, the error code (as described in the API documentation) can be accessed at TweepError.response.text. Note, however, that TweepErrors also may be raised with other things as message (for example plain error reason strings).
  1236.  
  1237. exception RateLimitError
  1238.  
  1239. Is raised when an API method fails due to hitting Twitter’s rate limit. Makes for easy handling of the rate limit specifically.
  1240. Inherits from TweepError, so except TweepError will catch a RateLimitError too.
  1241.  
  1242. Footnotes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement