# API Design Guide

This is the home of the API Design Guide published by Stafrænt Ísland as a best practice guide for API development. It should help synchronize the work between developers and make working together easier. The guide covers the relevant design principles and patterns to use so the consumer experience is enjoyable and consistent throughout APIs.

This guide is under constant review and updates will be made over time as new design patterns and styles are adopted.

All feedback is welcomed and encouraged to help make the guide better so please feel free to create pull requests.

## Content

* [Once-Only](api-design-guide/once-only)
* [Resource Oriented Design](api-design-guide/resource-oriented-design)
  * [Design flow](resource-oriented-design#design-flow)
  * [Resource](resource-oriented-design#resources)
* [Naming Conventions](api-design-guide/naming-conventions)
  * [General](naming-conventions#general)
  * [Resources](naming-conventions#resources)
  * [Fields](naming-conventions#fields)
* [GraphQL Naming Conventions](api-design-guide/graphql-naming-conventions)
  * [Case styles](graphql-naming-conventions#case-styles)
  * [Input objects naming conventions](graphql-naming-conventions#input-objects-naming-conventions)
  * [Query naming conventions](graphql-naming-conventions#query-naming-conventions)
  * [Mutation naming conventions](graphql-naming-conventions#mutation-naming-conventions)
  * [Integrating naming conventions into shared api](graphql-naming-conventions#integrating-naming-conventions-into-shared-api)
* [Data Definitions](api-design-guide/data-definitions)
  * [Text encoding](data-definitions#text-encoding)
  * [JSON](data-definitions#json)
  * [National identifier](data-definitions#national-identifier)
  * [Language and currency](data-definitions#language-and-currency)
  * [Date and time](data-definitions#date-and-time)
  * [Timestamp data](data-definitions#timestamp-data)
* [Data transfer objects](api-design-guide/data-transfer-objects)
* [Pagination](api-design-guide/pagination)
  * [PageInfo](pagination#pageinfo)
  * [Pagination Query parameters](pagination#pagination-query-parameters)
  * [Monorepo library](pagination#monorepo-library)
* [Methods](api-design-guide/methods)
  * [Methods mapping to HTTP verbs](methods#methods-mapping-to-http-verbs)
  * [Custom methods (RPC)](methods#custom-methods-rpc)
* [REST Request](api-design-guide/rest-request)
  * [Query parameters](rest-request#query-parameters)
  * [Path parameters](rest-request#path-parameters)
* [REST Response](api-design-guide/rest-response)
  * [General](rest-response#general)
  * [GET](rest-response#get)
  * [POST](rest-response#post)
  * [PUT](rest-response#put)
  * [PATCH](rest-response#patch)
  * [DELETE](rest-response#delete)
* [Errors](api-design-guide/errors)
  * [Response Body](errors#response-body)
* [Documentation](api-design-guide/documentation)
  * [Describe error handling](documentation#describe-error-handling)
  * [Provide feedback mechanism](documentation#provide-feedback-mechanism)
  * [Example](documentation#example)
  * [Setup example](documentation#setup-example)
* [Versioning](api-design-guide/versioning)
  * [Version changes](versioning#version-changes)
  * [URLs](versioning#urls)
  * [Increment version numbers](versioning#increment-version-numbers)
  * [Deprecating API versions](versioning#deprecating-api-versions)
* [Security](api-design-guide/security)
* [Environments](api-design-guide/environments)
  * [Development](environments#development-environment)
  * [Test](environments#test-environment-for-providers-of-an-api)
  * [Sandbox](environments#sandbox-environment-for-consumers-of-an-api)
  * [Production](environments#production-environment)
* [Example Service](api-design-guide/example)

## Changelog

_Draft 4 - Published 2023-06-07_

* Updated usage of [HTTP status codes](rest-response#http-status-codes) to use `204` instead of `404` when resources are not found or not accessible to the user.
* Update [REST Requests](rest-request#working-with-sensitive-data) to describe arrays in query parameters and how to handle sensitive data in query and path parameters.
* Update [Custom Methods (RPC)](methods#custom-methods-rpc) to use verbs instead of nouns for method names with `POST`.

_Draft 3 - Published 2022-08-16_

* Improving [Documentation](api-design-guide/documentation).
* Adding description of Content Types in [REST Response](api-design-guide/rest-response).
* Making `hasPreviousPage` and `startCursor` optional in [Pagination](api-design-guide/pagination).
* Adding OWASP and IAS reference in [Security](api-design-guide/security).
* Other small fixes.

_Draft 2 - Published 2021-10-19_

* Changing pagination description

_Draft 1 - Published 2020-08-31_

* Initial relase
