Once authorised, a client can download the Inventory Status of any of its sites via the TWeb Public API. The Inventory Status is returned in a JSON list. The process of downloading the Inventory Status only involves one request to the Public API:
- A request to get the Inventory Status of all tanks for a particular site or all site(s)
Step 1 - Requesting inventory status
Endpoint Version:
The endpoint depends on the server used by your company to login to TWeb:
T-WEB Server | T-WEB Login URL | API Authorisation Endpoint |
www | https://www.tweb.com.au/v2/ |
https://publicapi.tweb.com.au/v1.1/Inventory |
www2 | https://www2.tweb.com.au/v2/ |
https://publicapi2.tweb.com.au/v1.1/Inventory |
gt | https://gt.tweb.ttfuel.com/v2/ |
https://publicapi.gt.tweb.ttfuel.com/v1.1/Inventory |
uae | https://uae.tweb.ttfuel.com/v2/ |
https://publicapi.uae.tweb.ttfuel.com/v1.1/Inventory |
The endpoint only accepts HTTP POST requests. The following POST parameters must be included with the request:
accessToken
Note that the Access Token may be submitted as a POST parameter or as a HTTP Cookie.
The following POST parameters may optionally be submitted with the request:
targetID
filterSiteNumber
For details regarding the Target ID, please refer to the following article: https://help.tweb.com.au/TWebPublicAPI/en/Authorisation/Execute#heading_request
filterSiteNumber
is an optional POST parameter. This parameter specifies the site whose Inventory Status is to be returned.
Site Numbers are allocated to all sites by TT. A list is available via TWeb. This filter has the following validation rule
specifications:
Rule | Specification |
Format | /[0-9]{6}/ , eg. 123456 |
Default | When this parameter is not specified then the Inventory Status for all sites will be returned |
Request Examples
A request for the Inventory Status that includes the Access Token from the file where it was stored during authorisation:
curl -b cookiejar.txt -skX POST -d "targetID=abc123&filterSiteNumber=123456" https://publicapi.tweb.com.au/v1.1/Inventory
A request for the Inventory Status that includes the Access Token as a POST parameter in the body:
curl -skX POST -d "accessToken=0123456789ABCDEF0123456789ABCDEF01234567&targetID=abc123&filterSiteNumber=123456" https://publicapi.tweb.com.au/v1.1/Inventory
Step 1 - Response
The response from the Inventory Status endpoint has the following JSON format:
{ "Data": { "Meta": { "Title": "Public API: Download Inventory", "Endpoint": "/v1.1/Inventory", "SubmittedFilters": { "filterSiteNumber": "123456" } }, "Items": [ { "SiteNumber": "123456", "TankNumber": 1, "Volume": 50000, "Capacity": 50000, "MeasurementDate": "2017-09-01T00:00:00", "Ullage": 0, "WaterHeight": 0, "Grade": { "GradeNum": 1, "Name": "Unleaded" }, "MeasurementSource": 0 }, { "SiteNumber": "123456", "TankNumber": 2, "Volume": 20000, "Capacity": 50000, "MeasurementDate": "2017-09-01T00:00:00", "Ullage": 30000, "WaterHeight": 0, "Grade": { "GradeNum": 2, "Name": "Premium ULP" }, "MeasurementSource": 1 } ] }, "Error": { "Code": 0, "Status": "OK" } }
The Inventory Status is returned as a list of objects in Data.Items
. Each of the properties of that object are described
in the following table:
Property | Description |
SiteNumber |
The Controller's Site ID. |
TankNumber |
The Tank Number. |
Volume |
The volume in the tank during the measurement, to the nearest 1 decimal place. |
Capacity |
The capacity of the tank, no decimal places. |
MeasurementDate |
The measurement date and time, formatted as yyyy-MM-ddTHH:mm:ss, where T is always the literal character T. |
Ullage |
The ullage volume in the tank, to the nearest 1 decimal place. |
WaterHeight |
The water height in the tank, to the nearest 1 decimal place. |
Grade.GradeNum |
The grade number of the fuel. |
Grade.Name |
The name of the fuel. |
MeasurementSource |
An integer representing the source of the inventory dip data. Available options are:
|
The Error JSON property is included in all responses from the TWeb Public API. The possible responses when requesting the Inventory Status are:
Error Code | Error Name | Explanation |
0 | OK | Inventory data have been returned without any error |
1 | Server Error | This issue either does not fit any of the other codes or is due to a bug in the Public API code. |
4000 | Rate Limit Exceeded | This is the second request within a 1 second period. |
4002 | Account Inactive | Account Inactive. |
4003 | Session Expired | Session Expired. |
4008 | Invalid Access Token | The Access Token was not valid. |
4012 | Insufficient API Privileges | Account does not has sufficient privilege for this endpoint. |
4300 | Unable to Get Inventory Status Data | There was an error while attempting to download the Inventory Status. |