Accessing web API and data formats

In this section, we will be exploring various APIs that are available on the web, send requests to them, and receive responses, before explaining how they work via the Python programming language.

Let's consider the following sample URL, https://www.someexampledomain.com. The API it provides comes with parameters, locators, and authentication. By using these, we can access the following resources:

  • https://api.someexampledomain.com 
  • https://api.someexampledomain.com/resource?key1=value1&key2=value2
  • https://api.someexampledomain.com/resource?api_key=ACCESS_KEY&key1=value1&key2=value2
  • https://api.someexampledomain.com/resource/v1/2019/01

Parameters or collections of key-value pairs are actually sets of predefined variables that are provided by the web. Usually, the API provides some sort of documentation or basic guidelines regarding its usage, HTTP methods, available keys and types, or permitted values that the key can receive, along with other information on the features that are supported by the API, as shown in the following screenshot: 

API details and links from https://sunrise-sunset.org/api

End users and systems can only use the API with the features and functions that the provider permits.

The following a number of actual API links and example calls that show the formats and parameters that are used in URLs:

Parameters such as key, api_key, apiKey and api-key are required for security and tracking measures and need to be obtained before you process any API requests. 

The API links and example calls in this section are linked to the resources they are listed on. For example, https://api.twitter.com/1.1/search/tweets.json?q=nasa&result_type=popular is listed on https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.249.209