Skip to main content

Python driver for the TCAnnex CPRT API

Project description

tcannex

A Python driver for the TCAnnex CPRT (Cybersecurity and Privacy Reference Tool) API.

Installation

pip install tcannex

Quick Start

Set your API key as an environment variable:

export TCANNEX_API_KEY="your-api-key"

Use the client:

from tcannex import TCAnnexClient

with TCAnnexClient() as client:
    # List all documents
    response = client.get_documents()
    for doc in response.documents:
        print(f"{doc.name} (v{doc.version})")

    # Get a specific document with its elements and relationships
    response = client.get_document("NIST_CSF_2.0")
    for element in response.elements:
        print(f"  {element.element_identifier}: {element.title}")

    # Get a specific element
    response = client.get_element("NIST_CSF_2.0", "GV")
    print(response.elements[0].text)

You can also pass the API key directly:

client = TCAnnexClient(api_key="your-api-key")

API Reference

Client

TCAnnexClient(api_key=None, base_url="https://api.tcannex.com")

Method Description
get_root() Read API root
get_documents() List all documents
get_document(document_identifier) Get a document with its elements, relationships, and relationship types
get_element(document_identifier, element_identifier) Get an element with its document, relationships, and relationship types
close() Close the HTTP client

All methods return a CPRTResponse.

Models

  • CPRTResponsedocuments, elements, relationship_types, relationships
  • Documentdoc_identifier, name, version, website
  • Elementdoc_identifier, element_type, element_identifier, title, text
  • Relationshipsource_element_identifier, source_doc_identifier, dest_element_identifier, dest_doc_identifier, provenance_doc_identifier, relationship_identifier
  • RelationshipTyperelationship_identifier, description, value

Exceptions

  • TCAnnexError — Base exception
  • AuthenticationError — Missing or invalid API key
  • APIError — Non-2xx response (has status_code and body attributes)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tcannex-0.1.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tcannex-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file tcannex-0.1.1.tar.gz.

File metadata

  • Download URL: tcannex-0.1.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for tcannex-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b39d711d1dddf48cb6220721d8da39da9dbc58600a17cd8e87cba3ed78631d90
MD5 7b9704a781215120812ae8bb263dee48
BLAKE2b-256 e716d0189c9c1cd25340567afdd2ef9a359961e2ce6fae7260b0ac9aef6ffb09

See more details on using hashes here.

File details

Details for the file tcannex-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tcannex-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for tcannex-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e28b5729d83f3df4561665e8eee5414e135eac56b5e0055cdf4b808f4dc7d9a
MD5 b7eb4c0a4b910f3404fc4f86faf278a9
BLAKE2b-256 d170c129840c69ed6299c541782900e9820362822a37a049bb487bca6f8958e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page