Skip to content

Instantly share code, notes, and snippets.

@bobquest33
Last active April 24, 2017 06:21
Show Gist options
  • Save bobquest33/919769bcf2e9e286fcb80ad31e8c811a to your computer and use it in GitHub Desktop.
Save bobquest33/919769bcf2e9e286fcb80ad31e8c811a to your computer and use it in GitHub Desktop.
100 Scripts in 30 Days challenge: Script 15— Finding Rate limit details for Twitter API
# -*- coding: utf-8 -*-
import os
import sys
import twitter
import toml
import glob
import json
import tweepy
for conffilename in glob.glob('conf\\*.toml'):
with open(conffilename) as conffile:
config = toml.loads(conffile.read())
APP_NAME = config["APP_NAME"]
CONSUMER_KEY = config["CONSUMER_KEY"]
CONSUMER_SECRET = config["CONSUMER_SECRET"]
access_token = config["access_token"]
access_token_secret = config["access_token_secret"]
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
ratelimitstat = api.rate_limit_status()
print( json.dumps(ratelimitstat, indent=1))
with open("ratelimit.json","w") as wp:
wp.write(json.dumps(ratelimitstat, indent=1))
APP_NAME = ""
CONSUMER_KEY = ""
CONSUMER_SECRET = ""
access_token = ""
access_token_secret = ""
{
"rate_limit_context": {
"access_token": ""
},
"resources": {
"lists": {
"/lists/list": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/lists/memberships": {
"limit": 75,
"remaining": 75,
"reset": 1492831633
},
"/lists/subscribers/show": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/lists/members": {
"limit": 900,
"remaining": 900,
"reset": 1492831633
},
"/lists/subscriptions": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/lists/show": {
"limit": 75,
"remaining": 75,
"reset": 1492831633
},
"/lists/ownerships": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/lists/subscribers": {
"limit": 180,
"remaining": 180,
"reset": 1492831633
},
"/lists/members/show": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/lists/statuses": {
"limit": 900,
"remaining": 900,
"reset": 1492831633
}
},
"application": {
"/application/rate_limit_status": {
"limit": 180,
"remaining": 179,
"reset": 1492831633
}
},
"mutes": {
"/mutes/users/list": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/mutes/users/ids": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"live_video_stream": {
"/live_video_stream/status/:id": {
"limit": 1000,
"remaining": 1000,
"reset": 1492831633
}
},
"friendships": {
"/friendships/outgoing": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/friendships/list": {
"limit": 200,
"remaining": 200,
"reset": 1492831633
},
"/friendships/no_retweets/ids": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/friendships/lookup": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/friendships/incoming": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/friendships/show": {
"limit": 180,
"remaining": 180,
"reset": 1492831633
}
},
"auth": {
"/auth/csrf_token": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"blocks": {
"/blocks/list": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/blocks/ids": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"geo": {
"/geo/similar_places": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/geo/id/:place_id": {
"limit": 75,
"remaining": 75,
"reset": 1492831633
},
"/geo/reverse_geocode": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/geo/search": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"users": {
"/users/report_spam": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/users/show/:id": {
"limit": 900,
"remaining": 900,
"reset": 1492831633
},
"/users/search": {
"limit": 900,
"remaining": 900,
"reset": 1492831633
},
"/users/suggestions/:slug": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/users/derived_info": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/users/profile_banner": {
"limit": 180,
"remaining": 180,
"reset": 1492831633
},
"/users/suggestions/:slug/members": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/users/lookup": {
"limit": 900,
"remaining": 900,
"reset": 1492831633
},
"/users/suggestions": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"followers": {
"/followers/ids": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/followers/list": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"collections": {
"/collections/list": {
"limit": 1000,
"remaining": 1000,
"reset": 1492831633
},
"/collections/entries": {
"limit": 1000,
"remaining": 1000,
"reset": 1492831633
},
"/collections/show": {
"limit": 1000,
"remaining": 1000,
"reset": 1492831633
}
},
"statuses": {
"/statuses/retweeters/ids": {
"limit": 75,
"remaining": 75,
"reset": 1492831633
},
"/statuses/retweets_of_me": {
"limit": 75,
"remaining": 75,
"reset": 1492831633
},
"/statuses/home_timeline": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/statuses/show/:id": {
"limit": 900,
"remaining": 900,
"reset": 1492831633
},
"/statuses/user_timeline": {
"limit": 900,
"remaining": 900,
"reset": 1492831633
},
"/statuses/friends": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/statuses/retweets/:id": {
"limit": 75,
"remaining": 75,
"reset": 1492831633
},
"/statuses/mentions_timeline": {
"limit": 75,
"remaining": 75,
"reset": 1492831633
},
"/statuses/oembed": {
"limit": 180,
"remaining": 180,
"reset": 1492831633
},
"/statuses/lookup": {
"limit": 900,
"remaining": 900,
"reset": 1492831633
}
},
"custom_profiles": {
"/custom_profiles/list": {
"limit": 180,
"remaining": 180,
"reset": 1492831633
},
"/custom_profiles/show": {
"limit": 180,
"remaining": 180,
"reset": 1492831633
}
},
"webhooks": {
"/webhooks/subscriptions/direct_messages": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/webhooks": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"contacts": {
"/contacts/uploaded_by": {
"limit": 300,
"remaining": 300,
"reset": 1492831633
},
"/contacts/users": {
"limit": 300,
"remaining": 300,
"reset": 1492831633
},
"/contacts/addressbook": {
"limit": 300,
"remaining": 300,
"reset": 1492831633
},
"/contacts/users_and_uploaded_by": {
"limit": 300,
"remaining": 300,
"reset": 1492831633
},
"/contacts/delete/status": {
"limit": 300,
"remaining": 300,
"reset": 1492831633
}
},
"tweet_prompts": {
"/tweet_prompts/report_interaction": {
"limit": 180,
"remaining": 180,
"reset": 1492831633
},
"/tweet_prompts/show": {
"limit": 180,
"remaining": 180,
"reset": 1492831633
}
},
"moments": {
"/moments/permissions": {
"limit": 300,
"remaining": 300,
"reset": 1492831633
}
},
"help": {
"/help/tos": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/help/configuration": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/help/privacy": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/help/settings": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/help/languages": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"feedback": {
"/feedback/show/:id": {
"limit": 180,
"remaining": 180,
"reset": 1492831633
},
"/feedback/events": {
"limit": 1000,
"remaining": 1000,
"reset": 1492831633
}
},
"business_experience": {
"/business_experience/dashboard_settings/destroy": {
"limit": 450,
"remaining": 450,
"reset": 1492831633
},
"/business_experience/dashboard_features": {
"limit": 450,
"remaining": 450,
"reset": 1492831633
},
"/business_experience/keywords": {
"limit": 450,
"remaining": 450,
"reset": 1492831633
},
"/business_experience/dashboard_settings/update": {
"limit": 450,
"remaining": 450,
"reset": 1492831633
},
"/business_experience/dashboard_settings/show": {
"limit": 450,
"remaining": 450,
"reset": 1492831633
}
},
"friends": {
"/friends/following/ids": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/friends/following/list": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/friends/list": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/friends/ids": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"drafts": {
"/drafts/statuses/update": {
"limit": 450,
"remaining": 450,
"reset": 1492831633
},
"/drafts/statuses/destroy": {
"limit": 450,
"remaining": 450,
"reset": 1492831633
},
"/drafts/statuses/ids": {
"limit": 450,
"remaining": 450,
"reset": 1492831633
},
"/drafts/statuses/list": {
"limit": 450,
"remaining": 450,
"reset": 1492831633
},
"/drafts/statuses/show": {
"limit": 450,
"remaining": 450,
"reset": 1492831633
},
"/drafts/statuses/create": {
"limit": 450,
"remaining": 450,
"reset": 1492831633
}
},
"direct_messages": {
"/direct_messages/sent": {
"limit": 300,
"remaining": 300,
"reset": 1492831633
},
"/direct_messages": {
"limit": 300,
"remaining": 300,
"reset": 1492831633
},
"/direct_messages/sent_and_received": {
"limit": 300,
"remaining": 300,
"reset": 1492831633
},
"/direct_messages/show": {
"limit": 300,
"remaining": 300,
"reset": 1492831633
},
"/direct_messages/events/list": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/direct_messages/events/show": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"media": {
"/media/upload": {
"limit": 500,
"remaining": 500,
"reset": 1492831633
}
},
"account_activity": {
"/account_activity/webhooks": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/account_activity/webhooks/:id/subscriptions": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"account": {
"/account/login_verification_enrollment": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/account/update_profile": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/account/verify_credentials": {
"limit": 75,
"remaining": 75,
"reset": 1492831633
},
"/account/settings": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"favorites": {
"/favorites/list": {
"limit": 75,
"remaining": 75,
"reset": 1492831633
}
},
"device": {
"/device/token": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"saved_searches": {
"/saved_searches/destroy/:id": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/saved_searches/show/:id": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
},
"/saved_searches/list": {
"limit": 15,
"remaining": 15,
"reset": 1492831633
}
},
"search": {
"/search/tweets": {
"limit": 180,
"remaining": 180,
"reset": 1492831633
}
},
"trends": {
"/trends/closest": {
"limit": 75,
"remaining": 74,
"reset": 1492831605
},
"/trends/available": {
"limit": 75,
"remaining": 75,
"reset": 1492831633
},
"/trends/place": {
"limit": 75,
"remaining": 75,
"reset": 1492831633
}
},
"live_pipeline": {
"/live_pipeline/events": {
"limit": 180,
"remaining": 180,
"reset": 1492831633
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment