Getting historical raw context information
Documents the HTTP REST API for querying historical raw context information from the STH component, including pagination, date filtering, and CSV export.
What this file does
Documents the HTTP REST API for querying historical raw context information from the STH component, including pagination, date filtering, and CSV export.
When to use it
- You need to retrieve raw context data from a FIWARE STH server
- You want to paginate through historical context attribute values
- You need to export raw context data as CSV
- You are migrating from the deprecated v1 API to v2
Assumes this stack
Getting historical raw context information
The STH component exposes an HTTP REST API to let external clients query the available historical raw context information.
A typical URL querying for this information using a GET request is the following:
http://<sth-host>:<sth-port>/STH/v2/entities/<entityId>/attrs/<attrName>?type=<entityType>&hLimit=3&hOffset=0&dateFrom=2016-01-01T00:00:00.000Z&dateTo=2016-01-31T23:59:59.999Z
Notice that in the previous URL we have used some templates between < and > which should be substituted by the
corresponding real values.
Also notice that in the previous request a paginated response has been requested with a limit of 3 entries and an offset of 0 entries (first page).
The requests for raw context information can use the following query parameters:
- lastN: Only the requested last entries will be returned. It is a mandatory parameter if no
hLimitandhOffsetare provided. - hLimit: In case of pagination, the number of entries per page. It is a mandatory parameter if no
lastNis provided. - hOffset: In case of pagination, the offset to apply to the requested search of raw context information. It is a
mandatory parameter if no
lastNis provided. - dateFrom: The starting date and time from which the raw context information is desired. It is an optional parameter.
- dateTo: The final date and time until which the raw context information is desired. It is an optional parameter.
- file type: The raw context information can be requested as a file setting this query parameter to the desired
file type. Currently, the only supported value and file type is
csv. It is an optional parameter. - count: The total count of elements could be asked using this query parameter. Supported values are
trueorfalse. As a result response will include a new header: Fiware-Total-Count. It is an optional parameter which default isfalse.
NOTE: Date is specified using the ISO 8601 standard format.
In order to avoid problems handing big results there is a restriction about the number of results per page that could be
retrieved. The rule is hLimit <= lastN <= config.maxPageSize Where default max page is are defined to 100.
An example response provided by the STH component to a request such as the previous one could be the following:
{
"type": "StructuredValue",
"values": [
{
"recvTime": "2016-01-14T13:43:33.306Z",
"attrValue": "21.28"
},
{
"recvTime": "2016-01-14T13:43:34.636Z",
"attrValue": "23.42"
},
{
"recvTime": "2016-01-14T13:43:35.424Z",
"attrValue": "22.12"
}
]
}
It is important to note that if a valid query is made but it returns no data (for example because there is no raw
context information for the specified time frame), a response with code 200 is returned including an empty values
property array, since it is a valid query.
Deprecated API
There is an alternative method based in old V1 API. However, this is deprecated functionality, included here for the sake of completeness. You are encouraged to not using it, as it can be removed in a future STH version.
Alternative URL:
http://<sth-host>:<sth-port>/STH/v1/contextEntities/type/<entityType>/id/<entityId>/attributes/<attrName>?hLimit=3&hOffset=0&dateFrom=2016-01-01T00:00:00.000Z&dateTo=2016-01-31T23:59:59.999Z
Example response:
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "attrName",
"values": [
{
"recvTime": "2016-01-14T13:43:33.306Z",
"attrValue": "21.28"
},
{
"recvTime": "2016-01-14T13:43:34.636Z",
"attrValue": "23.42"
},
{
"recvTime": "2016-01-14T13:43:35.424Z",
"attrValue": "22.12"
}
]
}
],
"id": "entityId",
"isPattern": false
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
What's inside
1 API endpoint description, 7 query parameters, 2 example responses, 1 deprecated API section
Change this for your project
- Replace
<sth-host>and<sth-port>with your STH server address - Replace
<entityId>,<entityType>, and<attrName>with your entity and attribute identifiers - Adjust
config.maxPageSizedefault of 100 if your deployment uses a different limit
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Returning HTTP 200 with an empty
valuesarray for valid queries that yield no data - Using
Fiware-Total-Countheader for total result counts
Related Documents
Zig 0.16.0 Context Document for LLMs
Documents breaking changes from Zig 0.13/0.14 to 0.16.0, covering syntax, I/O, build system, and standard library updates.
绘制对比图片 KITTI
Documents the topic remapping and data flow needed to connect Fast-LIO2 frontend with SC-PGO backend for KITTI evaluation.
Beads Workflow Context
Guides when to use bd graph-based issue tracker versus TodoWrite for session vs multi-session work, with commands and workflows.
EPIC: usda-data-crush-stats
Maps a multi-year USDA grape crush data pipeline from raw downloads through bronze, silver, and gold layers to final CSV fact and dimension tables.