The SysML v2 REST API is the official way to access SysML v2 models programmatically. It is standardised, well-specified, and responds to every request with raw JSON that at first feels like looking at Matrix code. Anyone who wants to use the API meaningfully needs an intermediate layer that translates this raw data into something manageable. That is exactly what you build with Python and Flask in surprisingly few lines.

What is the SysML v2 REST API?

SysML v2 is the new standard for model-based systems engineering (MBSE). Alongside the modelling language itself, the standard also defines a REST API through which SysML v2 repository servers make their data accessible. Every repository implementing this standard speaks the same API language, regardless of whether it is local or in the cloud. The API delivers projects, commits, and model elements as JSON. Projects are namespaces for models; commits are version states comparable to Git commits, but for system models.

Why a Flask server in between?

Flask is a lightweight Python web framework that turns HTTP endpoints into simple Python functions. The idea is simple: instead of calling the SysML v2 API directly from the browser (which often fails due to CORS problems and missing HTTPS support), you place a Python server in between. It accepts requests from the web interface, communicates with the SysML v2 API, and returns processed, sorted responses. This is called middleware — and it is so useful you will wonder why you did not do it sooner.

Step 1: Install and test Flask

Prerequisites: Python 3.8 or newer, a code editor, and a web browser. Nothing more. Flask is installed with a single command: pip install flask. Whether Flask is running can be checked immediately: create a Python file with a single route, run flask run, and visit 127.0.0.1:5000 in the browser. If "Hello World" appears, Flask is ready.

Step 2: Retrieve projects from the SysML v2 API

The first useful endpoint of the SysML v2 API is GET /projects. It returns a list of all projects on the server. In the Flask server, this call is encapsulated in its own Python function: the function constructs the URL, sends a GET request with requests.Session() (more efficient than opening a new TCP connection each time), checks the HTTP status code, parses the JSON, and sorts the projects alphabetically. The result is sent back to the webpage by Flask as a JSON response, where it ends up in a dropdown menu.

Step 3: Retrieve commits for a project

Each project has a unique ID. With this ID, the second core endpoint can be called: GET /projects/{id}/commits. Commits are version states of the model — every saved change creates a new commit with its own ID. These commit IDs are the key to everything else: model elements, packages, requirements — all of this can be retrieved via the commit ID. The Flask implementation follows the same pattern as for projects: build the URL, send the request, check the response, sort, return.

Clean structure: extracting logic

A proven practice: all communication logic with the SysML v2 API belongs in a separate helper file, not in the Flask server itself. This keeps the Flask server focused on its actual task — receiving HTTP requests and sending responses. The helper file handles the details. This makes the code easier to read and easier to extend when additional API endpoints are added in later steps.

Conclusion: Three ingredients, one usable result

Python, Flask, and a web browser are enough to make the SysML v2 REST API meaningfully usable. The architecture is simple, stable, and open for extension. The webpage calls the Flask server; the Flask server calls the SysML v2 API. Anyone who has built this foundation can implement any queries on top of it: reading model elements, extracting requirements, reading out SYSMOD structures. The API is standardised; the rest is imagination.

Have a topic you'd like us to write about? Let us know.