{"id":18419,"date":"2025-06-04T11:44:23","date_gmt":"2025-06-04T09:44:23","guid":{"rendered":"https:\/\/smartdatamodels.org\/?p=18419"},"modified":"2025-06-04T11:44:23","modified_gmt":"2025-06-04T09:44:23","slug":"use-smart-data-models-as-a-service-first-draft","status":"publish","type":"post","link":"https:\/\/smartdatamodels.org\/index.php\/use-smart-data-models-as-a-service-first-draft\/","title":{"rendered":"Use smart data models as a service. First draft"},"content":{"rendered":"<p>In the data-models repository you can access to the first version to use smart data models as a service. Thanks to the works for the <a href=\"https:\/\/www.cyclopsproject.eu\/\">Cyclops project<\/a>.<\/p>\n<p>The files available create a wrap up around <a href=\"https:\/\/pypi.org\/project\/pysmartdatamodels\/\">pysmartdatamodels<\/a> package and also add one service for the online validation of NGSI-LD payloads.<\/p>\n<p>Here is the <a href=\"https:\/\/github.com\/smart-data-models\/data-models\/blob\/master\/sdm_as_a_service\/README.md\">readme<\/a> contents to have an explanation of this first version<\/p>\n<p>&nbsp;<\/p>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h1 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Smart Data Models API and Demo<\/h1>\n<\/div>\n<p dir=\"auto\">This project consists of two main components:<\/p>\n<ol dir=\"auto\">\n<li>A FastAPI-based web service (<code>pysdm_api3.py<\/code>) that provides access to Smart Data Models functionality<\/li>\n<li>A demo script (<code>demo_script2.py<\/code>) that demonstrates the API endpoints<\/li>\n<li>A requirements file for the components use<\/li>\n<li>A bash script to run it<\/li>\n<\/ol>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h2 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">API Service (<code>pysdm_api3.py<\/code>)<\/h2>\n<\/div>\n<p dir=\"auto\">A RESTful API that interfaces with the <code>pysmartdatamodels<\/code> library to provide access to Smart Data Models functionality.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h3 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Key Features<\/h3>\n<\/div>\n<ul dir=\"auto\">\n<li><strong>Payload Validation<\/strong>: Validate JSON payloads against Smart Data Models schemas<\/li>\n<li><strong>Data Model Exploration<\/strong>: Browse subjects, data models, and their attributes<\/li>\n<li><strong>Search Functionality<\/strong>: Find data models by exact or approximate name matching<\/li>\n<li><strong>Context Retrieval<\/strong>: Get @context information for data models<\/li>\n<li>if you need other please email us to info @ smartdatamodels. org<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h3 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Endpoints<\/h3>\n<\/div>\n<table>\n<thead>\n<tr>\n<th>Endpoint<\/th>\n<th>Method<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>\/validate-url<\/code><\/td>\n<td>GET<\/td>\n<td>Validate a JSON payload from a URL against Smart Data Models<\/td>\n<\/tr>\n<tr>\n<td><code>\/subjects<\/code><\/td>\n<td>GET<\/td>\n<td>List all available subjects<\/td>\n<\/tr>\n<tr>\n<td><code>\/datamodels\/{subject_name}<\/code><\/td>\n<td>GET<\/td>\n<td>List data models for a subject<\/td>\n<\/tr>\n<tr>\n<td><code>\/datamodels\/{subject_name}\/{datamodel_name}\/attributes<\/code><\/td>\n<td>GET<\/td>\n<td>Get attributes of a data model<\/td>\n<\/tr>\n<tr>\n<td><code>\/datamodels\/{subject_name}\/{datamodel_name}\/example<\/code><\/td>\n<td>GET<\/td>\n<td>Get an example payload of a data model<\/td>\n<\/tr>\n<tr>\n<td><code>\/search\/datamodels\/{name_pattern}\/{likelihood}<\/code><\/td>\n<td>GET<\/td>\n<td>Search for data models by approximate name<\/td>\n<\/tr>\n<tr>\n<td><code>\/datamodels\/exact-match\/{datamodel_name}<\/code><\/td>\n<td>GET<\/td>\n<td>Find a data model by exact name<\/td>\n<\/tr>\n<tr>\n<td><code>\/subjects\/exact-match\/{subject_name}<\/code><\/td>\n<td>GET<\/td>\n<td>Check if a subject exists by exact name<\/td>\n<\/tr>\n<tr>\n<td><code>\/datamodels\/{datamodel_name}\/contexts<\/code><\/td>\n<td>GET<\/td>\n<td>Get @context(s) for a data model name<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h3 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Validation Process<\/h3>\n<\/div>\n<p dir=\"auto\">The <code>\/validate-url<\/code> endpoint performs comprehensive validation:<\/p>\n<ol dir=\"auto\">\n<li>Fetches JSON from the provided URL<\/li>\n<li>Normalizes NGSI-LD payloads to key-values format<\/li>\n<li>Extracts the payload type<\/li>\n<li>Finds all subjects containing this type<\/li>\n<li>Retrieves schemas for each subject<\/li>\n<li>Validates against all schemas<\/li>\n<li>Returns consolidated results<\/li>\n<\/ol>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h2 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Demo Script (<code>demo_script2.py<\/code>)<\/h2>\n<\/div>\n<p dir=\"auto\">A simple interactive script that demonstrates the API endpoints by opening a series of pre-configured URLs in your default web browser.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h3 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Features<\/h3>\n<\/div>\n<ul dir=\"auto\">\n<li>Opens each URL in a new browser tab<\/li>\n<li>Pauses between URLs for user input<\/li>\n<li>Allows early termination with &#8216;exit&#8217; command<\/li>\n<li>Provides clear progress indicators<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h3 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Usage<\/h3>\n<\/div>\n<ol dir=\"auto\">\n<li>Configure the URLs in the <code>my_web_urls<\/code> list<\/li>\n<li>Run the script: <code>python demo_script2.py<\/code><\/li>\n<li>Follow the on-screen instructions<\/li>\n<\/ol>\n<p dir=\"auto\">The demo includes examples of:<\/p>\n<ul dir=\"auto\">\n<li>Payload validation<\/li>\n<li>Subject listing<\/li>\n<li>Data model exploration<\/li>\n<li>Attribute retrieval<\/li>\n<li>Example payloads<\/li>\n<li>Search functionality<\/li>\n<li>Exact matching<\/li>\n<li>Context retrieval<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h2 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Requirements<\/h2>\n<\/div>\n<ul dir=\"auto\">\n<li>Python 3.7+<\/li>\n<li>FastAPI<\/li>\n<li>Uvicorn<\/li>\n<li>httpx<\/li>\n<li>pydantic<\/li>\n<li>jsonschema<\/li>\n<li>webbrowser (standard library)<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h2 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Installation<\/h2>\n<\/div>\n<pre>pip install fastapi uvicorn httpx pydantic jsonschema<\/pre>\n<div class=\"zeroclipboard-container\"><\/div>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h2 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Running the API<\/h2>\n<\/div>\n<pre>python pysdm_api3.py<\/pre>\n<div class=\"zeroclipboard-container\"><\/div>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h2 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Running the demo<\/h2>\n<\/div>\n<pre>python demo_script2.py<\/pre>\n<div class=\"zeroclipboard-container\"><\/div>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h2 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">Configuration<\/h2>\n<\/div>\n<p dir=\"auto\">Edit the my_web_urls list in demo_script2.py to change which endpoints are demonstrated.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\">\n<h2 class=\"heading-element\" dir=\"auto\" tabindex=\"-1\">License<\/h2>\n<\/div>\n<p>Apache 2.0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the data-models repository you can access to the first version to use smart data models as a service. Thanks to the works for the Cyclops project. The files available create a wrap up around pysmartdatamodels package and also add one service for the online validation of NGSI-LD payloads. Here&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/smartdatamodels.org\/index.php\/use-smart-data-models-as-a-service-first-draft\/\">More&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[105,107,109,113,115,119,117,88,143,111,125,182,201],"tags":[],"class_list":["post-18419","post","type-post","status-publish","format-standard","hentry","category-cross-sector","category-smart-cities","category-smart-energy-domain","category-smart-environment","category-smart-manufacturing","category-smart-robotics","category-smart-water","category-smart-sensoring","category-smartaeronautics","category-smart-agrifood","category-smartdestinations","category-smarthealth","category-smartlogistics"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":10252,"url":"https:\/\/smartdatamodels.org\/index.php\/new-scripts-released\/","url_meta":{"origin":18419,"position":0},"title":"New scripts released","author":"maestro","date":"24\/01\/2024","format":false,"excerpt":"4 of the python scripts that are used to maintain the Smart Data models have been released. Use them or study it at your own convenience. Glad to receive comments and improvements Check them out here: 30_f_properties_inventory_10.0.py 35_create_term_pages6.0.py 37_create_entity_pages_v2.0.py 60_generate_datamodel_readmes_v17.0.py","rel":"","context":"In &quot;Cross Sector&quot;","block_context":{"text":"Cross Sector","link":"https:\/\/smartdatamodels.org\/index.php\/category\/cross-sector\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/smartdatamodels.org\/wp-content\/uploads\/2022\/11\/python-logo-master-v3-TM-flattened.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/smartdatamodels.org\/wp-content\/uploads\/2022\/11\/python-logo-master-v3-TM-flattened.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/smartdatamodels.org\/wp-content\/uploads\/2022\/11\/python-logo-master-v3-TM-flattened.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":10091,"url":"https:\/\/smartdatamodels.org\/index.php\/new-service-export-you-data-models-to-sql-schema\/","url_meta":{"origin":18419,"position":1},"title":"New service: Export you data models to SQL schema","author":"maestro","date":"30\/10\/2023","format":false,"excerpt":"We provide a service to Generate a PostgreSQL schema SQL script from the model.yaml representation of a Smart Data Model. You can access this service under this link following Tools > SQL service. You need to provide as input the standard GitHub link to the model.yaml file or the raw\u2026","rel":"","context":"In &quot;Smart Cities domain&quot;","block_context":{"text":"Smart Cities domain","link":"https:\/\/smartdatamodels.org\/index.php\/category\/smart-cities\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/smartdatamodels.org\/wp-content\/uploads\/2023\/10\/Screen-Shot-2023-10-30-at-17.14.41-300x201.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":32588,"url":"https:\/\/smartdatamodels.org\/index.php\/new-mcp-service-to-use-smart-data-models-in-your-local-ai-agent-autonomous-light-management-4-smart-data-models\/","url_meta":{"origin":18419,"position":2},"title":"New MCP service to use smart Data models in your local AI agent. Autonomous light management 4  Smart Data Models","author":"maestro","date":"10\/03\/2026","format":false,"excerpt":"Are you building AI applications for Smart Cities, Energy, or IoT? Interoperability is often the biggest hurdle\u2014but a new tool is making it easier to keep your LLMs \"in the loop\" with global standards. Introducing the Smart Data Models MCP Server, a new reference implementation that connects Large Language Models\u2026","rel":"","context":"In &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/smartdatamodels.org\/index.php\/category\/ai\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/smartdatamodels.org\/wp-content\/uploads\/2026\/03\/Screenshot-from-2026-03-09-18-58-58.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1842,"url":"https:\/\/smartdatamodels.org\/index.php\/alpha-version-of-the-service-for-generating-an-ngsi-ld-payload-based-on-a-smart-data-model\/","url_meta":{"origin":18419,"position":3},"title":"Alpha version of the service for generating an NGSI-LD payload based on a Smart Data Model","author":"maestro","date":"03\/03\/2021","format":false,"excerpt":"This is an alpha version (so you can expect errors and not being complete). Use it at your own risk. Please report errors and suggestions at info@smartdatamodels.org Call: https:\/\/smartdatamodels.org\/extra\/ngsi-ld_generator.php Parameters: (Mandatories) schemaUrl: The link to the RAW version of the json schema (see example) email: your email Example: https:\/\/smartdatamodels.org\/extra\/ngsi-ld_generator.php?schemaUrl=https:\/\/raw.githubusercontent.com\/smart-data-models\/dataModel.Streetlighting\/f56f5a7933ab05d7fce1d5adc0847f25a099cdb4\/StreetlightModel\/schema.json&email=alberto.abella@fiware.org Use\u2026","rel":"","context":"In &quot;Cross Sector&quot;","block_context":{"text":"Cross Sector","link":"https:\/\/smartdatamodels.org\/index.php\/category\/cross-sector\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":698,"url":"https:\/\/smartdatamodels.org\/index.php\/drafting-service-for-checking-properties-of-a-new-data-model\/","url_meta":{"origin":18419,"position":4},"title":"Drafting service for checking properties of a new data model","author":"maestro","date":"08\/10\/2020","format":false,"excerpt":"We are in the way of creating a service for those contributors willing to contribute with a complete data model. The service is under debugging, so it cannot be trusted for production purposes. Let us know issues here In order to access it has to access this URL (https:\/\/smartdatamodels.org\/extra\/check_properties.php) with\u2026","rel":"","context":"In &quot;Internal&quot;","block_context":{"text":"Internal","link":"https:\/\/smartdatamodels.org\/index.php\/category\/internal\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/smartdatamodels.org\/wp-content\/uploads\/2020\/10\/Selection_156.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3399,"url":"https:\/\/smartdatamodels.org\/index.php\/new-ontology-mapped-gsma\/","url_meta":{"origin":18419,"position":5},"title":"New ontology mapped: GSMA","author":"maestro","date":"26\/11\/2021","format":false,"excerpt":"GSMA in their Iot Big data project has created an ontology for mapping some of the elemtens in the data models. Now in the folder data-models > context -> ontologies_files ->gsma.json you have the file you can use with the external @context generator service in the main menu.","rel":"","context":"In &quot;Cross Sector&quot;","block_context":{"text":"Cross Sector","link":"https:\/\/smartdatamodels.org\/index.php\/category\/cross-sector\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/posts\/18419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/comments?post=18419"}],"version-history":[{"count":1,"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/posts\/18419\/revisions"}],"predecessor-version":[{"id":18421,"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/posts\/18419\/revisions\/18421"}],"wp:attachment":[{"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/media?parent=18419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/categories?post=18419"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smartdatamodels.org\/index.php\/wp-json\/wp\/v2\/tags?post=18419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}