Building a custom Python client
Throughout the book, we accessed different social media platform through Python libraries, either officially supported by the social media server themselves or provided by third parties.
This section answers the question: what if they don't provide a Python client for their API (and there is no unofficial library either)?
HTTP made simple
In order to implement the calls to the desired API, the recommended library for easy HTTP interactions is requests. From our virtual environment, use the following command:
$ pip install requests
The requests library offers a straightforward interface to perform HTTP calls. In order to test the library, we're going to implement a simple client for the httpbin.org
service, a web service, that offers basic request/response interactions, perfect for our educational purposes.
The httpbin.org
web page (http://httpbin.org/), explains the various endpoints and their meaning. To showcase the use of the requests library, we will implement...