10. APIs - TEC-RFID/rfid-asset-documentation GitHub Wiki
To find your API key, go to the web portal, click Settings in the sidebar, then API Key.
If you don't already have an API key, click Generate to create one. If you need to replace your existing API key, click Generate again. Note that generating a new API key will invalidate the old one.
Get Assets API
Get All Assets with Filters
URL: https://app.tec-rfid.co.uk/api/get-all-assets-with-filters
This will return all assets that match the search criteria. If you want to use pagination (30 results per page), append ?page=PAGENUMBER to the URL.
Method: POST
Headers:
- Content-Type: application/json
Payload Format:
{
"api_key": "APIKEY",
"created_at_range": "01/01/2023,20/05/2023"
"rfid_code": "EPC",
"asset_name": "ASSETNAME",
"asset_type": "ASSETTYPE",
"category": "CATEGORY",
"location": "LOCATION",
"user": "USER",
"asset_group": "ASSETGROUP",
"status": "STATUS"
}
Notes:
- All filters are optional (with the obvious exception of api_key), so you can filter as much or as little as you need.
- created_at_range should be dd/mm/yyyy, comma separated.
- If no results are found, it'll still return a success response, but "data" will equal null instead of an array.
- If pagination is not used, the "pagination" key will still be present in the response, but it will equal null.
Response Types:
Success
{
"status": true,
"message": "Filtered Results",
"data": [
{RETURNS JSON OBJECT FOR EACH ASSET FOUND}
],
"pagination": {
"current_page": 1,
"max_pages": 0,
"row_per_page": 30
}
}
Failure
{
"status": "fail",
"message": "Invalid API Key.",
"data": []
}
Create Assets API
Create Asset
URL: https://app.tec-rfid.co.uk/api/create-asset-api
Method: POST
Headers:
- Content-Type: application/json
Payload Format:
The required payload will vary significantly depending on your organisation's required fields. To determine your required format, just send your API key on its own, as below, and the response will be reference JSON for you to use.
{
"api_key": "APIKEY"
}
Response Types:
Success
{
"status": "success",
"message": "Asset created successfully",
"data": [
{RETURNS JSON OBJECT FOR ASSET CREATED}
]
}
Failure
{
"status": "fail",
"message": "Please use following format",
"JsonBodyFormat": {REFERENCE FORMAT FOR YOUR ORGANISATION}
}
Bulk Create Assets
URL: https://app.tec-rfid.co.uk/api/v3/create-bulk-asset-api
Method: POST
Headers:
- Content-Type: application/json
Payload Format:
Identical to above, the one difference being that you nest the assets inside an array, like so:
{
"api_key": "APIKEY",
"assets": [
{ONE JSON OBJECT FOR EACH ASSET TO BE CREATED}
]
}
Update Assets API
Update a Single Asset
URL: https://app.tec-rfid.co.uk/api/v2/update-asset-api
Method: POST
Headers:
- Content-Type: application/json
Payload Format:
The required payload will vary significantly depending on your organisation's required fields. To determine your required format, just send your API key on its own, as below, and the response will be reference JSON for you to use.
{
"api_key": "APIKEY"
}
You will only need to send required fields (which will always include asset ID, name, and tag, but are otherwise determined by your organization's settings).
Fields sent with null or blank values in the payload will be overwritten; if you want a field to retain its original value, don't send it in the payload and it will be ignored.
Since you will need to include required fields even if you don't want to change them, we suggest structuring your code to make sure you have access to and are sending all required fields in your API updates.
The basic required fields are the asset ID, asset name and EPC. Below is an example of the minimum fields required for updating the API.
{
"api_key": "APIKEY",
"id": "ASSETID",
"name": "ASSETNAME",
"asset_tag": "EPC"
}
For custom fields, the JSON response will return information listed below, which assist with knowing what the format needs to be. The only required fields for updating a custom field are the ID of the custom fields and the values to be updated.
"custom_fields": [
{
"id":ID(integer),
"custom_field_type":"global/asset_type_specific",
"name":"NAME",
"field_type":"FIELDTYPE",
"format":"FORMAT",
"help_text":"HELPTEXT",
"is_required":0,
"values":["VALUE1","VALUE2"]
}
]
An example format for updating assets including custom fields is below. Some standard fields are hidden - see the top of this section for how to get a specific payload for your organisation.
{
"api_key": "APIKEY",
"id": "Asset ID * (record will update by this ID)",
"name": "Asset Name *",
"asset_tag": "EPC RFID (Code) *",
"type": "Asset Type",
"location": "Location",
"status": "Active / Archived",
"custom_fields": [
{
"id":123,
"values":["VALUE1"]
},
{
"id":124,
"values":["VALUE2"]
}
]
}
Response Types:
Success
{
"status": "success",
"message": "Asset updated successfully",
"data": [
{RETURNS JSON OBJECT FOR ASSET UPDATED}
]
}
Failure
{
"status": "fail",
"message": "Please use following format",
"JsonBodyFormat": {REFERENCE FORMAT FOR YOUR ORGANISATION}
}
Bulk Update Assets by EPC RFID Code
URL: https://app.tec-rfid.co.uk/api/bulk-update-asset-master-field-by-epcrfid
Method: POST
Headers:
- Content-Type: application/json
Payload Format:
This API allows you to update assets by using their EPC RFID code field. The required payload will vary significantly depending on your organisation's required fields. To determine your required format, just send your API key on its own, as below, and the response will be reference JSON for you to use.
{
"api_key": "APIKEY"
}
The only required field to update an asset with this API is the EPC RFID code. For each bulk update, you can update as many fields as you like, but you cannot update assets to different values per field in a single request.
Bulk Update Assets by Asset ID
URL: https://app.tec-rfid.co.uk/api/bulk-update-asset-master-field-by-assetid
Method: POST
Headers:
- Content-Type: application/json
Payload Format:
This API allows you to update assets by using their ID. The required payload will vary significantly depending on your organisation's required fields. To determine your required format, just send your API key on its own, as below, and the response will be reference JSON for you to use.
{
"api_key": "APIKEY"
}
The only required field to update an asset with this API is the ID. For each bulk update, you can update as many fields as you like, but you cannot update assets to different values per field in a single request.
Location APIs
Get Last Scanned Location and Timestamp
URL: https://app.tec-rfid.co.uk/api/last-scanned-location-and-timestamp
Method: POST
Headers:
- Content-Type: application/json
Payload Format:
{
"api_key": "APIKEY",
"asset_tag": "EPC/RFIDCODE"
}
Sample Response:
{
"status": "success",
"message": "",
"data": {
"asset_tag": "0088881000010000",
"last_scanned_location": "Test Location 1",
"timestamp_last_scan": "15/04/2023 17:52:11"
}
}
Get Last X Amount of Scanned Locations
URL: https://app.tec-rfid.co.uk/api/last-x-amount-of-scanned-locations
Method: POST
Headers:
- Content-Type: application/json
Payload Format:
{
"api_key": "APIKEY",
"asset_tag": "TAG/EPC/RFIDCODE",
"no_of_locations": INTEGER
}
Sample Response:
{
"status": "success",
"message": "",
"data": [
{
"location": "Location A",
"first_scan": "14/02/2023 17:52:11",
"last_scan": "01/05/2023 17:52:11"
},
{
"location": "Location B",
"first_scan": "22/03/2023 17:52:11",
"last_scan": "29/04/2023 17:52:11"
}
]
}
Items Seen at Location in Last X Seconds
URL: https://app.tec-rfid.co.uk/api/item-seen-at-location-in-last-x-seconds
Method: POST
Headers:
- Content-Type: application/json
Payload Format:
{
"api_key": "APIKEY",
"location": "LOCATION_NAME",
"seconds": INTEGER
}
Sample Response:
{
"status": "success",
"message": "",
"data": {
"assets": [
{
"id": 76,
"name": "Testing Asset 2 (Dell 431)",
"asset_tag": "EPC00000002",
"asset_number": null,
"image": null,
"serial_number": "12345",
"description": "This is just for testing 2",
"due_date": "16/06/2022",
"category": "Electronics.",
"user": "New Test User 1",
"location": "Liverpool",
"value": "200000",
"notes": "Testing Note",
"asset_type": "LED",
"last_scan_timestamp": "16/04/2023 17:52:11"
},
{
"id": 76,
"name": "Testing Asset 2 (Dell 431)",
"asset_tag": "EPC00000002",
"asset_number": null,
"image": null,
"serial_number": "12345",
"description": "This is just for testing 2",
"due_date": "16/06/2022",
"category": "Electronics.",
"user": "New Test User 1",
"location": "Liverpool",
"value": "200000",
"notes": "Testing Note",
"asset_type": "LED",
"last_scan_timestamp": "16/04/2023 17:52:11"
}
]
}
}
Fixed Reader API
Adding/Updating Reader IDs
On the web portal, go to Locations, find the location you're looking for, and click Edit (pencil icon). The Reader Id(s) field is towards the bottom of the Edit interface. Reader IDs must be alphanumeric; you can add multiple reader IDs, comma-separated.
Update Asset Location By Reader ID
URL: https://app.tec-rfid.co.uk/api/update-asset-location-by-reader-id
Method: POST
Headers:
- Content-Type: application/json
Payload Format:
{
"api_key": "API_KEY",
"reader_id": "READER_ID",
"tag": "EPC (RFIDCODE)"
}
Example Payload:
{
"api_key": "cxVYOm3Kqy1hFHGydatCIKoZY2AtffS3hO0JeZly",
"reader_id": "RED31",
"tag": "EPC00000001"
}
Response Types:
Success
{
"status": "success",
"message": "asset updated successfully"
}
Failure
{
"status": "fail",
"message": "reader not found"
}
{
"status": "fail",
"message": "asset not found"
}
{
"status": "fail",
"message": "API Key is missing."
}
{
"status": "fail",
"message": "Invalid API Key."
}
Bulk Update Asset Location By Reader ID
URL: https://app.tec-rfid.co.uk/api/bulk-update-asset-location-by-reader
Method: POST
Headers:
- Content-Type: application/json
Payload Format:
{
"api_key": "API_KEY",
"data": [
{"reader_id":"READER_ID","tag":"EPC (RFIDCODE)","timestamp":"DATETIME"}
]
}
Example Payload:
{
"api_key": "cxVYOm3Kqy1hFHGydatCIKoZY2AtffS3hO0JeZly",
"data":[
{"reader_id":"r2", "tag": "aaa2", "timestamp":"2023-06-11 11:37:42"},
{"reader_id":"r2", "tag": "aaa3", "timestamp":"2023-06-11 11:36:42"}
]
}
Response Types:
Success
{
"status": "success",
"message": "locations updated successfully",
"processing_time": 0
}
Failure
{
"status": "fail",
"message": "Something went wrong when loading your data"
}