Create a custom endpoint for Analytics Manager queries
Rework pending, no delivery date. The Front App SDK (ReactJS) and the Front API SDK (NodeJS) are both being replaced. This page documents the current release, remains accurate, and is maintained until the replacement ships. Code written against it keeps working.
It is possible to easily extend the Analytics Manager query flow by adding new endpoints.
Those endpoints can then be called from any chart in the Front App to be displayed.
Here are some use examples:
- merge 2 queries in one result
- use Machine Learning to compute and display forecast
- do some computation on results before returning them
Create a new endpoint
Simply add a file in
./src/qb/endpoints/.
This folder does not exist by default, it must be created from the root of the Front API.
For instance, adding the following file provides an answer from a GET request on qb/hello_world :
./src/qb/endpoints/hello_world.js
Merge two queries
In this example, consider a dataset containing the turnover of Data Platform and 4 other companies. The objective is to compare :
- the evolution of the Data Platform turnover
- the evolution of the sum of all turnover (Data Platform + 4 others).
The Analytics Manager query format needs 2 different queries :
In order to build a chart with 2 curves in the Front App, the custom endpoint should return the appropriate result set.
In this example :
- both queries are made through the
QueryBuilder.queries()helper function. - responses consist of 2 distinct results : the Front App does not handle it as is.
- the module
Mergeoffers basic merge functions to accumulate queries.
TherenameWithIdoption provides two forepaas:turnover and global:turnover fields in return.
To be noticed
Caching and activation of authentication is done automatically.
Improve to be dynamic
In most cases, custom endpoints are not simple GET requests that always compute the same request. Usually, the request(s) sent to the Analytics Manager are dynamically generated using the body of the request.
In order to do so, the request's method needs to change to POST and queries passed as variable.
These changes result in the following code:
Call it from the Front App
In the JSON of a Chart, instead of using the request parameter, all you have to do is use the endpoint parameter, as in this example:
For an endpoint in POST, dynamic parameter values will be passed in req.body.
Go further
If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for a custom analysis of your project.
Ask questions, give your feedback and interact directly with the team building the Data Platform on the dedicated Discord channel.
If you need support with your OVHcloud services, create a request in our Help Centre.
Join our community of users.

