Writing an API Client
Why write an API client Most automation flows require interacting with HTTP APIs. Communicating with these APIs requires an HTTP client. A ubiquitous example of a client is a web browser. However, for most automation tasks, a web browser is too heavy. We turn to relatively lightweight clients like cURL or in Windows land Invoke-WebRequest. For automation purposes specifically, we often use the client provided by the language or a popular third-party client. In Python most developers default to using the Requests library. The native urllib.request module is perfectly fine albeit less ergonomic. I’ll be covering how to make a basic HTTP request in the languages that I frequently use later but for now we will be using Python. Generally, it is advisable to seek out an official API client provided by the developers of that API. For example, Stripe and Twilio both have official SDKs for various languages. These should be used instead of rolling your own client. It can be desirable to rol...