Skip to main content

Python client library for Cradlepoint NCM API

Project description

NCM API Client Documentation

Overview

This module provides easy access to the Cradlepoint NCM API with support for both v2 and v3 APIs. It includes a singleton pattern for simple usage and module-level function access for convenience.

Installation

pip install -U ncm

Requirements

Cradlepoint NCM API Keys are required to make API calls:

  • For v2 API: X-CP-API-ID, X-CP-API-KEY, X-ECM-API-ID, X-ECM-API-KEY
  • For v3 API: Bearer token

Usage Options

1. Zero-Configuration Usage (Recommended)

import ncm

# Set these environment variables once:
# export X_CP_API_ID="b89a24a3"
# export X_CP_API_KEY="4b1d77fe271241b1cfafab993ef0891d"
# export X_ECM_API_ID="c71b3e68-33f5-4e69-9853-14989700f204"
# export X_ECM_API_KEY="f1ca6cd41f326c00e23322795c063068274caa30"
# export NCM_API_TOKEN="your-bearer-token"  # For v3 API

# Then just use it - no setup required!
accounts = ncm.get_accounts()
devices = ncm.get_devices()
routers = ncm.get_routers()

2. Explicit Configuration (Alternative)

import ncm

# Option A: Set up API keys explicitly
api_keys = {
   'X-CP-API-ID': 'b89a24a3',
   'X-CP-API-KEY': '4b1d77fe271241b1cfafab993ef0891d',
   'X-ECM-API-ID': 'c71b3e68-33f5-4e69-9853-14989700f204',
   'X-ECM-API-KEY': 'f1ca6cd41f326c00e23322795c063068274caa30'
}
ncm.set_api_keys(api_keys)

# Option B: Manual environment variable loading
ncm.set_api_keys()  # Manually loads from environment

3. Traditional Class Instantiation

import ncm
api_keys = {...}  # Same as above
client = ncm.NcmClient(api_keys=api_keys)
accounts = client.get_accounts()

4. Mixed v2/v3 API Usage

import ncm
api_keys = {
   'X-CP-API-ID': 'b89a24a3',
   'X-CP-API-KEY': '4b1d77fe271241b1cfafab993ef0891d',
   'X-ECM-API-ID': 'c71b3e68-33f5-4e69-9853-14989700f204',
   'X-ECM-API-KEY': 'f1ca6cd41f326c00e23322795c063068274caa30',
   'token': 'your-v3-bearer-token'  # For v3 API
}
client = ncm.NcmClient(api_keys=api_keys)
# Methods will automatically route to the appropriate API version

5. Backward Compatibility (Legacy Scripts)

from ncm import ncm  # Old import pattern still works!

api_keys = {
    'X-ECM-API-ID': os.environ.get("X_ECM_API_ID"),
    'X-ECM-API-KEY': os.environ.get("X_ECM_API_KEY"),
    'X-CP-API-ID': os.environ.get("X_CP_API_ID"),
    'X-CP-API-KEY': os.environ.get("X_CP_API_KEY"),
    'Authorization': f'Bearer {os.environ.get("TOKEN")}'
}

# All existing patterns work unchanged:
ncm_client = ncm.NcmClientv3(api_key=token, log_events=True)
ncm_client.set_api_keys(api_keys)  # Instance method still works

# New convenience pattern also available:
ncm.set_api_keys(api_keys)  # Module-level method
routers = ncm.get_routers()  # Direct method access

Features

  • ✅ Zero-configuration usage with automatic environment variable loading
  • ✅ Singleton pattern for easy module-level access
  • ✅ Automatic API version routing (v3 prioritized over v2)
  • ✅ Module-level function access (ncm.method_name())
  • ✅ Automatic initialization on import if environment variables are set
  • ✅ Full backward compatibility with existing scripts
  • ✅ Support for both import patterns: "import ncm" and "from ncm import ncm"
  • ✅ Optimized pagination (default limit 500 vs API default 20)
  • ✅ Support for limit='all' to get all records without paging
  • ✅ Automatic chunking of "__in" filters beyond 100 item limit

Documentation

Full documentation of the Cradlepoint NCM API is available at: https://developer.cradlepoint.com

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

ncm-0.0.68.tar.gz (34.6 kB view details)

Uploaded Source

Built Distribution

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

ncm-0.0.68-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

Details for the file ncm-0.0.68.tar.gz.

File metadata

  • Download URL: ncm-0.0.68.tar.gz
  • Upload date:
  • Size: 34.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for ncm-0.0.68.tar.gz
Algorithm Hash digest
SHA256 c60401bb0e3bd28fa6ce6d1570c4c7756f249a0e171fe23ba57e4a9c5dfb57c1
MD5 7f89a0b0d2bae49861ed350bae55d925
BLAKE2b-256 532d909ca03e8b38f606a11bbbe59073a09e62f257e76f92d9295d6ab5485b82

See more details on using hashes here.

File details

Details for the file ncm-0.0.68-py3-none-any.whl.

File metadata

  • Download URL: ncm-0.0.68-py3-none-any.whl
  • Upload date:
  • Size: 34.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for ncm-0.0.68-py3-none-any.whl
Algorithm Hash digest
SHA256 9a0896b81b41e14c81465ee1fd693cff39c8797aeb76f74bca5fe9a8b50fe40e
MD5 5005205bcbf61e204c8ea22795130eca
BLAKE2b-256 df433122977ecb875301a665e79dc4a7a03ac28ba7f8f9ff3427ef442a3eade0

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