Pandabase

Response Format

Learn how the Pandabase API structures responses and handles errors.

Response Structure

API responses include an ok field that indicates whether the request succeeded.

Success Response

When a request succeeds, the API returns ok: true along with the requested data:

{
  "ok": true,
  "data": {
    // Your requested data here
  }
}

Response Fields:

Prop

Type

Error Response

When a request fails, the API returns ok: false along with error details:

{
  "ok": false,
  "error": "Human-readable error message"
}

Response Fields:

Prop

Type

Error messages are designed to not contain sensitive information and can be safely displayed in user interfaces.

HTTP Status Codes

The API uses standard HTTP status codes to indicate the general category of response:

Status CodeDescription
200OK - Request succeeded
201Created - Resource created successfully
400Bad Request - Invalid request parameters
401Unauthorized - Missing or invalid authentication
403Forbidden - Authenticated but lacks permission
404Not Found - Resource doesn't exist
409Conflict - Request conflicts with current state
422Unprocessable Entity - Validation error
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Server error
503Service Unavailable - Temporary service interruption

Handling Responses

Always check the ok field to determine if a request succeeded:

const response = await fetch("https://api.pandabase.io/stores/{storeId}", {
  method: "GET",
  headers: {
    Authorization: "Bearer sk_xxx",
    "Content-Type": "application/json",
  },
});

const result = await response.json();

if (result.ok) {
  // Success - use result.data
  console.log("data:", result.data);
} else {
  // Error - handle result.error
  console.error(`error ${result.error.code}: ${result.error.message}`);
}

Include the X-Request-Id response header when contacting support so we can find the request.

Last updated on

On this page