Creating the API
As the first step, let’s see how we can connect to the REST API provided by the Cat API site and extract the content that we need.
Parsing Cat Picture Links
In order to fetch our links, we need to create an HTTP client. Let’s use the excellent clj-http library for this task. As always, we start by adding the dependency to our project.clj file.
|||:dependencies [... [clj-http "2.0.0"]]|
Note that if your application is running, you need to restart it in order for the library to become available.
With the library in place, we can navigate to the swagger-service.routes.services namespace and add the code for reading the links. Let’s first reference it in our namespace as client.
|||[clj-http.client :as client]) ...|