Skip to main content

sysml-api-client

A Python client for the OMG Systems Modeling API and Services, specifically tested against the OpenMBEE Flexo implementation. The PyPI name is sysml-api-client; Python imports remain sysmlv2_client and sysml_api.

Installation

Requires Python 3.10 or newer. Once published on PyPI:

python -m pip install sysml-api-client
from sysmlv2_client import SysMLV2Client

See RELEASING.md for build validation and publisher setup.

Features

  • Provides methods for core SysML v2 operations:
    • Projects: Get List, Create, Get by ID
    • Commits: Create (handles element create/update/delete), Get by ID, List
    • Branches: List, Create, Get by ID, Delete
    • Tags: List, Create, Get by ID, Delete
    • Elements: Get by ID, List All in Commit, Get Owned by Element
    • Relationships: List for Element
  • Handles authentication using Bearer tokens.
  • Includes basic error handling and custom exceptions.

Setup

1. Run Flexo SysMLv2 Service Locally

Follow instructions here

2. Install Client (Development)

python -m pip install -e ".[test]"

Basic Usage

from sysmlv2_client import SysMLV2Client, SysMLV2Error
from pprint import pprint
import uuid # For element IDs

BASE_URL = "http://localhost:8083"
# Replace with the actual token from flexo-setup/docker-compose/env/flexo-sysmlv2.env
BEARER_TOKEN = "Bearer YOUR_TOKEN_HERE"

try:
    client = SysMLV2Client(base_url=BASE_URL, bearer_token=BEARER_TOKEN)
    print("Client initialized.")

    # Get projects
    print("\\n--- Getting Projects ---")
    projects = client.get_projects()
    print(f"Found {len(projects)} projects.")
    for project in projects:
        print(f"  - Name: {project.get('name', 'N/A')}, ID: {project.get('@id', 'N/A')}")

    # Create a project (example data)
    print("\\n--- Creating Project ---")
    new_proj_data = {"@type": "Project", "name": "Client README Example"}
    created_proj = client.create_project(new_proj_data)
    print(f"Created project:")
    pprint(created_proj)
    project_id = created_proj.get('@id')

    if project_id:
        # Create a commit that also creates an element
        print(f"\\n--- Creating Commit with Element in Project {project_id} ---")
        element_id = str(uuid.uuid4())
        commit_data = {
            "@type": "Commit",
            "description": "Add initial block",
            "change": [{
                "@type": "DataVersion",
                "payload": {
                    "@id": element_id,
                    "@type": "PartDefinition", # Example type
                    "name": "MyExamplePartDefinition"
                }
            }]
        }
        created_commit = client.create_commit(project_id, commit_data)
        print("Commit created:")
        pprint(created_commit)
        commit_id = created_commit.get('@id')

        if commit_id:
            # List elements in the new commit
            print(f"\\n--- Listing Elements in Commit {commit_id} ---")
            elements = client.list_elements(project_id, commit_id)
            print(f"Found {len(elements)} elements:")
            pprint(elements)

except SysMLV2Error as e:
    print(f"An API error occurred: {e}")
except ValueError as e:
    print(f"Initialization error: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

Running Tests

Unit tests are implemented using pytest and requests-mock.

  1. Install Dependencies:
    python -m pip install -e ".[test]"
    
  2. Run Tests: Navigate to the project root directory in your terminal and run:
    pytest
    

The OMG Beta 1 REST/HTTP conformance suite includes live provider tests, a Python client interoperability test, and traceability matrices.

For a Flexo gateway that requires X-SysMLv2-Svc-Token, pass the token through the svc_token keyword:

import os

from sysmlv2_client import SysMLV2Client

client = SysMLV2Client("http://127.0.0.1:62859", svc_token=os.environ["SYSML_SVC_TOKEN"])

If your deployment also requires Bearer authentication, supply bearer_token as well. Automatic redirects are disabled when a service token is configured.

API

Basic v2 API

  • get_projects
  • create_project
  • delete_project
  • get_project_by_id
  • get_element
  • get_owned_elements
  • create_commit
  • get_commit_by_id
  • list_commits
  • list_branches
  • create_branch
  • get_branch_by_id
  • list_tags
  • create_tag
  • get_tag_by_id
  • list_elements
  • list_relationships

Convenience functions

  • create_sysml_project
  • get_project_by_name
  • commit_to_project
  • get_last_commit_from_project
  • create_branch

Metadata

Release files for sysml-api-client 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sysml-api-client 0.1.1
File Size Uploaded Provenance Actions
sysml_api_client-0.1.1.tar.gz 18.5 kB With provenance Details for sysml_api_client-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sysml-api-client 0.1.1
File Interpreter ABI Platform Actions
sysml_api_client-0.1.1-py3-none-any.whl Python 3 none any Details for sysml_api_client-0.1.1-py3-none-any.whl

Total release size: 31.4 kB

Release files / sysml_api_client-0.1.1.tar.gz

Download URL sysml_api_client-0.1.1.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b7ec82afea3c99c66fab39a4a69c0642a5ccab6f274673a356c53832d9469298
BLAKE2b-256 checksum
How to use checksums
aa9a90057ed50df6aed5521fa3b42a3de78c8d902158bfca357ac6898c4d6085
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / sysml_api_client-0.1.1-py3-none-any.whl

Download URL sysml_api_client-0.1.1-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d8ff55989629e0685146d9a8c68b5fcc43b1f825ca7d64334f9a6074b7ab1f0
BLAKE2b-256 checksum
How to use checksums
623b431614b90147e3cafd7f18c8e33acd07db1f990c3418dd6d9fc93f80a565
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for sysml-api-client 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sysml_api_client-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page