The [[Cube]] semantics API enables your organisation to service downstream data applications with custom queries.  The semantic model defines all entities, measures, metrics, timestamps and its relations. The data itself has been cleaned and transformed by in the datawarehouse beforehand using [[dbt]]. ## Architecture The interactive UI below is connected to the demonstration semantics API and is connected to a [BigQuery dataset](https://console.cloud.google.com/bigquery?ws=!1m5!1m4!4m3!1seternal-ship-306122!2sabd_dbt!3sfct_invoices) with 28 million records representing all the invoices sent by the Alcoholic Beverage Division from the State of Iowa since 2012. The configuration of the semantic model can be found in our [GitHub repository](https://github.com/maxq-analytics/abd_cube). To get a better feel for the underlying data behind the semantics API, we refer you to the dedicated [[Internal Analytics]] reports inside [Looker Studio](https://lookerstudio.google.com/u/0/reporting/86bd9839-3788-4b62-a1d9-4ce312bbff3e/page/p_etg6w1911c). ## SQL generator Cube generates queries in the JSON-format based on the input provided through their API. ![[Cube Query.png]] *Query that requests the multiple metrics over the last 60 months for Fireball brand* <br> The incoming query API requests, are translated into SQL statements, taking into account the dialect of the underlying datawarehouse, which is [[BigQuery]] in our demonstration. ![[Cube SQL Query.png]] *Generated SQL that is executed in the BigQuery datawarehouse* <br> Commonly recurring queries are auto-cached by cube based on the volume of usage. This setup enables cube to respond in miliseconds on queries that without the semantic caching layer would take several seconds. ![[Cube auto-caching.png]] *Auto-cached response based on frequently used query entries* ## Demonstration You can set the filters as input for the query that is sent to the Semantic API, which generates a JSON response, looking as such: ![[Semantics API response.png]] *Example response from Semantics API demonstration interface* <br> All of the filters shown below in the iframe are properties inside the datamodel. Try out one of the following filter combinations and check the API response: 1. City: `Waterloo`, Vendor Name: `Proximo`, Date Range: `Last 60 months` 2. City: `Des Moines`, Item Description: `Black Velvet`, Date Range: `Last year` 3. Brand: `Fireball`, Date Range: `Last 100 weeks`, Granularity: `Months` <br> <iframe src="https://maxq-analytics.github.io/maxq-website/semantic_api.html" frameborder="0" style="width: 100%; height: 1500px; border: none;"></iframe> ## Use cases The semantics API can be used for a multitude of use cases: - **Self-Service Analytics** - Business users can query data using natural language or BI tools like Tableau and Power BI, ensuring consistency and accuracy in reporting. - **Embedded Analytics** - Developers can integrate real-time, interactive dashboards and analytics into SaaS applications without requiring complex backend queries. - **Machine Learning Feature Store** - Data scientists can access aggregated, cleaned, and pre-processed data as input for machine learning models, ensuring consistent feature definitions. - **API-Driven AI Agents** - AI-powered agents can leverage structured data to provide real-time insights, automate decisions, or power conversational AI systems for business intelligence.