Init requests
API Reference
Tonos API includes a set of HTTP endpoints that help your application to easily integrate with Tonos.
Init endpoints are for checking if a user has access to your content.
Authentication
On Init endpoints, user authentication is done via Bearer JWT tokens. The token is sent on request headers. After the user is logged in, the Javascript SDK will try to save the token on the user’s browser as a cookie. In this way, when requests are made on your application, the token cookie will be included to read on your behalf on the backend side.
Errors
Tonos uses HTTP response status codes and the response object to indicate the status of endpoint request calls.
HTTP Status codes
200 | The page that you are asking for access status is found in our database. |
---|---|
400 | The page or content does not exist in our database. |
Response object
{
"data": {}, // response data's
"errors": {}, // errors messages
"statusCode": 200, // HTTP response status
"success": true // success of request call based on HTTP status codes
}
Init access
Init access endpoint helps to control premium content from the back end side. Concerning the protection of premium content, this endpoint helps to solve this issue.
Endpoints
GET https://client-api.tonos.gjirafa.tech/init/access?url=:url&contentId=:contentId
Request attributes
url - The URL of the page
contentId - Identifier of the page
One of the request attributes is required
The response object
{
"statusCode": 200,
"success": true,
"errors": {},
"message": null,
"data": {
"access": false,
"offers": [
{
"selector": null,
"isModal": true
},
{
"selector": "#player",
"isModal": false
}
]
}
}
Response attributes
access - Indicates if the user has access to view content of the specified page
offers - Indicates active offers of the page
selector - CSS selector of the locked container where the offer should show up
isModal - Indicates if offer is modal and will cover all the page
canClose - Indicates if offer modal is closable
The following snippet explains that a page has two active offers. The first one is modal and is closable. The modal will cover all the page content and it is up to you which content of the page you want to hide and not return to your visitor from your backend side.
The second one has a selector, which lets us know where the offer should show up. From the #player
selector, we understand that the content inside this selector is premium locked and must not return to your visitor.
"data": {
"access": false,
"offers": [
{
"selector": null,
"isModal": true,
"canClose": true
},
{
"selector": "#player",
"isModal": false,
"canClose": false
}
]
}