API Documentation
NOTE: Most of our API's are not documented, as they are primarily used by the application itself only.
If you do not see an API for the information that you wish to retreive, please contact StockIQ Support, and we will add the requested documentation to this section of the knowledge base.
REST Automation User Creation
- Create a StockIQ user account that will be the account used by whatever process accesses your StockIQ instance.
- the user must have a valid email address to receive the new user login credentials. one good way is to make an alias to somebody in your IT department, e.g. siqapi@companyname.com
- Ensure your user has all permissions for the API's that you will be requesting. For example, if you are using an API from the inventory module, make sure that the Inventory Manager role is assigned to the user, at least.
Authenticating and Calling the API
- Authentication - StockIQ uses basic authorization - make sure this header with base64 encoded credentials are included in your request.
- Base URL: The base URL for all calls will be http(s)://[Name or IP of your server]/api/
- example: https://contoso.stockiqtech.net/api/
- example: http://mycompanystockiqserver:8010/api/
- Specific Resources - After the base URL, you will add the specific resource and parameters that you want to query.
- Format - All StockIQ API's are set up for JSON, so include the Accept "application/json" in your header.
C# Example
Below is an example calling the API using C# and the common NewtonSoft.JSON and RestSharp libraries. Both of these are available from Nuget.
Other languages will be similar:
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StockIQApiClientExample
{
class ApiClient
{
static void Main(string[] args)
{
//change this based on what API you want and the parameters you wish to send:
//var client = new RestClient($"https://mycompany.stockiqtech.net/api/AlertsSummary?alertTypeIds=1&alertPriorityIds=4");
var client = new RestClient($"https://mycompany.stockiqtech.net/api/AlertsSummary");
//basic authentication header:
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
client.Timeout = -1;
//change the Method based on if the request is a GET, PUT, POST, etc:
var request = new RestRequest(Method.GET);
//if you have parameters to put in the body for PUT and POST requests, add them here if you have an object:
//var myParameterObject = new
//{
// property = 1,
// otherProperty = "Hello World"
//};
//request.AddJsonBody(myParameterObject);
////alternate method for JSON body parameters if you just have a string:
//var myJsonString = "{ property: 1, otherProperty: 'Hello World'}";
//request.AddParameter("application/json", myJsonString, ParameterType.RequestBody);
var response = client.Execute(request);
//do whatever you want with the content here
//Console.WriteLine(response.Content);
//OR:
var alertSummaries = JsonConvert.DeserializeObject<List<AlertSummary>>(response.Content);
//...do stuff...
}
class AlertSummary
{
[JsonProperty("ATN")]
public string AlertTypeName { get; set; }
public string ItemCode { get; set; }
public string SiteCode { get; set; }
public string ItemDescription { get; set; }
[JsonProperty("AMsg")]
public string AlertMessage { get; set; }
//other properties you might be interested in here...
//...
}
}
}