Skip to content

ClickPesa REST API Development General Guideline - Version 1.0

Notifications You must be signed in to change notification settings

ClickPesa/REST-API-Development-Guideline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

ClickPesa API Development General Guideline - Version 1.0

  1. Use kebab-case for URLs

Example:

GET /system-orders
  1. Use camelCase for Parameters

Example:

PATCH /system-orders/{orderId}
  1. Plural Name to Point to a resource / collection

Example:

GET /system-orders
  1. URL Starts With a Collection and Ends With an Identifier

Example:

// Bad - points to a property instead of a resource
GET /shops/:shopId/category/:categoryId/price 

//Good
GET /shops/:shopId/ or GET /category/:categoryId
  1. Use proper HTTP methods to describe an operation

Example:

//Bad
POST /update-user/{userId} or GET /getusers

//Good
PUT /user/{userId}

//HTTP Methods for CRUD Functions
GET  // To retrieve a representation of a resource
POST // To create new resources and sub-resources
PUT  // To update existing resources
PATCH // To update existing resources. It only updates the fields that were supplied, leaving the others alone
DELETE // To delete existing resources
  1. Don’t use database's table_name / collection as a resource name

  2. Accept limit and offset Parameters GET operations

Example:

GET /shops?offset=5&limit=5
  1. Take fields Query Parameter

Example:

// Only return the name, address, and contact of the shops
GET /shops?fields=id,name,address,contact
  1. Use the Relation in the URL For Nested Resources

Example:

//  Get the list of all products from shop 2
GET /shops/2/products

//  Get the details of product 31, which belongs to shop 2
GET /shops/2/products/31
  1. Use Verbs for Non CRUD operations

Example:

// resend the alert to a user
POST /alerts/245743/resend

About

ClickPesa REST API Development General Guideline - Version 1.0

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published