View Categories

API Responses

< 1 min read

Upbooks™ API – API Responses #

Upbooks™ API responses follow a structured format to provide meaningful information to clients. Responses are categorized into error responses and success responses, each wrapped in a specific interface.

Error Response #

Error responses are returned when an API request encounters an issue. The format is as follows:

interface ErrorResponse {
  code: string | number;
  message: string;
}

Example:

{"code": "404", "message": "Client not found"}

Success Response – Single Item #

Success responses for retrieving a single item follow this format:

interface SuccessResponseWrapped {
  data: T;
  message?: string;
}

Example:

{
  "data":{ 
    "clientId": "123", 
    "name": "Example Client" 
  }, 
  "message": "Client retrieved successfully"
}

Success Response – List #

Success responses for retrieving a list of items follow this format:

interface SuccessListingResponseWrapped {
  data: Array;
  totalCount?: number;
  filteredCount?: number;
  message?: string;
}

Example:

{
  "data": [{
    "clientId": "123",
    "name": "Client 1"
  }, {
    "clientId": "456",
    "name": "Client 2"
  }],
  "totalCount": 2,
  "filteredCount": 2,
  "message": "Clients retrieved successfully"
}

Example: Client Add API #

For the “Client Add” API, a success response could look like this:

{
  "data": {
    "clientId": "789",
    "name": "New Client"
  },
  "message": "Client added successfully"
}

Example: Client Get Single API #

For the “Client Get Single” API, a success response could look like this:

{
  "data": {
    "clientId": "789",
    "name": "New Client"
  },
  "message": "Client retrieved successfully"
}