LogoLogo
  • Technical Direction
  • Technical overview
    • Technical Implementation
    • API Design Guide
      • Data Definitions and Standards
      • Data Transfer Objects
      • Documentation
      • Environments
      • Error Handling
      • Example API Service
      • GraphQL Naming Conventions
      • Methods
      • Naming Conventions
      • Once Only Principle
      • Pagination
      • Resource Oriented Design
      • REST Request
      • REST Response
      • Security
      • Versioning
    • Ísland.is Public Web Data Flow
    • Code Reviews
    • Code Standards
    • Monorepo
    • Project Management
    • Teamwork
    • Architectural Decision Records
      • Use Markdown Architectural Decision Records
      • Use NX
      • Continuous Integration
      • CSS
      • Branching and Release Strategy
      • Error Tracking and Monitoring
      • What API Management Tool to Consider
      • Viskuausan Static Site Generator
      • Use OAuth 2.0 and OpenID Connect As Protocols for Authentication and Authorization
      • Unified Naming Strategy for Files and Directories
      • CMS
      • Open Source License
      • What Chart Library Should We Use Across Island.is?
      • What Feature Flag Service/application Should We Use at Island.is?
      • Logging, Monitoring and APM Platform
      • ADR Template
    • Log Management Policy
  • Products
    • Island.is Authentication Service
      • Terminology
      • Integration Options
      • Authentication Flows
      • Authorising API Endpoints
      • Session Lifecycle
      • Scopes and Tokens
      • Delegations
      • Configuration
      • Tools and Examples
      • Environments
      • Test IAS with Postman
      • Using the IAS admin portal
    • Notifications / Hnipp
      • New Notification Setup Guide
      • Notifications service workflow overview
      • Email notifications
    • Pósthólfið
      • Security Checklist
      • Introduction
      • Skjalatilkynning API
      • Skjalaveita API
      • Sequence Diagram
      • Interfaces
    • Straumurinn (X-Road)
      • Architecture Guidelines for Service Providers and Consumers
      • Setting up an X-Road Security Server
        • Network Configuration
      • X-Road - Uppfærsla á öryggisþjónum
      • Straumurinn - Notkun og umsýsla
      • X-Road Central - current version
  • Development
    • Getting Started
    • Generating a New Project
    • Definition of done
    • Devops
      • Continuous Delivery
      • Database
      • Dockerizing
      • Environment Setup
      • Logging
      • Metrics
      • NextJS Custom Server
      • Observability
      • Operations Base Principles
      • Security
      • Service Configuration
      • Support
    • AWS Secrets
    • Feature Flags
    • Documentation Contributions
    • Defining Monorepo Boundaries With Tags
    • OpenAPI
    • Code Generation
    • Workspace Settings (Deprecated)
    • External Contributions
  • REFERENCE
    • Problems
      • 400 Validation Failed
      • 400 Attempt Failed
      • 403 Bad Subject
      • 400 500 Template API Error
    • Glossary
  • Misc
    • Guide: Adding a Payment Step to an Application
    • Guide: Enable Organisations to Make Requests to an Application
    • README Template
Powered by GitBook
On this page
  • Methods mapping to HTTP verbs
  • Custom methods (RPC)
  • Example

Was this helpful?

  1. Technical overview
  2. API Design Guide

Methods

PreviousGraphQL Naming ConventionsNextNaming Conventions

Last updated 2 years ago

Was this helpful?

Methods are operations a client can take on resources. Follow when developing methods for APIs. Emphasize resources (data model) over the methods performed on the resources (functionality). A typical resource-oriented API exposes a large number of resources with a small number of methods.

Most API services support the following 5 operations: LIST, GET, CREATE, UPDATE, and DELETE on all resources, also known as the standard methods (). Create custom methods to provide a means to express arbitrary actions that are difficult to model using only the standard methods.

A photo album service, for example, may provide the following methods:

Method
Resource

CREATE Creates a user

//my-service.island.is/v1/users

a collection of User resources

GET Gets a user

//my-service.island.is/v1/users/:userId

a single User resource

UPDATE Updates a user

//my-service.island.is/v1/users/:userId

a single User resource

LIST Lists photos of a user

//my-service.island.is/v1/users/:userId/photos

a collection of Photos resources

DELETE Deletes a photo

//my-service.island.is/v1/users/:userId/photos/:photoId

a single Photo resource

For obvious reasons, operations CREATE and LIST always work on a resource collection, and GET, UPDATE and DELETE on a single resource. Note: You should never define a method with no associated resource.

Methods mapping to HTTP verbs

In HTTP RESTful API services, each method must be mapped to an HTTP verb ().

The following table specifies the mappings between standard and custom methods and HTTP verbs:

Method
HTTP Request Method (Verb)

LIST

GET

GET

GET

CREATE

POST

UPDATE

PATCH/PUT

DELETE

DELETE

Custom

POST (usually)

Custom methods (RPC)

APIs should prefer standard methods over custom methods. However, in the real world there is often a need to provide custom methods. A custom method is an action that does not cleanly map to any of the standard methods. The way to add custom methods to your API is to use POST and add the verb of the action as a sub-resource.

Example

GET    https://api.island.is/v1/messages
GET    https://api.island.is/v1/messages/:messageId
POST   https://api.island.is/v1/messages
PUT    https://api.island.is/v1/messages/:messageId
DELETE https://api.island.is/v1/messages/:messageId

Then there is a requirement to provide a functionality to be able to archive and unarchive a single message and a batch of messages. The archiving and unarchiving of a single message is then provided by:

POST   https://api.island.is/v1/messages/:messageId/archive
POST   https://api.island.is/v1/messages/:messageId/unarchive

The batch archiving is provided by

POST   https://api.island.is/v1/messages/archive
POST   https://api.island.is/v1/messages/unarchive

Note: The POST method accepts a list of message Ids in the request body.

An API has a Message resource and it provides the standard methods like:

resource-oriented design
CRUD
HTTP request methods
CRUD