REST API/Response Format

Response Format

Understanding API response structure, status codes, and data formats

Response Structure

All API responses follow a consistent JSON structure with three top-level fields: data, status, and error_code. This standardized format makes it easy to handle responses programmatically.

Successful Response

When a request succeeds, the response includes the requested data in the data field:

Success Response 200 OK

data

Contains the actual response payload. Structure varies by endpoint but typically includes items array for list endpoints and pagination metadata.

status

Boolean indicating request success. true for successful requests, false for errors.

error_code

Numeric code indicating the result. 0 means success. Non-zero values indicate specific error conditions (see Error Handling guide).

Pagination

List endpoints return paginated results with metadata to help navigate through large datasets:

total— Total number of items across all pages
page— Current page number (1-indexed)
size— Number of items per page
items— Array of results for the current page

Complex Data Structures

Some endpoints return nested objects with multilingual fields and normalized identifiers:

Complex Response

Multilingual Fields

Fields like display_name contain arrays of translations with language codes:

"display_name": [{ "lang": "EN", "name": "..." }]

Normalized IDs

Entities include both unique IDs (drug_id, target_id) and normalized IDs for grouping similar entities across different naming conventions.

Response Headers

Important metadata is included in response headers:

content-typeResponse format
Always application/json
x-correlation-idRequest tracking
Unique identifier for request tracing and debugging
x-openapi-amountAPI usage
API call consumption amount for this request
dateResponse time
Server timestamp when the response was generated
serverServer info
API gateway server information (APISIX)

Best Practices

  • Always check status field before processing data
  • Handle pagination properly for large result sets
  • Use x-correlation-id for debugging and request tracing
  • Parse multilingual fields based on your application's locale