官术网_书友最值得收藏!

  • Python Social Media Analytics
  • Siddhartha Chatterjee Michal Krystyanczuk
  • 145字
  • 2021-07-15 17:24:57

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.

主站蜘蛛池模板: 池州市| 溧水县| 定襄县| 信丰县| 景东| 临湘市| 文登市| 扶沟县| 东至县| 吴旗县| 朝阳市| 红安县| 武山县| 磐石市| 策勒县| 红原县| 石河子市| 响水县| 定安县| 万山特区| 湘潭县| 张家界市| 山丹县| 和龙市| 呼图壁县| 岳普湖县| 姚安县| 镶黄旗| 琼结县| 岐山县| 沭阳县| 白银市| 洪湖市| 鹿泉市| 嵊泗县| 双峰县| 马山县| 彭泽县| 桐庐县| 望都县| 化州市|