Example of using mybinder.org to get tweets via API

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.

Usage

Query data

search_query
consumer_key
consumer_secret
access_token_key
access_token_secret
import json

a = {f"{i}": i for i in range(10)}
print(json.dumps(a))