This repo contains a best practice exemplar for using Uplink to write API clients. Uplink provides a handy declaritive interface for creating classes that make requests to web API's. Some challenges can emerge when using it however:
- unstructured data in post requests and json responses
- testing is tricky
- typing
Some of the above can be mitigated by using features of Uplink and some by using appropriate design patterns.
This repository contains a best practices exemplar of an Uplink API client. Key features include:
- Handling error responses by raising an exception.
- Making use of deserialisation support with Pydantic models to structure return data.
- Decoupling the methods that make API calls from the public interface of the client.
- Support for testing using targeted mocking of the requests module.