JSON APIs: Default design for common features

Posted Over 1 year ago. Visible to the public. Repeats.

When you build a JSON API you need to come up with a style to represent attributes, pagination, errors or including associated objects. Instead of reinventing the wheel, you may reuse successful API designs.

JSON API

JSON:API Show archive.org snapshot specifies common features found in most JSON APIs, like pagination, ordering and nested resources. The spec looks very similar to how one would build an API with Rails and uses similar patterns. Even if you don't plan on supporting the whole spec, it can still make sense to know how the spec would solve a problem.

Following a certain set of rules for you API can make it easier for your clients to consume it. Clients can use client libraries Show archive.org snapshot to access your API and can read up on the JSON:API spec to get a basic understanding on how to use your API.

Stripe API

If you don't like the conventions of JSON-API, consider the style of an existing JSON API that you enjoy working with. For instance the Stripe API Show archive.org snapshot is a good source of inspiration.

General advice

Niklas Hä.
Last edit
6 months ago
Henning Koch
Keywords
REST, API
License
Source code in this card is licensed under the MIT License.
Posted by Niklas Hä. to makandra dev (2022-09-07 07:55)