API Reference
Introduction
The Chaotics API uses REST. Our API are take and return JSON-encoded data. We use standard HTTP response codes and verbs.
Authentication
Chaotics doesn't require authentication to create an API response endpoint. On creation of an API response endpoint an ID and secret will be returned. It is your responsibility to keep these secret. With the API response endpoint ID a user can request the response. With the ID and the secret a user can request that the API response endpoint is updated or deleted.
To supply the secret for an update of delete action.
Header | Value |
---|---|
Authorization | Your API Secret |
Errors
Chaotics uses conventional HTTP response codes to indicate the success or failure of an API request.
In general:
- Codes in the 2xx range indicate success.
- Codes in the 4xx range indicate a problem with the request. Retrying these errors is unlikely to be successful.
- Codes in the 5xx range indicate an error with Chaotics's servers. Retrying these errors by be successful.
HTTP Status Code | Description |
---|---|
200 - OK | Everything worked as expected. |
400 - Bad Request | The request was unacceptable, check for a missing required parameter. |
404 - Not Found | The requested resource doesn't exist. |
500 - Server Errors | Something went wrong on our end. |
Error responses returned by Chaotics will follow a standard pattern.
Attribute | Description |
---|---|
code | Numeric reference |
description | A description of the error |
Example Error Response
{
"code": 400,
"description": "The request was malformed: required field 'responseStatusCode' is missing."
}
API Response Object
Attributes
Attribute | Type | Required? | Description |
---|---|---|---|
responseStatusCode | Integer | required | The HTTP Status code you would like the endpoint to response with. |
responseContentType | String | required | The value of the Content-Type header the endpoint will response with. |
charset | String | optional (Defaults to UTF-8 ) | The character set to encode the body response with. |
responseBody | String | required | The body you would like the endpoint to response with. |
weight | Integer | optional (default 1) | The weight associated with this API Response. |
latency | Integer | optional (default 0) | The number in milliseconds of additional latency you would like to add to the endpoints response. Up to maximum of 5000. |
Create an API Endpoint
POST
https://api.chaotics.io/endpoint
To create an API endpoint POST
a list of at least one API Response Object.
Attribute | Type | Required? | Description |
---|---|---|---|
apiResponses | List | Required | The required API response behavior |
expireIn | Number | Optional (default 30) | Auto delete the API response endpoint in x days. If not included API response endpoint will be kept indefinitely |
Example Create API Request Body
{
"apiResponses": [
{
"responseStatusCode":200,
"responseContentType":"text/plain",
"charset":"UTF-8",
"responseBody":"ok",
"weight":70,
"latency":100
},
{
"responseStatusCode":500,
"responseContentType":"text/plain",
"charset":"UTF-8",
"responseBody":"failure",
"weight":30,
"latency":4000
}
],
"expireIn": 30
}
Create API Response
Http Status Code 200
The response contains two values which are important for the management of your API endpoint. The apiId
is the unique reference to your API and will be required to get your response in the future. The secret
is a shared secret between Chaotics and yourself, and is required to make update and delete requests. It is your responsibility to keep these safe.
Attribute | Type | Description |
---|---|---|
apiId | String | The unique reference to your API endpoint |
secret | String | The secret for your API endpoint |
Example Create API Response Body
{
"apiId":"xxxxxxxxxxxxxxxxxxxx",
"secret":"xxxxxxxxx"
}
Delete an API Endpoint
DELETE
https://api.chaotics.io/endpoint/{id}
This API requires authentication using your secret.
Header | Value |
---|---|
Authorization | Your API Secret |
Delete API Endpoint Response
Http Status Code 200