NGSI-LD API Access Guide
Access Open Data Models attribute descriptions through standardized NGSI-LD queries
đ What is this API?
This page provides information on how to access the Open Data Models attribute descriptions through the NGSI-LD API.
đ Data Model Structure
| Property | Type | Description |
|---|---|---|
id |
string (URI) | Unique identifier for the attribute |
type |
string | NGSI-LD Entity type (always “Attribute”) |
attributeName |
string | Name of the attribute |
dataModel |
string | The data model this attribute belongs to |
description |
string | Description of the attribute |
dataType |
string | Data type of the attribute (string, number, etc.) |
modelTags |
string | Tags associated with the data model |
repoLink |
string (URL) | Link to the GitHub repository |
đ Full Specification: You can view the complete data model specification at:
GitHub Specification |
JSON Schema
đĄ Example Queries
Example 1: Querying a Specific Attribute
To retrieve information about a specific attribute, you can query by its unique identifier. Here’s an example querying the name attribute from the MachineLearning data model:
đš Using cURL
curl -X GET \ 'http://opendatamodels.org:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Attribute:smartdatamodels.org:dataModel.MachineLearning:MLProcessing:name%230.0.2' \ -H 'Accept: application/ld+json'
đš Using Python
import requests
import json
url = "http://opendatamodels.org:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Attribute:smartdatamodels.org:dataModel.MachineLearning:MLProcessing:name%230.0.2"
headers = {
"Accept": "application/ld+json"
}
response = requests.get(url, headers=headers)
data = response.json()
print(json.dumps(data, indent=2))
đš Using JavaScript (Node.js/Browser)
const url = "http://opendatamodels.org:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Attribute:smartdatamodels.org:dataModel.MachineLearning:MLProcessing:name%230.0.2";
fetch(url, {
method: 'GET',
headers: {
'Accept': 'application/ld+json'
}
})
.then(response => response.json())
.then(data => console.log(JSON.stringify(data, null, 2)))
.catch(error => console.error('Error:', error));
â Example Response
{
"id": "urn:ngsi-ld:Attribute:smartdatamodels.org:dataModel.MachineLearning:MLProcessing:name#0.0.2",
"type": "Attribute",
"attributeName": {
"type": "Property",
"value": "name"
},
"dataModel": {
"type": "Property",
"value": "MLProcessing"
},
"description": {
"type": "Property",
"value": "The name of this item"
},
"dataType": {
"type": "Property",
"value": "string"
},
"modelTags": {
"type": "Property",
"value": "ML, MachineLearning, AI"
},
"repoLink": {
"type": "Property",
"value": "https://github.com/smart-data-models/dataModel.MachineLearning"
},
"@context": [
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
]
}
Example 2: Querying Another Attribute (Urban Mobility)
Here’s another example querying the description attribute from the UrbanMobility data model:
đš Using cURL
curl -X GET \ 'http://opendatamodels.org:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Attribute:smartdatamodels.org:dataModel.UrbanMobility:GtfsStopTime:description%230.0.2' \ -H 'Accept: application/ld+json'
đš Using Python
import requests
import json
url = "http://opendatamodels.org:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Attribute:smartdatamodels.org:dataModel.UrbanMobility:GtfsStopTime:description%230.0.2"
headers = {
"Accept": "application/ld+json"
}
response = requests.get(url, headers=headers)
data = response.json()
print(json.dumps(data, indent=2))
đš Using JavaScript (Node.js/Browser)
const url = "http://opendatamodels.org:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Attribute:smartdatamodels.org:dataModel.UrbanMobility:GtfsStopTime:description%230.0.2";
fetch(url, {
method: 'GET',
headers: {
'Accept': 'application/ld+json'
}
})
.then(response => response.json())
.then(data => console.log(JSON.stringify(data, null, 2)))
.catch(error => console.error('Error:', error));
â Example Response
{
"id": "urn:ngsi-ld:Attribute:smartdatamodels.org:dataModel.UrbanMobility:GtfsStopTime:description#0.0.2",
"type": "Attribute",
"attributeName": {
"type": "Property",
"value": "description"
},
"dataModel": {
"type": "Property",
"value": "GtfsStopTime"
},
"description": {
"type": "Property",
"value": "A description of this item"
},
"dataType": {
"type": "Property",
"value": "string"
},
"modelTags": {
"type": "Property",
"value": "GTFS, UrbanMobility, Transportation"
},
"repoLink": {
"type": "Property",
"value": "https://github.com/smart-data-models/dataModel.UrbanMobility"
},
"@context": [
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
]
}
Example 3: Query Structure for Searching Attributes
While this page doesn’t execute live queries, you can search for attributes using NGSI-LD query parameters. Here’s an example structure for filtering attributes by data model:
curl -X GET \ 'http://opendatamodels.org:1026/ngsi-ld/v1/entities/?type=Attribute&q=dataModel==%22MLProcessing%22' \ -H 'Accept: application/ld+json'
Query Parameters Explanation:
type=Attributeâ Filters entities to only Attribute typesq=dataModel=="MLProcessing"â Filters by the dataModel property value- You can combine multiple conditions using
&or|operators
â ī¸ Note: Remember to URL-encode special characters in your queries. The # character in attribute IDs should be encoded as %23.
đ NGSI-LD Standard Resources
To learn more about the NGSI-LD standard and how to work with NGSI-LD APIs, please refer to these resources:
âšī¸ Additional Information
Attribute ID Format
Attribute identifiers follow this structure:
Example breakdown:
urn:ngsi-ld:Attributeâ NGSI-LD URN prefix and entity typesmartdatamodels.orgâ Authority/namespacedataModel.MachineLearningâ Domain identifierMLProcessingâ Data model namenameâ Attribute nameversionâ Version of the schema of the data model