API
Data's current API gateway is kokos-dispatcher.
Kokos Dispatcher
Kokos Dispatcher is responsible for authenticating user and launching FUN against others micro-executors.
The current version of the dispatcher APIs is v2
(you can see that in the enpoint path).
Authentication
POST
/api/[APP]/v2/authentication
with a request body application/xxx-form-urlencoded
or application/json
like:
usr=[USER]
pwd=[PASSWORD]
device=[DEVICE]
and answers with:
{
"variables": [
// ...
]
}
that represents user variables used to resolve certain parameters in FUNs.
Headers returned with response are:
X-Smeup-Access-Token: Bearer [JWT]
X-Smeup-Protocol: [VERSION]
X-Smeup-Refresh-Token: Bearer [REFRESH_TOKEN]
The device
parameter is optional and can be used to identify the device from which the user is connecting (W) web or (P) phone.
Example
POST
http://localhost:8000/api/standard/v2/authentication
application/xxx-form-urlencoded
usr=Admin
pwd=123456
Launching FUNs
A user must be authenticated to launch FUNs.
POST
/api/[APP]/v2/fun
with a request body application/xxx-form-urlencoded
or application/json
like:
fun=[FUN]
plus the JWT obtained with authentication as header (and as secure cookie):
Authorization: Bearer [JWT]
If you are using a browser or a client like Postman JWT cookie will be automatically added to the request.
and answers with a SmeupDataStructure
that contains the result of the FUN execution:
// Something like this
{
"type": "SmeupDataStructure",
"serviceInfo": {
"fun": "F(EXD;*SCO;) 2(MB;SCP_SCH;EXAMPLE)",
"serviceName": "*SCO"
},
"info": "F(EXD;*SCO;) 2(MB;SCP_SCH;EXAMPLE)",
"debugInfo": {}
}
Example
POST
http://localhost:8000/api/standard/v2/fun
application/xxx-form-urlencoded
fun=F(EXD;*SCO;) 2(MB;SCP_SCH;EXAMPLE)
Disconnecting
POST
/api/[APP]/v2/disconnection
to quit the session associated with current user.
Example
POST
http://localhost:8000/api/standard/v2/disconnection
Using the Swagger UI
By connecting to the dispatcher URL https://<dispatcher-host>:<dispatcher-port>/swagger/index.html
you can access the swagger interface without the need to use Postman.
From there you can test the API and see the request and response formats.
FAQs
I get an error while trying to authenticate
- check if the user and password are correct
- check if the application (
APP
placeholder in endpoint path) exists and it is not mistyped - make sure APIs version is correct (v2)
I get an error while launching FUN
- check that the
APP
parameter you are launching the FUN against is correct and it is the same as the one used for authentication - make sure the FUN is correct and it exists