Tectra API

Coming in the next release

Drive Tectra from your own tools, the way Revit and Rhino can be scripted. The API runs on your own computer, is off by default, and only answers calls that carry one of your company's keys.

Overview

Core API

One object model for projects, models, elements, tasks, links, calendars, resources, costs, simulation, viewer, clashes and video.

Plugins

Add buttons, panels, rules, importers and reports inside Tectra. Each plugin declares its permissions.

Local REST API

REST and live events on 127.0.0.1, with client libraries for Python and .NET first, then JavaScript.

Turn on the API

  1. Open Tectra and go to View › Extensions.

  2. Switch on Local API. Tectra starts listening on http://127.0.0.1:47100/v1. Nothing is reachable from other computers.

  3. Leave Tectra open while your scripts run.

Keys and scopes

Create a key in View › Extensions › API keys. The key is shown once, so store it in your password manager or an environment variable such as TECTRA_KEY. Each key belongs to one company database.

ScopeAllows
readRead projects, tasks, links, costs and KPIs
writeChange tasks and links, import schedules, run auto-link
renderScreenshots and video export
adminManage keys and plugins

Send the key in the Authorization header on every call. Remove a key at any time and every script using it stops working at once.

Python quick start

  1. Install the client library.

    pip install tectra
  2. Connect. The client reads the key from the environment.

    import os
    from tectra import Client
    
    t = Client(api_key=os.environ["TECTRA_KEY"])
    for p in t.projects.list():
        print(p.id, p.name)
  3. Read tasks.

    project = t.projects.get("Tower A")
    late = [x for x in project.tasks.list() if x.finish_variance_days > 0]
    print(len(late), "activities are late")

Guide: update progress every Monday

A complete script that imports the weekly P6 update, reads earned value and renders a video for the client.

  1. Import this week's update. Links to the model are kept.

    project.schedule.import_file("updates/week-12.xer")
  2. Link anything new with your saved template.

    result = project.autolink(template="Concrete frame", min_score=0.8)
    print(result.linked, "new links,", result.to_review, "to review")
  3. Read earned value at the data date.

    kpi = project.evm(date=project.data_date)
    print(f"SPI {kpi.spi:.2f}  CPI {kpi.cpi:.2f}  EAC {kpi.eac:,.0f}")
  4. Render the progress video.

    project.renders.video(path="orbit", quality="1080p", out="week-12.mp4")
  5. Run it every week with Windows Task Scheduler or cron on macOS.

REST reference

The same calls from any language. All paths start with http://127.0.0.1:47100.

MethodPathWhat it does
GET/v1/projectsList the projects in the open company
GET/v1/projects/{id}/tasksActivities with dates, progress and links
PATCH/v1/projects/{id}/tasks/{taskId}Update dates or progress
POST/v1/projects/{id}/linksLink elements by IFC GlobalId
POST/v1/projects/{id}/schedule:importImport an XER, XML or CSV update
POST/v1/projects/{id}/autolinkRun auto-link with a template
GET/v1/projects/{id}/evm?date=Earned value and KPIs at a date
POST/v1/projects/{id}/rendersRender a screenshot or MP4
curl -H "Authorization: Bearer $TECTRA_KEY" http://127.0.0.1:47100/v1/projects

Live events

Open a WebSocket to /v1/events to hear when a task changes, the date changes in the viewer, or a render finishes.

for event in t.events.stream(["task.changed", "render.finished"]):
    print(event.type, event.data)

Plugins

A plugin is a folder with a tectra-plugin.json manifest and your code. It can add a ribbon button, a side panel, auto-link rules, an importer or a report. Tectra shows the permissions a plugin asks for when you install it.

{
  "name": "Concrete pour report",
  "version": "1.0.0",
  "permissions": ["read", "render"],
  "ribbon": { "tab": "Output", "button": "Pour report", "run": "report.py" }
}

Release status

The API is being built now. Names and paths may still change before release. Download Tectra and tick "Email me when the API is released" to hear first.

Try Tectra on your next project

Free for Windows and macOS. Includes a demo building with its schedule.

Download Tectra