# CPH Developers Consuption API
# POST /consumer/data/average
# Parameters
- Average Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"end_date": "string",
"prefixes": [
"string"
],
"granularity": "string",
"id_name_field": "string",
"ids": [
"string"
],
"metric_name_field": [
"string"
],
"entity": "string",
"start_date": "string"
}
# Resposes
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 413: occurs when an attempt is made to upload a file that is too large
# POST /consumer/data/average-dimensions
This method returns the mathematical average of a metric for the range of data and periodicity requested including extra dimension fields. Query parameters are included in the request body as follows:
- entity: The entity to be queried.
- prefixes: List of prefixes which will be returned. If empty, all prefixes will be returned.
- id_name_field: The tag used to filter.
- ids: The values of the tag (id_name_field) to be returned.
- metric_name_field: The name of the metric fields to be returned.
- granularity: The way to aggregate the data. You can check allowed granularities here (opens new window).
- start_date: The earliest date to be returned in ISO 8601 format.
- end_date: The latest date to be returned in ISO 8601 format.
NOTE: start_date or end_date can include durations when the other field includes a specific date. For example, {"start_date": "2020-01-01T00:00:00Z", "end_date": "PT15M"} will return the data between 2020-01-01T00:00:00Z and 2020-01-01T00:15:00Z.
# Request example
{
"entity": "ingesta-rt-vizz",
"id_name_field": "id_tag",
"ids": ["01PHD.OSL101.PV"],
"metric_name_field": ["value", "min", "max"],
"prefixes": [],
"granularity": "fifteen_minute",
"start_date": "2019-12-10T00:00",
"end_date": "2019-12-14T00:00"
}
# Parameters
- Average Dimensions Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"end_date": "string",
"prefixes": [
"string"
],
"granularity": "string",
"id_name_field": "string",
"ids": [
"string"
],
"metric_name_field": [
"string"
],
"fields": [
"string"
],
"entity": "string",
"start_date": "string"
}
# Responses
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 413: occurs when an attempt is made to upload a file that is too large
# POST /consumer/data/average-granularity
This method returns the mathematical average of a metric for the range of data and periodicity requested including extra dimension fields. Query parameters are included in the request body as follows:
- entity: The entity to be queried.
- prefixes: List of prefixes which will be returned. If empty, all prefixes will be returned.
- id_name_field: The tag used to filter.
- ids: The values of the tag (id_name_field) to be returned.
- metric_name_field: The name of the metric fields to be returned.
- granularity: The way to aggregate the data. You can check allowed granularities here (opens new window).
- start_date: The earliest date to be returned in ISO 8601 format.
- end_date: The latest date to be returned in ISO 8601 format.
NOTE: start_date or end_date can include durations when the other field includes a specific date. For example, {"start_date": "2020-01-01T00:00:00Z", "end_date": "PT15M"} will return the data between 2020-01-01T00:00:00Z and 2020-01-01T00:15:00Z.
# Request example
{
"entity": "ingesta-rt-vizz",
"id_name_field": "id_tag",
"ids": ["01PHD.OSL101.PV"],
"metric_name_field": ["value", "min", "max"],
"prefixes": [],
"granularity": "fifteen_minute",
"start_date": "2019-12-10T00:00",
"end_date": "2019-12-14T00:00"
}
# Parameters
- Average Granularity Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"end_date": "string",
"prefixes": [
"string"
],
"granularity": "string",
"id_name_field": "string",
"ids": [
"string"
],
"metric_name_field": [
"string"
],
"fields": [
"string"
],
"entity": "string",
"start_date": "string"
}
# Responses
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 413: occurs when an attempt is made to upload a file that is too large
# POST /consumer/data/druid-native-query
This method is used to execute druid native queries via API. It receives native query objects. This objects varies based on the type of query, more info here (opens new window)
# Request Example
{
"queryType": "scan",
"dataSource": "neb-alarms",
"intervals": {
"type": "intervals",
"intervals": [
"-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"
]
},
"virtualColumns": [], "resultFormat": "list",
"limit": 100,
"order": "none",
"filter": null,
"columns": [
"__time",
"tag",
"value"
], "legacy": false,
"descending": false,
"granularity": {
"type": "all"
# Parameters
- Druid Native Query Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"query_data": {},
"query_type": "string"
}
# Responses
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 413: occurs when an attempt is made to upload a file that is too large
# GET /consumer/data/entities
This API does not require any previous parameter. It can be executed directly
# Responses
- 200: Means that the page has loaded correctly.
# POST /consumer/data/last
# Parameters
- Last Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"date": "string",
"prefixes": [
"string"
],
"offset": 0,
"id_name_field": "string",
"ids": [
"string"
],
"metric_name_field": [
"string"
],
"fields": [
"string"
],
"entity": "string"
}
# Responses
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 413: occurs when an attempt is made to upload a file that is too large
# POST /consumer/data/latest
This method returns the latest item from a query time range. Query parameters are included in the request body as follows:
- entity: The entity to be queried.
- prefixes: List of prefixes which will be returned. If empty, all prefixes will be returned.
- id_name_field: The tag used to filter.
- ids: The values of the tag (id_name_field) to be returned.
- metric_name_field: The name of the metric fields to be returned.
- date: The earliest date that can be returned in ISO 8601 format.
- date can include durations when the other field includes a specific date. For example, {"date": "PT15M"} will return the data between current time (UTC) - 15mins.
# Request example
{
"entity": "ingesta-rt-vizz",
"id_name_field": "id_tag",
"ids": ["01PHD.OSL101.PV"],
"metric_name_field": ["value", "min", "max"],
"prefixes": [],
"date": "2019-12-10T00:00"
}
# Parameters
- Latest Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"date": "string",
"prefixes": [
"string"
],
"id_name_field": "string",
"ids": [
"string"
],
"metric_name_field": [
"string"
],
"entity": "string"
}
# Resposes
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 413: occurs when an attempt is made to upload a file that is too large
# POST /consumer/data/next
# Parameters
- Next Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"date": "string",
"prefixes": [
"string"
],
"offset": 0,
"id_name_field": "string",
"ids": [
"string"
],
"metric_name_field": [
"string"
],
"fields": [
"string"
],
"entity": "string"
}
# Resposes
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 413: occurs when an attempt is made to upload a file that is too large
# POST /consumer/data/select
# Parameters
- Select Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"end_date": "string",
"prefixes": [
"string"
],
"id_name_field": "string",
"ids": [
"string"
],
"metric_name_field": [
"string"
],
"fields": [
"string"
],
"entity": "string",
"start_date": "string"
}
# Resposes
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 413: occurs when an attempt is made to upload a file that is too large
# POST /consumer/data/snap
# Parameters
- Snap Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"end_date": "string",
"prefixes": [
"string"
],
"granularity": "string",
"id_name_field": "string",
"ids": [
"string"
],
"metric_name_field": [
"string"
],
"entity": "string",
"start_date": "string"
}
# Resposes
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 413: occurs when an attempt is made to upload a file that is too large
# POST /consumer/data/sql-query
This method is used to execute a query using SQL Syntax. There's only one parameter in the request body:
- sql_query: The SQL query to execute.
# Request Example
{
"sql_query": "SELECT * from "table_name" limit 5",
}
# Parameters
- Sql Query Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"sql_query": "string"
}
# Resposes
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 413: occurs when an attempt is made to upload a file that is too large
# POST /consumer/metadata
This API returns the metadata fields structure and the entity types. The body of this request must include a entities field specifying the metadata entities to be returned. If empty, all metadata entities will be returned.
# Request Example
{ "entities": ["dm-config-sensors-man-v5"] }
# Parameters
- Metadata Description List Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"entities": [
"string"
]
}
# Resposes
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
# GET /consumer/metadata/{table}
This API allow users to obtain the list of metadata for a metadata entity. The API can be invoked in two different ways:
- List the metadata entity: GET /consumer/metadata/{metadata-ingest-alias}
- Filter by ID (It's only allowed operate over the index field, which was informed when the ingest was created): GET /consumer/metadata/{metadata-ingest-alias}?<index_field>[filter]=value where [filter] must be one of the following:
- [bw]: (Begins With) Metadata whose ID starts with the specified value
- [gt] (Greather Than): Metadata whose ID is higher than the specified value
- [gte] (Greather Than or equal): Metadata whose ID is higher or equals to the specified value
- [lt] (Less Than): Metadata whose ID is lower than the specified value
- [lte] (Less Than or equal): Metadata whose ID is lower or equals than the specified value
- [be] (Between): Metadata whose ID is higher or equals to the lower value and lower or equals to the higher value.
NOTE: When the response field NextToken contains data, the API needs to paginate. To continue obtaining data is necesary to call the API again including the query param NextToken=obtained_NextToken.
# Parameters
- Table: This field is required and its must be String. In this field you must put the table you want to apply in the API
# Resposes
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 404: The resource is not available on the server
# POST /consumer/metadata/{table}
This API returns the attributes of one or more metadata fields from a metada ingest. The body of the request must include a itemsId field with the list IDs of the metadata fields to be returned.
# Request Example
{
"itemsId": ["01BPM.C1A105.VALIDACION", "01ILB.B31067.W1000"]
}
# Parameters
- Table: This field is required and its must be String. In this field you must put the table you want to apply in the API
- Metadata Item By Id Request Model: This field is required and must be written in json format. An example of code that can be executed in this section is:
{
"itemsId": [
"string"
]
}
# Resposes
- 200: Means that the page has loaded correctly.
- 400: Incorrect request or request
- 404: The resource is not available on the server