**This is an old revision of the document!**
zebrix REST api starter guide
Introduction
Every zebrix REST API call required a token that has to be included in the request header. The token can be obtained with a login procedure.
login api
POST /login
Parameters has to be sent in the JSON format
Parameters | |
---|---|
clientname | the customer name |
username | the username |
password | the user password |
login demo with "POSTMAN" (Google Chrome Extension)
Example of GET API on screen
GET /api/screen/:id
This example will demonstrate how to request information with a GET call to the API. We will use the screen api (to get the list of all screens with their properties). It will work the same for all other objects in zebrix (media, pages, playlist, etc.)
In this request we will need to use the previously requested token in the request header of the API will return a 401 (not authorized) error.
The token must be prefixed with the word “Bearer” and a space char that way :
Bearer eyJ0eXAiOiJKV1QiLCJhbGci0kLIUzI1NiJ9.eyJpZCI6MjYwMCwiQ2xpZW50SWQiOjIwLCJyb2xlIjoyLCJsZXZlbCI6MTAsInNjb3BlIjp7fSwiaWF0IjoxNDcwMTIyNDU2LCJleHAiOjE0NzAxNjU2NTZ9.YSqeMUJUm1t2JuIlidcwZzA7XS52SR8WiUHWRnH4E
The call of the API will return a JSON array of all screens :
To get information for a specific screen, its unique id can be added in the URL. For example, we want to get information about the screen with the id 6361 :
How to set content on a screen?
Basically, you will have to post the following JSON
{'contentType':"page",'ContentId': contentId, 'useScheduling': False}
* contentType (string): possible value « page » and « playlist »
- contentId (integer) : id of the content you want to set
- useScheduling (boolean) : false is mandatory when setting an arbitrary content.
To go back to schedule mode, you only need to POST the following JSON
{'useScheduling': True}
to the following URL:
POST : https://cmsv2.zebrix.net/api/screen/{screenID}/setContent
To get ID of pages and playlist, you can make a GET request to following URLs:
- /api/screen
- /api/page
- /api/playlist
How to use API for datasource
Introduction to datasource
In zebrix a datasource is basically one row from a database.
As an example let take a table from DB containing information about 4 meeting rooms. Each meeting room has 4 properties :
- ROOM (room name)
- VISITOR (current visitor who uses the meeting room)
- SEATS
- HASBEAMER
In zebrix this table of 4 meeting rooms will requires 4 datasources (i.e. meeting room 1, meeting room 2, meeting room 3, meeting room 4). Each line/datasource will contains all columns / fields in a JSON.
Get all datasources
GET /api/datasource/:id
All datasources will be returned with all their properties (including their content)
Using our meeting rooms example, here is the result you will get :
Theses datasource can be used by users in their page by following instructions on that page (section 5) (Using datasources in Zebrix
How to add a new datasource to zebrix
POST /api/datasource/
The content of the datasource has to be JSON encoded and put as an object in a defaults variable.
Example of usage :
How to update an existing datasource
POST /api/datasource/:id
The update process works the same as a creation but the id of the datasource need to be specified.
How to force screens to update
POST /api/screens/updateds
When a datasource is updated screens that display this datasource will not be update until the updateds is called. This API is usually called after update of a datasource. Is displayed pages contain multiple datasources it is adviced to call the updateds method at the end of the update process of all datasources instead of after every datasource update to limit ressources and bandwidth usage.