API Reference

Documentation for Channex.io HTTP JSON-based API version 1.0

WARNING!

There is draft version. Some details in API implementation can be changed before release date.

If you have any comments, suggestions or recommendations, please let us know via andrew@channex.io

API Reference

The Channex.io API is organised around REST. Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. We support cross-origin resource sharing, allowing you to interact securely with our API from a client-side web application. JSON is returned by all API responses, including errors.

API support GET, POST, PUT and DELETE queries.

Each response is valid JSON object and MUST contain at least one key: error, meta or data.

If response has success status, it MUST contain data or meta key at response object.

data object CAN be an Object or Array of Objects.

Each data object contain type and attributes keys with response object definition.

{
"meta": {
"message": "Human readability message"
},
"data": {
"type": "session",
"attributes": {
"token": "Bearer Access Token",
"system_role": "admin"
}
}
}

Each POST or PUT query MUST contain a valid JSON Object and use type of passed object as key for data.

{
"user": {
"email": "test@test.com"
}
}

Where user is type of passed entity.

Authentication

Channex.io supports JSON Web Token authentication method.

To authenticate User, you should call Sing In method with user credentials. In response, you are receive Session object with token key. Use that token as Bearer Token to authenticate user.

Example

Query:

curl --request POST "https://staging.channex.io/api/v1/sign_in" \
--header "Content-Type: application/json" \
--data '{
"user" : {
"email": "user@channex.io",
"password": "password"
}
}'

Response:

{
"meta": {
"message": "You are successfully logged in! Add this token to authorization header to make authorized requests."
},
"data": {
"type": "session",
"attributes": {
"token": "YOUR_TOKEN",
"system_role": "user",
"name": "Channex.io User",
"hotels": [],
"groups": [],
"email": "user@channex.io"
}
}
}

Request protected endpoint:

curl --request GET https://staging.channex.io/api/v1/hotels/ \
--header "Authorization: Bearer YOUR_TOKEN" \
--header "Content-Type: application/json"

Immediate Access

For better user experience our API allow user access to system immediate after registration without email address confirmation. Queries Sign Up, Sign In, Confirm return Session object with token key.

Errors

Channex.io 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 an error that failed given the information provided (e.g., a required parameter was omitted, validation errors, etc.). Codes in the 5xx range indicate an error with Channex.io servers.

Each error response MUST include errors Object with error details.

{
"errors": {
"code": "validation_error",
"title": "Validation Error",
"details": {
"is_active": [
"can't be blank"
]
}
}
}

Errors Object MUST include code and title fields, other fields is optional.

Status Codes

200 OK Success Response

400 Bad Request The request was unacceptable, often due to missing a required parameter.

401 Unauthorized No valid Bearer Token provided.

403 Forbidden Access forbidden. User not have rights to call this action.

404 Not Found The requested resource doesn't exist.

422 Unprocessable Entity Validation Error.

Filtering data arguments

The most API endpoints at Channex.io supports filtering data arguments. Our filtering API provide operations to comparison and inclusion checks.

Basic Concept

Filtering arguments are passed as regular GET arguments in the query string under the filter prefix. Each field should be wrapped into square brackets: filter[field]. To pass list of possible values, use comma symbol: filter[field]=value1,value2.

By default symbol = mean comparison operator is equal if single value passed or is includes if list of values passed. But you can use other operators, like greater then or less then by passing it as second argument for filter: filter[field][gte]=value or filter[field][lte]=value. You can use more then one comparison operator for one field, to build conditions like DATE greater then 2019-01-01 and less then 2019-02-01.

Supported comparison operators

  • gt (greater than)

  • gte (greater than or equal)

  • lt (less than)

  • lte (less than or equal)

  • eq (equal to) default operation if you pass value after = symbol

  • not (not equal to)

Examples

Basic Comparison

Field equal provided value.

API_ENDPOINT/?filter[hotel_uuid]=HOTEL_UUID

Multiple values

Field should be equal to at least one values from provided list.

API_ENDPOINT/?filter[hotel_uuid]=HOTEL_UUID1,HOTEL_UUID2

Multiple fields

Pass several filter arguments.

API_ENDPOINT/?filter[hotel_uuid]=HOTEL_UUID&filter[room_type_uuid]=ROOM_TYPE_UUID

Comparison operations

Use greater then and less then comparison operations

API_ENDPOINT/?filter[date][gte]=DATE_FROM&filter[date][lte]=DATE_TO

API Sandbox Server

To provide early access to our API and provide ability make some tests we are prepare sandbox server what you can use for your experiments.

https://staging.channex.io