Overview
Sorionlib includes a powerful API client for making HTTP requests with built-in authentication, retries, and error handling.Authentication
API key authentication
Bearer token authentication
Custom headers
Available methods
get(endpoint, params)
Makes a GET request.
| Parameter | Type | Description |
|---|---|---|
endpoint | string | The API endpoint. |
params | object | Query parameters (optional). |
Promise<object> - The response data.
post(endpoint, data)
Makes a POST request.
| Parameter | Type | Description |
|---|---|---|
endpoint | string | The API endpoint. |
data | object | Request body. |
Promise<object> - The response data.
put(endpoint, data)
Makes a PUT request.
| Parameter | Type | Description |
|---|---|---|
endpoint | string | The API endpoint. |
data | object | Request body. |
Promise<object> - The response data.
delete(endpoint)
Makes a DELETE request.
| Parameter | Type | Description |
|---|---|---|
endpoint | string | The API endpoint. |
Promise<object> - The response data.
Error handling
The API client throws typed errors that you can catch and handle:Common error codes
| Code | Description |
|---|---|
NETWORK_ERROR | Network connection failed. |
TIMEOUT | Request timed out. |
UNAUTHORIZED | Authentication failed. |
FORBIDDEN | Access denied. |
NOT_FOUND | Resource not found. |
RATE_LIMITED | Too many requests. |
SERVER_ERROR | Server error occurred. |
Configuration options
| Option | Type | Default | Description |
|---|---|---|---|
baseUrl | string | - | Base URL for all requests. |
apiKey | string | - | API key for authentication. |
token | string | - | Bearer token for authentication. |
headers | object | {} | Custom headers. |
timeout | number | 30000 | Request timeout in ms. |
retries | number | 3 | Number of retry attempts. |