Skip to content

Latest commit

 

History

History
87 lines (68 loc) · 1.75 KB

README.md

File metadata and controls

87 lines (68 loc) · 1.75 KB

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