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.0.tar.gz (5.4 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.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tcannex-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 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.0.tar.gz
Algorithm Hash digest
SHA256 4b3e5347b864b1e6492ce42f43579e76279ca99ce7fed3907c94f98c12b6b2b9
MD5 1ba26ca3f8772938d7d9312834cc6cb1
BLAKE2b-256 513357749ade9cadfe9c92552fd55bf6a53ef0b5d12e4a64690c93a9660d3761

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tcannex-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0adced1eeef69c3a956afb7939be5b688d2248b3a1313caa6e8dd945dcc2c984
MD5 b396198716193223fe58796830ec8c99
BLAKE2b-256 56eae79acb0c2aa4b691a889f0bcb9555a31051145ddfd18b1b741968b79e96e

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