API Autorization
WinKAS Api is tokens based and you will need to provide an active token to all API calls. To get a token, you will need to call the “Authorization” API and it requires the following information:
ContractId (Normal customer’s license or agreementId)
Username (The username that the customer has created with API access)
Password: (The assigned password for the username)
When you have retrieved a token with success, then read our suggestions for handling the token.
Authorization
Url: https://air.winkas.net/api/Authentication/Authenticate
Requesttype: Post
Body: {“UserName”:”NAME”, “UserPassword”:”PASSWORD”, “UserContractCode”:”CODE”}
Parameters description:
All parameters are string
Response example:
{
"AuthenticationMessage": "User successfully authenticated",
"WinKasData": {
"Id": 3397,
"UserName": "",
"UserPassword": "",
"UserContractCode": "",
"CurrentToken": "U1vTDs062o1iadVMJK72-nblIDVDB|86VbN3h7sSiW9QOZMrofSKw|xPE3Y3mHX7tU8U-jI-pZPJTiWlTI8n|nX45nUweWqh89gaPthYa|lTDEDqXc2ISwsoK-aWL9wL1C2rPS1onwa8|j1PouTZjxLi|SdGisCQqspzYy3jerLaUikSS|Q5VrN23a|cIqtxe|HDCOyb5B-CeyjVTkTwTl6yiQ92nkvJq43oSxP7-crg_",
"UserRealName": "MJ",
"AuthLevel": null,
"Profile": null
},
"WinkasErrorCode": 0,
"WinKasStatus": 0,
"WinKasStatusString": "Okay",
"WinKasMessage": "Authentication was okay.",
"ApiVersion": "5.67.2.1",
"ResponseDateTime": "2022-03-21T10:43:26",
"ResponseInfo": {
"ElapsedSeconds": 0.1,
"ServerName": "WINKAS-AIRWEB02"
},
"Source": null
Code example – Authentication.
Below examples for authentication in the following languages:
C#
Javascript / Ajax
Php
ASP (Classic)
C#
public string GetToken()
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://air.winkas.net/api/Authentication/Authenticate");
httpWebRequest.ContentType = "text/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = new JavaScriptSerializer().Serialize(new
{
UserName = "xxxxx",
UserPassword = "xxxxx",
UserContractCode = "xxxxx"
});
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var _jsonAuth = streamReader.ReadToEnd();
dynamic _jsonContent = JsonConvert.DeserializeObject(_jsonAuth);
string _token = _jsonContent.WinKasData.CurrentToken;
return _token;
}
}
}
Javascript
$(document).ready(function () {
var winkasServer = (function () {
var getAccounts = function (request) {
return $.ajax(
'https://air.winkas.net/api/Accounts/All', {
type: "POST",
data: request
});
};
var authenticate = function (request) {
return $.ajax(
'https://air.winkas.net/api/Authentication/Authenticate', {
type: "POST",
data: request
}
);
};
return {
getAccounts: getAccounts,
authenticate: authenticate
};
}());
var el = {
btnAction: $('#action'),
result: $('#result')
};
el.btnAction.on('click', function () {
el.result.html("Getting...");
var request = {
"UserName": "xxxxx",
"UserPassword": "xxxxx",
"UserContractCode": "xxxxx"
};
winkasServer.authenticate(request).done(function (data) {
var token = data.WinKasData.CurrentToken;
request = {
"Token": token
};
winkasServer.getAccounts(request).done(function (accounts) {
var acc = accounts.Accounts;
var html = "";
for (var i = 0; i < acc.length; i++) {
html += acc[i].Number + ", ";
}
el.result.html(html);
});
});
});
});
PHP
ASP (classic)