This demo uses Juniper library to run code on mybinder.org. The code uses twarc to get the latest tweets about a search query, using the Twitter API.
The demo is safe for using the API, as it circumvents the cross-origin request limitation of the Twitter API, because of which one cannot directly get the response the Twitter API in browser side javascript code.
Another usability issue which I have addressed here is to save the twitter credentials in the client's localStorage, which makes using the page on a refresh much easier. The local storage is also used to save the JSON data returned by the API. This ensures that the page is not making multiple requests to fetch the same data.
sctg_data
. If the data from a previous iteration is available the status line will show its size and search query used.Save credentials
button. This will create a code block with the Run
button.Run
to run the code for fetching tweets. By default around 500 pages of tweets are fetched. Parse output
. This saves the data in localStorage.const data = JSON.parse(localStorage.getItem("sctg_data"));
import json a = {f"{i}": i for i in range(10)} print(json.dumps(a))