Getting Started with TM1py
TM1py is a Python library for interacting with IBM Planning Analytics / TM1 via the REST API.
Requirements
- Python (3.7 or higher)
- TM1/Planning Analytics (v11 or higher)
Optional Python Packages
To fully unlock TM1py's potential, these two packages are optional.
- pandas
- networkx
Installation
TM1py only
Or TM1py with pandas dataframe support
Connect and print version
TM1 11 on-premise
from TM1py.Services import TM1Service
with TM1Service(address='localhost', port=8001, user='admin', password='apple', ssl=True) as tm1:
print(tm1.server.get_product_version())
TM1 11 on IBM cloud
with TM1Service(
base_url='https://mycompany.planning-analytics.ibmcloud.com/tm1/api/tm1/',
user="non_interactive_user",
namespace="LDAP",
password="U3lSn5QLwoQZY2",
ssl=True,
verify=True,
async_requests_mode=True) as tm1:
print(tm1.server.get_product_version())
TM1 12 PAaaS
from TM1py import TM1Service
params = {
"base_url": "https://us-east-1.planninganalytics.saas.ibm.com/api/<TenantId>/v0/tm1/<DatabaseName>/",
"user": "apikey",
"password": "<TheActualApiKey>",
"async_requests_mode": True,
"ssl": True,
"verify": True
}
with TM1Service(**params) as tm1:
print(tm1.server.get_product_version())
TM1 12 on-premise & Cloud Pak For Data
with TM1Service(
address="tm1-ibm-operands-services.apps.cluster.your-cluster.company.com",
instance="your instance name",
database="your database name",
application_client_id="client id",
application_client_secret="client secret",
user="admin",
ssl=True) as tm1:
print(tm1.server.get_product_version())