Introduction to the Data API
InterSystems Supply Chain Orchestrator™ provides an APIOpens in a new tab for creating, updating, deleting, and retrieving data. This page provides an introduction to this API.
API URL Patterns
All the API calls follow the same URL pattern:
GET {{IRIS-SERVER}}/{{DATAMODEL-PATH}}/OBJECT_PATH?parameters
POST {{IRIS-SERVER}}/{{DATAMODEL-PATH}}/OBJECT_PATH
GET/PUT/DELETE {{IRIS-SERVER}}/{{DATAMODEL-PATH}}/OBJECT_PATH/uid
Where:
-
The {{IRIS-SERVER}} part is the server information of the InterSystems IRIS® instance. In a locally deployed server, it may look like http://localhost:52773
-
The {{DATAMODEL-PATH}} part is the API base URL, such as /api/scdata/v1
-
The OBJECT_PATH part is simply the object name in lower case plural form, such as salesorders or customers. See the table below for all object values.
-
The first URL pattern gets data for an object, or searches for objects using a set of parameters. Any attributes of the object can be used in a search criterion.
-
The second URL pattern creates a new object record. The body of the request should include the JSON string for the new object.
-
The third URL pattern retrieves, updates, or deletes an object record by its uid (which is the external primary key).
Some examples:
-
Finding all sales orders with status Open or PartialShip:
GET {{IRIS-SERVER}}/{{DATAMODEL-PATH}}/salesorders?orderStatus=Open,PartialShip
-
Creating a new customer:
POST {{IRIS-SERVER}}/{{DATAMODEL-PATH}}/customers
with the following JSON in the request body:
{
"uid" : "CUST-TEST-101",
"name" : "Google",
"type" : "HighTech",
"contact" : "Ming",
"url" : "https://google.com"
}
-
Retrieving a supply shipment record with uid value SUP-SHIP-1001:
GET {{IRIS-SERVER}}/{{DATAMODEL-PATH}}/supplyshipments/SUP-SHIP-1001
-
Updating a location record:
PUT {{IRIS-SERVER}}/{{DATAMODEL-PATH}}/locations/LOC-PLANT-002
with new location JSON data in the request body.
Search APIs
Searches are supported through GET APIs with one or multiple URL parameters; each parameter maps to one search condition. If more than one parameter are used, the parameter conditions are combined with logical AND operation. For example, the following searches all Lenovo laptop products:
GET /products?brand=Lenovo&category=laptop
Each parameter name should match exactly an attribute name of the primary object. In some cases, attributes from secondary objects (contained or referenced objects) can also be used. For example, some product attributes can be used in an order search.
The search parameter value can be a single value, a list of values, or a range of values, as follows:
-
Single value. This is the simplest search criterion, using the format parameterName=value. If the parameter is a string or a list of strings, the value matching is case-insensitive. So brand=lenovo is the same as brand=Lenovo.
-
List of values. For a condition that requires matching any of the values in a list, you can provide a list of values as a comma-separated string. For example, to find products of either Lenovo brand or Dell brand, you can use brand=Lenovo,Dell. The list can be used for all data types, string, date, or numbers.
-
Range of values. For date and numerical values (including currency), a range can be used in a search parameter. A range is specified by two values, separated by .. (two dots), in format of min..max. Both values are inclusive for the range. For example, price=100..200 fins all records with price in range of 100 (including 100) and 200 (including 200). The two range boundary values are not always required, and if one is missing, it means that boundary does not exist. For example, price=..200 means any record with price less than or equal to 200, while price=100.. means any record with price greater than or equal to 100.
-
Null value. For any data type, you can search for records with an attribute not set (that is, a null value), or an attribute with some value set (that is, not null). For such cases, you can use two special string values NULL and NOTNULL for any attribute, such as attr1=NULL&attr2=NOTNULL
For example, this call finds all laptop computers from either Lenovo or Dell with price range between 500 and 1000:
GET /products?category=laptop&brand=Lenovo,Dell&price=500..1000
Sorting of Results
When more than one record is returned by an API call, you can define the order of the response data by specifying the sorting parameter sortBy. The value of this parameter must be a comma-separated list of attribute names of the primary object returned.
For example, the following API call defines how a list of orders should be sorted in the response:
GET /salesorders?sortBy=customer,orderValue
which defines the sorting to be first by customer, and then by order value.
By default, sorting is done in ascending order. To change the order to descending, use the - sign before the attribute name, such as the following example, which first sorts by customer in ascending order, and then by orderValue in descending order:
GET /salesorders?sortBy=customer,-orderValue
Default Sorting
If no sorting parameter is provided in the request URL, a default sorting is applied, based on the primary object returned. The following table lists the default sorting parameters for each object type:
Object |
URL path |
Default sorting attributes |
Carrier |
carriers |
name |
Customer |
customers |
name |
Supplier |
suppliers |
name |
Product |
products |
name |
Location |
locations |
locationName |
BillOfMaterial |
billofmaterials |
productId, parentItemId |
InventoryThreshold |
inventorythresholds |
siteLocationId, productId |
Milestone |
milestones |
ID |
ProductInventory |
productinventories |
siteLocationId, productId |
ProductSupplier |
productsuppliers |
productId |
SupplyPlan |
supplyplans |
locationId, productId |
DemandPlan |
demandplans |
locationId, productId |
SalesOrder |
salesorders |
-orderPlacedDate |
SalesOrderLine |
salesorderlines |
orderId, lineNumber |
SalesShipment |
salesshipments |
-actualShipDate |
SalesShipmentLine |
salesshipmentlines |
shipmentId, lineNumber |
PurchaseOrder |
purchaseorders |
-orderPlacedDate |
PurchaseOrderLine |
purchaseorderlines |
orderId, lineNumber |
SupplyShipment |
supplyshipments |
-actualShipDate |
SupplyShipmentLine |
supplyshipmentlines |
shipmentId, lineNumber |
ManufacturingOrder |
manufacturingorders |
-orderEntryDate |