Search…
Naming Conventions
This document describes API naming conventions related to services and resources, with focus on the general consumer experience. Consistency and clear naming conventions are key to providing uniform APIs between agencies. For further information about our naming conventions for the developer experience please refer to our coding standard.

General

In order to provide a consistent consumer experience across the API ecosystem and over a long period of time, all names used by an API should be:
  • simple
  • intuitive
  • consistent
One goal of these naming conventions is to ensure that the majority of consumers can easily understand an API. It does this by encouraging the use of a simple, consistent and small vocabulary when naming methods and resources. It also enforces names to be in British English. Developers should use our glossary when in trouble finding the appropriate English translation of an Icelandic concept.
Commonly accepted short forms or abbreviations of long words may be used for brevity. For example, API is preferred over Application Programming Interface. Use intuitive, familiar terminology where possible. For example, when describing removing (and destroying) a resource, delete is preferred over erase. Use the same name or term for the same concept, including for concepts shared across the ecosystem.
Name overloading should be avoided. Use different names for different concepts. Overly general names that are ambiguous within the context of the API and the larger API ecosystem should be avoided as they can lead to a misunderstanding of API concepts. Specific names that accurately describe the API concept and distinguish it from other relevant concepts should be used. There is no definitive list of names to avoid, as every name must be evaluated in their context.
Bad
1
Info // info about what?
2
Service // service for what?
3
Application // application for what?
Copied!
Good
1
OrderStatus // Info about Order status
2
OrderService // Service that works with the Order resource
3
PaternityLeave // Application data for paternity leave application
Copied!
Carefully consider using names that may conflict with keywords in common programming languages. Such names may be used but will likely trigger additional scrutiny during API review. Use them judiciously and sparingly.

Resources

Resource names should be singular noun and use PascalCase.
Bad
1
Users
2
user
3
Paternityleave
Copied!
Good
1
User
2
PaternityLeave
Copied!

URIs

The URI defined in RFC3986 consists of five components: scheme, authority, path, query and fragment.
1
https://example.com:8042/over/there?name=ferret#nose
2
\___/ \______________/\_________/ \_________/ \__/
3
| | | | |
4
scheme authority path query fragment
Copied!
When structuring resource URIs please follow the following rules:
  • [Resource names and collection IDs] must be the plural form of the singular noun used for the resource.
  • Use lowercase letters for URI paths since capital letters can sometimes cause problems.
  • Use hyphens (-) to improve readability of concatenated resource names.
  • Use the forward slash (/) in a path to indicate hierarchical relationship between resources.
  • Do not end a path with a trailing forward slash (/).
  • Do not use underscores (_) as they can be partially obscured or hidden in some browsers or screens.
  • For naming query parameters please use the camelCase naming convention.
Example URI of an authority and a path component
1
example.com/v1/users/1/photos/121
2
\_________/ | \___/ \____/ \_/
3
| | | | \
4
| | | | Resource ID
5
| | | | (type)
6
| | | \
7
| | | Collection ID
8
| | | (type)
9
| | \
10
| | Resource name of parent resource
11
| \
12
| Major version
13
\
14
API service name
Copied!

Fields

Resource field names should be clear, descriptive and use camelCase. Fields representing arrays or lists should be named as plural nouns.
Bad
1
User:
2
type: object
3
properties:
4
Name:
5
type: string
6
DisplayName:
7
type: string
8
dspName:
9
type: string
10
Email:
11
type: string
12
child:
13
type: array
Copied!
Good
1
User:
2
type: object
3
properties:
4
name:
5
type: string
6
displayName:
7
type: string
8
email:
9
type: string
10
childs:
11
type: array
Copied!

References

Last modified 1yr ago