The Blog shows how to use TM1 Rest API to extract, filter, select only specific details/properties from the dimensions, all the metadata extracted from TM1 Rest API will be in JSON. If this is your first time on TM1 Rest API, then it is recommended to visit the link below which covers the introduction and helps with getting started on TM1 Rest API.
https://blog.octanesolutions.com.au/introduction-to-tm1-rest-api
Here, we will be using Go_New_Store TM1 Sample Instance in windows environment and Chrome Browser with JSONView Extension
https://<AdminHost>:<PortNumber>/api/v1/
AdminHost: The Server name where the Admin Server is Setup, here localhost will be used.
PortNumber: Http Port number can be found in the Config file for TM1 server.
Above URL is also referred to as the Service Root URL for TM1 Rest API. Now, let's get started by seeing the URL used to get all dimensions and their properties and also, the URL used to get only the specific dimension and its properties
- https://localhost:5010/api/v1/Dimensions
- https://localhost:5010/api/v1/Dimensions(‘Retailers’)
This URL can be used to get all the dimensions and their properties in that instance (here, Port 5010 is http port for “GO_New_Stores” Sample TM1 Instance)
Above URL is used to get properties for the selected dimension. In this case, the properties of the dimension “Retailers” are fetched.
Filter:
The Sections shows how the filter can be used on dimensions in detail
- https://localhost:5010/api/v1/Dimensions?$filter=indexof(Name,'}') eq 0
- https://localhost:5010/api/v1/Dimensions?$filter=not indexof(Name,'}') eq 0
- https://localhost:5010/api/v1/Dimensions?$filter=contains(Name,'}ElementAttributes')
- https://localhost:5010/api/v1/Dimensions?$filter=startswith(Name,'Re')
- https://localhost:5010/api/v1/Dimensions?$filter=endswith(Name,'on')
- https://localhost:5010/api/v1/Dimensions?$top=5
- https://localhost:5010/api/v1/Dimensions?skip=5
- https://localhost:5010/api/v1/Dimensions?$filter=lenth(Name) eq 4
- https://localhost:5010/api/v1/Dimensions?$filter=substring(Name,0,2) eq 'Re'
URL uses the filter to get only the control dimensions and their properties
URL gets all the dimensions and their properties excluding the control dimensions
The URL gets all the dimension containing '}ElementAttributes' as a part of the name string property
URL gets all the dimensions name starting with ‘Re’
URL gets all the dimensions name ending with ‘on’
URL gets only the top 5 dimensions from the derived entities
URL Skips the first 5 dimensions from the derived entities
URL gets all the dimensions whose name length equals 4
URL gets all dimensions whose substring matches with ‘Re’
Select:
The Function is used for selecting only the required properties from dimension details fetched.
- https://localhost:5010/api/v1/Dimensions?$filter=indexof(Name,'}') eq 0&$select=Name,Attributes/DIMENSION_TYPE
This URL can be used to get all control dimension and only the selected properties such has Name & Dimension type are shows
Expand:
This section shows how to navigate from dimensions to hierarchy from there to elements and also, how to use expand in the URL
- https://localhost:5010/api/v1/Dimensions('Retailers')/Hierarchies
- https://localhost:5010/api/v1/Dimensions?$expand=Hierarchies
- https://localhost:5010/api/v1/Dimensions('Retailers')/DefaultHierarchy
- https://localhost:5010/api/v1/Dimensions('Retailers')?$expand=DefaultHierarchy($expand=Elements($select=Name,UniqueName,Type,Attributes/Caption))
- https://localhost:5010/api/v1/Dimensions('Retailers')/DefaultHierarchy/Elements?$select=Name,UniqueName,Type,Attributes/Caption
URL shows how we can navigate from the dimension to hierarchies for getting hierarchies and it’s property details
The URL shows how to use expand to get both dimensions and their properties along with hierarchies and it’s properties
Above URL shows the default hierarchy and it’s properties for the selected dimensions
Above URL gets the dimension and its properties, default hierarchy and it’s property along with elements with their selected properties
Above URL show only the elements and their selected properties for the default hierarchy in dimension “Retailers”
Leave a comment