General endpoint structure¶
The Argus API uses a REST structure, with the general layout desribed in this document.
Result set¶
All endpoints - including those returning a single object -have a common result set format of the form :
1 2 3 4 5 6 7 8 | |
The value data contains the real result from the endpoint, which may be a list or a
single object, depending on the endpoint.
Empty results¶
- For list result endpoints, an empty result will be returned as an empty list.
- For a single result endpoints, an empty result may return data value
null,or return status code 404 if the endpoint is not valid.
count and size¶
For searching endpoints, the value count will give the total number of
results for the given filtering parameters.
The size will simply state the number of values returned in a list result. For a single
result, size should be 0.
If counting is not implemented (such as for single object endpoints),
the value of count will be 0.
If counting takes too long, it may time out, in which case the value of count will
be -1.
Identifying fields¶
Clients should beware which fields on an object are considered identifying.
Most objects have an id, which is a numeric value or a UUID. This is typically a unique
field which will never change as long as the object exists.
In addition, many fields have a shortName field, which is a human-readable, but still
programmatically usable field, which is normally a readable single word, containing a unique
name for the object. Although shortnames are possible to change, they are usually considered
stable and unique, as they provide reference points both in Argus code and in integrations.
Other name fields however, as well as localizedName and description, are typically considered visual names only,
and should not be used as identifying fields.
Info objects¶
Returned objects that have a reference to other objects, typically use Info objects to provide information about the referenced objects.
An info object is a reduced version of the referenced object, typically containing the ID and the key properties (name, customer) of the referenced object.
Clients which need to show more of the referenced object than what is available in the info object, should fetch that object from its own endpoint. If this is done a lot, it may be wise to implement a cache for this purpose.
Error codes¶
There are some general error codes used across all endpoints:
200- No error, request completed successfully
201- No error, request completed successfully, creating a new entity
401- The session or API-key provided is not valid, so the service cannot validate the request to any users permissions
403- The current session or API-key is not permitted access to the requested operation. This may be a specific constraint (no access to the specified object), or a general constraint (no access to the requested operation at all)
404- If requesting a specific resource, the system may return 404 if this resource is not found / not available. When listing/filtering entities, the result will be empty if no matching values are found.
405- If requesting an endpoint with unsupported content type specifications, this may
return error 405. Make sure the
content-typeheader is correctly set. 412- This code may be used to indicate that the request is invalid, either because some constraint is not satisfied, or because some of the provided parameters are invalid. See parameter errors
In addition, endpoints may have their specific error codes, which are documented in the API-docs for the service.
Parameter errors¶
If request contains invalid/wrong parameters, the service will return a 412 status code.
The result set will then contain a FIELD_ERROR message:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
If the error is more general, and not associated to a specific field (such as a specific constraint encountered when processing the request), the result set will contain an "action error" message and no specific field name.
Retrieving objects¶
GET operations are guaranteed read-only, meaning that they will not change data in any
way.
Endpoints retrieving single entities, or lists of entities are using the
GET method.
The general URL structure for this is :
1 | |
which will list all available entities of this type, optionally filtered by the provided parameters.
or:
1 | |
which will fetch a single entity with the given ID.
Advanced search¶
The exception is advanced search endpoints which accept a JSON body with
advanced search criteria, these are using POST.
The general URL structure for the search endpoints is:
1 | |
with a POST body containing the search criteria:
1 2 3 4 | |
Adding new objects¶
Endpoints for adding new data are using the POST method. The general URL structure for this is:
1 | |
with a JSON body defining the new object:
1 2 3 4 5 6 | |
If creating the object violates any constraints (such as name uniqueness etc), the
operation will fail with HTTP 412 (Parameter error).
Add-endpoints return the created object, which also includes the id field of the c
reated object.
On objects with created or lastUpdated fields, these fields are automatically set
by the service.
See the OpenAPI for JSON structure.
Updating objects¶
Endpoints for updating existing data are using the PUT method. The
general URL structure for this is
1 | |
with a JSON body defining the new object.
1 2 3 4 5 6 | |
Generally the update operations have a list of optional fields, and only specified fields will be updated.
If an object's field is set, the value of that field will be set on the specified object.
In the example above (relative to the object created in the previous "add"-operation):
fieldandbooleanFieldare set new valuesotherBooleanFieldis not touched.collectionFieldis updated by removing two existing values, and adding two new values.
Update-endpoints return the updated object, after the specified field changes have been applied.
Objects with lastUpdated fields are automatically updated by the service.
See the API documentation for details on API request structure.