50+ ready-to-use samples, just download the folder from GitHub and try them out.

Using the TM1py Samples is the best way to get started with TM1py. With these samples you will learn for example how to:

Examples

Reschedule all chores on one instance by - 1 hour:

with TM1Service(address='localhost', port=8001, user='admin', password='apple', ssl=True) as tm1:
    for chore in tm1.chores.get_all():
        chore.reschedule(hours=-1)
        tm1.chores.update(chore)

Find unused dimensions

from TM1py.Services import TM1Service

# Connect to TM1
with TM1Service(address='localhost', port=8001, user='admin', password='apple', ssl=True) as tm1:
    # get all dimensions
    all_dimensions = tm1.dimensions.get_all_names()
    # get all cubes
    all_cubes = tm1.cubes.get_all()
    # find used dimensions
    used_dimensions = set()
    for cube in all_cubes:
        used_dimensions.update(cube.dimensions)
    # determine unused dimensions
    unused_dimensions = set(all_dimensions) - used_dimensions

    print(unused_dimensions)

Generate a TM1 MDX Query from cube view

from TM1py.Services import TM1Service


# Establish connection to TM1 Server
with TM1Service(address='localhost', port=8001, user='admin', password='apple', ssl=True) as tm1:

    # Instantiate TM1py.NativeView object
    nv = tm1.views.get_native_view('Plan_BudgetPlan', 'High Level Profit And Loss', private=False)

    # Retrieve MDX from native view. Print it
    print(nv.MDX)