Update Twitter Endpoints & Internal Functions
* Twitter Endpoints are now in the order of https://dev.twitter.com/docs/api/1.1 * No need to repeat search function internally when it is available via `twitter_endpoints.py` * Make `searchGen` use self.search, instead of self.get with the full search url
This commit is contained in:
parent
dfca6c533e
commit
a172136f3e
5 changed files with 270 additions and 282 deletions
|
|
@ -10,50 +10,97 @@
|
|||
|
||||
i.e, in this case, if I pass version = 47 to any function, {{version}} will be replaced
|
||||
with 47, instead of defaulting to 1 (said defaulting takes place at conversion time).
|
||||
|
||||
This map is organized the order functions are documented at:
|
||||
https://dev.twitter.com/docs/api/1.1
|
||||
"""
|
||||
|
||||
# Base Twitter API url, no need to repeat this junk...
|
||||
base_url = 'http://api.twitter.com/{{version}}'
|
||||
|
||||
api_table = {
|
||||
'getRateLimitStatus': {
|
||||
'url': '/application/rate_limit_status.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
'verifyCredentials': {
|
||||
'url': '/account/verify_credentials.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
'endSession': {
|
||||
'url': '/account/end_session.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
# Timeline methods
|
||||
'getHomeTimeline': {
|
||||
'url': '/statuses/home_timeline.json',
|
||||
# Timelines
|
||||
'getMentionsTimeline': {
|
||||
'url': 'statuses/mentions_timeline',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getUserTimeline': {
|
||||
'url': '/statuses/user_timeline.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
# Interfacing with friends/followers
|
||||
'getUserMentions': {
|
||||
'url': '/statuses/mentions.json',
|
||||
'getHomeTimeline': {
|
||||
'url': '/statuses/home_timeline.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'createFriendship': {
|
||||
'url': '/friendships/create.json',
|
||||
'retweetedOfMe': {
|
||||
'url': '/statuses/retweets_of_me.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
|
||||
# Tweets
|
||||
'getRetweets': {
|
||||
'url': '/statuses/retweets/{{id}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'showStatus': {
|
||||
'url': '/statuses/show/{{id}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'destroyStatus': {
|
||||
'url': '/statuses/destroy/{{id}}.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'destroyFriendship': {
|
||||
'url': '/friendships/destroy.json',
|
||||
'updateStatus': {
|
||||
'url': '/statuses/update.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'retweet': {
|
||||
'url': '/statuses/retweet/{{id}}.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
# See twython.py for update_status_with_media
|
||||
'getOembedTweet': {
|
||||
'url': '/statuses/oembed.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
|
||||
# Search
|
||||
'search': {
|
||||
'url': '/search/tweets.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
|
||||
# Direct Messages
|
||||
'getDirectMessages': {
|
||||
'url': '/direct_messages.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getSentMessages': {
|
||||
'url': '/direct_messages/sent.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getDirectMessage': {
|
||||
'url': '/direct_messages/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'destroyDirectMessage': {
|
||||
'url': '/direct_messages/destroy/{{id}}.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'sendDirectMessage': {
|
||||
'url': '/direct_messages/new.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
|
||||
# Friends & Followers
|
||||
'getUserIdsOfBlockedRetweets': {
|
||||
'url': '/friendships/no_retweets/ids.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFriendsIDs': {
|
||||
'url': '/friends/ids.json',
|
||||
'method': 'GET',
|
||||
|
|
@ -62,12 +109,8 @@ api_table = {
|
|||
'url': '/followers/ids.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFriendsList': {
|
||||
'url': '/friends/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFollowersList': {
|
||||
'url': '/followers/list.json',
|
||||
'lookupFriendships': {
|
||||
'url': '/friendships/lookup.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getIncomingFriendshipIDs': {
|
||||
|
|
@ -78,119 +121,67 @@ api_table = {
|
|||
'url': '/friendships/outgoing.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
# Retweets
|
||||
'reTweet': {
|
||||
'url': '/statuses/retweet/{{id}}.json',
|
||||
'createFriendship': {
|
||||
'url': '/friendships/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'getRetweets': {
|
||||
'url': '/statuses/retweets/{{id}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'retweetedOfMe': {
|
||||
'url': '/statuses/retweets_of_me.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'retweetedByMe': {
|
||||
'url': '/statuses/retweeted_by_me.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'retweetedToMe': {
|
||||
'url': '/statuses/retweeted_to_me.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
# User methods
|
||||
'showUser': {
|
||||
'url': '/users/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'searchUsers': {
|
||||
'url': '/users/search.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
'lookupUser': {
|
||||
'url': '/users/lookup.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
# Status methods - showing, updating, destroying, etc.
|
||||
'showStatus': {
|
||||
'url': '/statuses/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'updateStatus': {
|
||||
'url': '/statuses/update.json',
|
||||
'destroyFriendship': {
|
||||
'url': '/friendships/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'destroyStatus': {
|
||||
'url': '/statuses/destroy/{{id}}.json',
|
||||
'updateFriendship': {
|
||||
'url': '/friendships/update.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
# Direct Messages - getting, sending, effing, etc.
|
||||
'getDirectMessages': {
|
||||
'url': '/direct_messages.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getSentMessages': {
|
||||
'url': '/direct_messages/sent.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'sendDirectMessage': {
|
||||
'url': '/direct_messages/new.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'destroyDirectMessage': {
|
||||
'url': '/direct_messages/destroy/{{id}}.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
# Friendship methods
|
||||
'checkIfFriendshipExists': {
|
||||
'url': '/friendships/exists.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'showFriendship': {
|
||||
'url': '/friendships/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFriendsList': {
|
||||
'url': '/friends/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFollowersList': {
|
||||
'url': '/followers/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
# Profile methods
|
||||
|
||||
# Users
|
||||
'getAccountSettings': {
|
||||
'url': '/account/settings.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'verifyCredentials': {
|
||||
'url': '/account/verify_credentials.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'updateAccountSettings': {
|
||||
'url': '/account/settings.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'updateDeliveryService': {
|
||||
'url': '/account/update_delivery_device.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'updateProfile': {
|
||||
'url': '/account/update_profile.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
# See twython.py for update_profile_background_image
|
||||
'updateProfileColors': {
|
||||
'url': '/account/update_profile_colors.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'myTotals': {
|
||||
'url': '/account/totals.json',
|
||||
# See twython.py for update_profile_image
|
||||
'listBlocks': {
|
||||
'url': '/blocks/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'removeProfileBanner': {
|
||||
'url': '/account/remove_profile_banner.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
# Favorites methods
|
||||
'getFavorites': {
|
||||
'url': '/favorites.json',
|
||||
'listBlockIds': {
|
||||
'url': '/blocks/ids.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'createFavorite': {
|
||||
'url': '/favorites/create/{{id}}.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'destroyFavorite': {
|
||||
'url': '/favorites/destroy/{{id}}.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
# Blocking methods
|
||||
'createBlock': {
|
||||
'url': '/blocks/create/{{id}}.json',
|
||||
'method': 'POST',
|
||||
|
|
@ -199,119 +190,79 @@ api_table = {
|
|||
'url': '/blocks/destroy/{{id}}.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'getBlocking': {
|
||||
'url': '/blocks/blocking.json',
|
||||
'lookupUser': {
|
||||
'url': '/users/lookup.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getBlockedIDs': {
|
||||
'url': '/blocks/blocking/ids.json',
|
||||
'showUser': {
|
||||
'url': '/users/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'checkIfBlockExists': {
|
||||
'url': '/blocks/exists.json',
|
||||
'searchUsers': {
|
||||
'url': '/users/search.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
# Trending methods
|
||||
'getCurrentTrends': {
|
||||
'url': '/trends/current.json',
|
||||
'getContributees': {
|
||||
'url': '/users/contributees.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getDailyTrends': {
|
||||
'url': '/trends/daily.json',
|
||||
'getContributors': {
|
||||
'url': '/users/contributors.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getWeeklyTrends': {
|
||||
'url': '/trends/weekly.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'availableTrends': {
|
||||
'url': '/trends/available.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'trendsByLocation': {
|
||||
'url': '/trends/{{woeid}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
# Saved Searches
|
||||
'getSavedSearches': {
|
||||
'url': '/saved_searches.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'showSavedSearch': {
|
||||
'url': '/saved_searches/show/{{id}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'createSavedSearch': {
|
||||
'url': '/saved_searches/create.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'destroySavedSearch': {
|
||||
'url': '/saved_searches/destroy/{{id}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
# List API methods/endpoints. Fairly exhaustive and annoying in general. ;P
|
||||
'createList': {
|
||||
'url': '/lists/create.json',
|
||||
'removeProfileBanner': {
|
||||
'url': '/account/remove_profile_banner.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'updateList': {
|
||||
'url': '/lists/update.json',
|
||||
# See twython.py for update_profile_banner
|
||||
|
||||
|
||||
# Suggested Users
|
||||
'getUserSuggestionsBySlug': {
|
||||
'url': '/users/suggestions/{{slug}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getUserSuggestions': {
|
||||
'url': '/users/suggestions.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getUserSuggestionsStatusesBySlug': {
|
||||
'url': '/users/suggestions/{{slug}}/members.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
|
||||
# Favorites
|
||||
'getFavorites': {
|
||||
'url': '/favorites/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'destroyFavorite': {
|
||||
'url': '/favorites/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'createFavorite': {
|
||||
'url': '/favorites/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
|
||||
# Lists
|
||||
'showLists': {
|
||||
'url': '/lists.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListMemberships': {
|
||||
'url': '/lists/memberships.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListSubscriptions': {
|
||||
'url': '/lists/subscriptions.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'isListSubscriber': {
|
||||
'url': '/lists/subscribers/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'deleteList': {
|
||||
'url': '/lists/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'getListTimeline': {
|
||||
'url': '/{{username}}/lists/{{list_id}}/statuses.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getSpecificList': {
|
||||
'url': '/lists/show.json',
|
||||
'url': '/lists/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListStatuses': {
|
||||
'url': '/lists/statuses.json',
|
||||
'method': 'GET'
|
||||
},
|
||||
'isListMember': {
|
||||
'url': '/lists/members/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'addListMember': {
|
||||
'url': '/lists/members/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'getListMembers': {
|
||||
'url': '/lists/members.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'deleteListMember': {
|
||||
'url': '/lists/members/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'deleteListMembers': {
|
||||
'url': '/lists/members/destroy_all.json',
|
||||
'method': 'POST'
|
||||
'getListMemberships': {
|
||||
'url': '/lists/memberships.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListSubscribers': {
|
||||
'url': '/lists/subscribers.json',
|
||||
|
|
@ -321,34 +272,121 @@ api_table = {
|
|||
'url': '/lists/subscribers/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'isListSubscriber': {
|
||||
'url': '/lists/subscribers/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'unsubscribeFromList': {
|
||||
'url': '/lists/subscribers/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
# The one-offs
|
||||
'notificationFollow': {
|
||||
'url': '/notifications/follow/follow.json',
|
||||
'method': 'POST',
|
||||
'createListMembers': {
|
||||
'url': '/lists/members/create_all.json',
|
||||
'method': 'POST'
|
||||
},
|
||||
'notificationLeave': {
|
||||
'url': '/notifications/leave/leave.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'updateDeliveryService': {
|
||||
'url': '/account/update_delivery_device.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'reportSpam': {
|
||||
'url': '/report_spam.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'getOembedTweet': {
|
||||
'url': '/statuses/oembed.json',
|
||||
'isListMember': {
|
||||
'url': '/lists/members/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListMembers': {
|
||||
'url': '/lists/members.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'addListMember': {
|
||||
'url': '/lists/members/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'deleteList': {
|
||||
'url': '/lists/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'updateList': {
|
||||
'url': '/lists/update.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'createList': {
|
||||
'url': '/lists/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'getSpecificList': {
|
||||
'url': '/lists/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListSubscriptions': {
|
||||
'url': '/lists/subscriptions.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'deleteListMembers': {
|
||||
'url': '/lists/members/destroy_all.json',
|
||||
'method': 'POST'
|
||||
},
|
||||
|
||||
|
||||
# Saved Searches
|
||||
'getSavedSearches': {
|
||||
'url': '/saved_searches/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'showSavedSearch': {
|
||||
'url': '/saved_searches/show/{{id}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'createSavedSearch': {
|
||||
'url': '/saved_searches/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'destroySavedSearch': {
|
||||
'url': '/saved_searches/destroy/{{id}}.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
|
||||
# Places & Geo
|
||||
'getGeoInfo': {
|
||||
'url': '/geo/id/{{place_id}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'reverseGeocode': {
|
||||
'url': '/geo/reverse_geocode.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'searchGeo': {
|
||||
'url': '/geo/search.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getSimilarPlaces': {
|
||||
'url': '/geo/similar_places.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'createPlace': {
|
||||
'url': '/geo/place.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
|
||||
# Trends
|
||||
'getPlaceTrends': {
|
||||
'url': '/trends/place.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getAvailableTrends': {
|
||||
'url': '/trends/available.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getClosestTrends': {
|
||||
'url': '/trends/closest.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
|
||||
# Spam Reporting
|
||||
'reportSpam': {
|
||||
'url': '/users/report_spam.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
# from https://dev.twitter.com/docs/error-codes-responses
|
||||
twitter_http_status_codes = {
|
||||
200: ('OK', 'Success!'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue