
Selecting the endpoint
An endpoint indicates where a particular resource can be accessed. It is represented by an URL that contains the name of the action. Even though there are multiple endpoints for each API, we will focus on those used in the next chapters of the book. All other endpoints/actions you can find in the official API documentation.
The Twitter REST API allows clients to retrieve a sample of tweets based on search criteria. The search request is made up of a Boolean query with some additional optional parameters (to, from, list, url, and filter). We will store the endpoint URL for this resource in a url variable:
url_rest = "https://api.twitter.com/1.1/search/tweets.json"
Similarly, we will use an endpoint URL for the Streaming API that returns a random sample stream of statuses:
url_streaming = "https://stream.twitter.com/1.1/statuses/sample.json"
We will use both variables to retrieve and parse the data.