Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Designing and maintaining an API standard #417

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

aaronrussellHO
Copy link
Contributor

Is this pull request a content or a code change? (Please fill in the relevant section and delete the other)

Code change

I can confirm:

Accessibility considerations

or

  • This change might impact accessibility, automated aXe tests cover the impact

or

  • This change might impact accessibility and is not covered by automated aXe tests - manual testing has been performed
    (If the change might impact accessibility then please add some further information here)

Content change

I can confirm:

  • Content does not include any code or configuration changes (excluding frontmatter information)
  • Content meets the content standards
    e.g. Writing a principle and Writing a standard
  • Content is suitable to open source, i.e.:
    • Content does not relate to unreleased gov policy
    • Content does not refer to anti-fraud mechanisms
    • Content does not include sensitive business logic
  • Last updated date for content is correct

@aaronrussellHO aaronrussellHO requested a review from a team as a code owner May 7, 2024 08:59
@aaronrussellHO aaronrussellHO changed the title WIP: Designing and maintaining an API standard Designing and maintaining an API standard Oct 14, 2024
Copy link
Contributor

@jeff-horton-ho-sas jeff-horton-ho-sas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few clarifications + typos


Using appropiate nouns for resource names rather than actions, because nouns describe the data, and can be used hierarchically to allow a consumer to navigate an API more easily. An example may be to use /devices to list all devices and /devices/:id to list the attributes of a particular device.

Although this advice is given on the [RESTful resource naming page](https://restfulapi.net/resource-naming/) it details a recommended approach to help regardless on type of API (RESTful, GraphQL etc).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Although this advice is given on the [RESTful resource naming page](https://restfulapi.net/resource-naming/) it details a recommended approach to help regardless on type of API (RESTful, GraphQL etc).
Although this advice is given on the [RESTful resource naming page](https://restfulapi.net/resource-naming/) it details a recommended approach to help regardless of the type of API (RESTful, GraphQL etc).


Knowing how your API scales helps to make sure your API is resilient and can handle peaks of traffic.

A stateless API means that the cliant is responsible for providing information about authantication etc. In turn, this means an application can then scale easily horizontally, as it doesn't matter which instance a client connects to.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A stateless API means that the cliant is responsible for providing information about authantication etc. In turn, this means an application can then scale easily horizontally, as it doesn't matter which instance a client connects to.
A stateless API means that the client is responsible for providing information about authentication etc. In turn, this means an application can then scale easily horizontally, as it doesn't matter which instance a client connects to.


A stateless API means that the cliant is responsible for providing information about authantication etc. In turn, this means an application can then scale easily horizontally, as it doesn't matter which instance a client connects to.

Using other techniques such as asynchronous code, multithreading and an event driven approach can also help scale an API.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Using other techniques such as asynchronous code, multithreading and an event driven approach can also help scale an API.
Using techniques such as asynchronous code, multithreading or an event driven approach can help scale an API.


You should also consider how you a version should be depreciated, and communicate this with any consumers.

### You MUST have appropriate status codes returning from each endpoint 
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### You MUST have appropriate status codes returning from each endpoint 
### You MUST return appropriate status codes from each endpoint

## Requirement(s)

- [You MUST include a form of versioning to your API](#you-must-include-a-form-of-versioning-to-your-api)
- [You MUST have appropriate status codes returning from each endpoint](#you-must-have-appropriate-status-codes-returning-from-each-endpoint)
Copy link
Contributor

@jeff-horton-ho-sas jeff-horton-ho-sas Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [You MUST have appropriate status codes returning from each endpoint](#you-must-have-appropriate-status-codes-returning-from-each-endpoint)
- [You MUST return appropriate status codes from each endpoint](#you-must-return-appropriate-status-codes-from-each-endpoint)


Although this advice is given on the [RESTful resource naming page](https://restfulapi.net/resource-naming/) it details a recommended approach to help regardless on type of API (RESTful, GraphQL etc).

### You MUST include some way to observe your API 
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### You MUST include some way to observe your API 
### You MUST include some way to observe your API


Authentication and authorisation are really important for API, this can mean restricting certain tasks or functions to a limited number of users. A user should have the least privilege possible. Role Based Access Control (RBAC) is an example of how to implement this.

### You MUST test your API 
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### You MUST test your API 
### You MUST test your API


When maintaining an API we must have a way to make sure that is in good health and there is a way to trace activity.

It is recommended that logs are used however the sensitivity of the data logged must also be considered.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It is recommended that logs are used however the sensitivity of the data logged must also be considered.
Application logs that are sent to an aggregation service are recommended for this. Review [the securing application logging pattern](https://engineering.homeoffice.gov.uk/patterns/securing-application-logging/) if your requests or responses could contain sensitive information.


Using an API Specification will help define your API endpoints, support is wide, with a wide community using it.

A good example is using OpenAPI Swagger to help build, maintain and document your API.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A good example is using OpenAPI Swagger to help build, maintain and document your API.
An example is using [OpenAPI (previously Swagger)](https://www.openapis.org/) to help build, maintain and document your API.


When designing an API aspects such as naming and versioning will help with not only the maintenance of the API, but also help the consumers of your API.

Been clear about how your API can be used, and what is happening can help a consumer build a better applicationby adding proper error messaging as well as using the latest versions of endpoints.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few typos on this line I think? Been clear, and what is happening, applicationby


### You MUST use an API Specification

Using an API Specification will help define your API endpoints, support is wide, with a wide community using it.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Using an API Specification will help define your API endpoints, support is wide, with a wide community using it.
Using an API Specification will help define your API endpoints and is widely supported by a large community.


There are a few [different ways of versioning](https://www.xmatters.com/blog/blog-four-rest-api-versioning-strategies) an API, via the URI path, query parameters or headers. You will also need to decide a versioning strategy, whether that be per endpoint or for the whole API.

You should also consider how you a version should be depreciated, and communicate this with any consumers.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You should also consider how you a version should be depreciated, and communicate this with any consumers.
You should also consider how a version should be deprecated and communicate this to any consumers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Software design Relates to SD guild content standard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants