Page 1 of 1
Tm1 API Query
Posted: Mon Sep 27, 2021 12:25 am
by Neelutm1
Hi Team,
We are trying to import some data from a tm1 cube/View using API technology through Postman.
What is the best command /URL to extract data from a view, We need both row/column data including headers.
We have tried below URL but it is only giving measure values..
POST
https://localhost:8881/api/v1/Cubes('General Ledger')/Views('P&L')/tm1.Execute?$expand=Cells
Regards,
Neelima
Re: Tm1 API Query
Posted: Tue Sep 28, 2021 12:17 am
by Neelutm1
HI Team,
I have used below sample URL and it is lot better.
https://awsptm1pa:8086/api/v1/Cubes('Cu ... xpand=Axes($expand=Hierarchies($select=Name),Tuples($expand=Members($select=Name))),Cells
Regards,
Neelima
Re: Tm1 API Query
Posted: Wed Sep 29, 2021 1:26 pm
by MariusWirtz
Hi,
maybe checkout tm1py.
It's an open-source python package that makes it easy to build stuff with the TM1 REST API.
https://github.com/cubewise-code/tm1py
It provides functions to retrieve data from cube views or through MDX.
You can also retrieve data directly as a data frame. That is useful if you want to save it as XLSX or want to do advanced analytics with the data.
Code: Select all
from TM1py import TM1Service
with TM1Service(address="", port=12354, ssl=True, user="admin", password="apple") as tm1:
data_frame = tm1.cells.execute_view_dataframe(cube_name="Sales", view_name="Default", private=False)
print(data_frame)
|
State |
SalesMeasure |
Value |
0 |
AK |
Gross Margin |
1413042.040 |
1 |
AK |
Revenue |
1544055.000 |
2 |
AK |
COGS |
131012.960 |
3 |
AZ |
Gross Margin |
83001.740 |
4 |
AZ |
Revenue |
175440.240 |
5 |
AZ |
COGS |
92438.500 |
6 |
CA |
Gross Margin |
921247.800 |
7 |
CA |
Revenue |
2075148.000 |
8 |
CA |
COGS |
1153900.200 |
9 |
CO |
Gross Margin |
15677.264 |
10 |
CO |
Revenue |
28648.464 |