This is part of a larger project with the objective of automatically displaying Twitter data in Adobe After Effects CC from a JSON file. My friend Arturo Bracero posted a complete tutorial about this topic on his personal blog.
In this repository, the python script tweet_to_json.py contains the necessary code to extract a JSON file from a tweet ID (the digits at the end of a tweet URL).
Using the script
First of all, you need to obtain your Twitter API credentials from https://apps.twitter.com/, if you still haven't done it.
Once you have it, simply substitute your own credentials on the four lines following the comment Twitter API credentials.
Then, you just call the program as
python tweet_to_json.py TWEET_ID, where TWEET_ID should be the numeric ID of the wanted tweet. For example, to get the JSON file from this tweet, run:
python tweet_to_json.py 932728419640492032
When calling the script, apart from the JSON file, the profile picture of the user that posted the tweet will also be saved. The image will be saved to 400x400 pixels by default. Adding an additional argument after the tweet ID while calling the script modifies the size of the saved image. For example, running the following code saves the image to 1000x1000 pixels:
python tweet_to_json.py 932728419640492032 1000