liveBook · Manning

Api client

As explained in Microservices Patterns, Second Edition

An API client is a software component that consumes operations or messages exposed by a service API.

An API client connects an application to a service through its API. It sends requests or asynchronous messages, processes incoming responses or messages, serializes outbound payloads, and deserializes inbound data into domain objects. section 8.1.7

Choose how the client models exchanged messages by weighing development effort, schema correctness, and type safety:

  • Use untyped structures such as maps or dictionaries, handwritten classes, code-generated classes, or libraries provided by the service team. section 8.1.7
  • Binary payload formats almost always use generated DTOs; text-based formats allow handwritten or generated DTOs, or untyped structures. section 8.1.7
  • Model only the message types or fields relevant to the client when a projection of the full schema is sufficient. section 8.1.7
Figure 8.3 An API client must have a data model of the messages that it exchanges with the service. The data model must serialize and deserialize correctly as defined by the schema. It can either be untyped (e.g. hash maps) or consist of handwritten or code-generated classes.
defining api client dtos

The diagram compares untyped and class-based message models and shows their serialization and deserialization responsibilities. section 8.1.7

How Microservices Patterns, Second Edition covers it

How deep it goes
Explains communication and serialization responsibilities, then compares DTO implementation options and selection factors.
Examples
Uses HTTP or gRPC requests, broker messages, and untyped, handwritten, or generated message models as examples.
What you can do after
Implement clients that serialize outbound payloads and deserialize incoming data into application domain objects.
How it connects
Connects API clients with data transfer objects, serialization, schemas, HTTP, gRPC, and message brokers.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.