What makes a good service ID?

Choosing good identifiers for your services is important. The service ID is what you will use to attach templates, styles and behaviour to a specific service. It must be unique within your application.

Requirements

Although there is no strict restriction on what an ID can be, the schema only requires that:

  • it is unique
  • it can contain numbers letters, and ':', '_', '-', or '.' but not whitespace., it should not start with a '.' or '-'

Conventions

  • Make the ID descriptive and readable so that you know what it corresponds to (verb first, word after)
  • Separate words with hyphens and use only lower case letters.
  • Keep it short and consistent throughout your app
  • Try to match the data that it returns
  • When there are multiple services matching the same URI patterns use the same prefix for the ID and add a suffix such as '-form', '-get', '-done', '-post', '-result'

 

Examples

A service returning the account details of a user match /account/{username}, should probably have the id get-account

Created on , last edited on