A collection of Python scripts for interacting with Ericsson NetCloud Manager APIs.
- Python 3.7 or higher — Windows users, see the Windows Python Setup Guide if
pythonisn't working in your terminal - Git (optional, for cloning the repository)
Using Git (Recommended):
git clone <repository-url>
cd api-samplesDownloading as ZIP:
- Download the repository as a ZIP file
- Extract the ZIP file to your desired location
- Navigate to the extracted
api-samplesfolder
cd path/to/extracted/api-samplesCreating a virtual environment isolates project dependencies from your system Python installation.
Windows:
python -m venv .venv
.venv\Scripts\activatemacOS (zsh):
python3 -m venv .venv
source .venv/bin/activateAfter activation, you should see (.venv) at the beginning of your command prompt, indicating the virtual environment is active.
With your virtual environment activated, install the required packages:
pip install -r requirements.txtThis will install all required dependencies including:
ncm- Ericsson NetCloud Manager Python libraryflask- Web framework (for Script Manager)werkzeug- WSGI utilitiespython-dateutil- Date parsing utilities
You need to set your NCM API credentials as environment variables. The scripts will automatically use these when running.
Windows:
set X_CP_API_ID=your_api_id
set X_CP_API_KEY=your_api_key
set X_ECM_API_ID=your_ecm_api_id
set X_ECM_API_KEY=your_ecm_api_key
set TOKEN=your_ncm_api_v3_tokenTo make these persistent in Windows, go to System Properties > Environment Variables and add them there.
macOS (zsh):
export X_CP_API_ID="your_api_id"
export X_CP_API_KEY="your_api_key"
export X_ECM_API_ID="your_ecm_api_id"
export X_ECM_API_KEY="your_ecm_api_key"
export TOKEN="your_ncm_api_v3_token"To make these persistent, add them to your ~/.zshrc:
echo 'export X_CP_API_ID="your_api_id"' >> ~/.zshrc
echo 'export X_CP_API_KEY="your_api_key"' >> ~/.zshrc
echo 'export X_ECM_API_ID="your_ecm_api_id"' >> ~/.zshrc
echo 'export X_ECM_API_KEY="your_ecm_api_key"' >> ~/.zshrc
echo 'export TOKEN="your_ncm_api_v3_token"' >> ~/.zshrc
source ~/.zshrcThis repository contains many sample scripts in the scripts/ folder that demonstrate various API interactions and use cases. These scripts cover a wide range of functionality including:
- Router management and configuration
- Alert creation and management
- User management
- Location tracking and historical data export
- Device metrics and signal samples
- Configuration backups and restoration
- Subscription management
- Device licensing operations
- And much more
Browse the scripts folder to explore all available sample scripts.
Make sure your virtual environment is activated before running scripts.
Windows:
python script_name.pymacOS:
python3 script_name.pyMany scripts accept command-line arguments. Check the script's docstring or run it with --help (if supported) for usage information.
For a convenient web-based interface to manage CSV files, API keys, and run scripts, check out the Script Manager.
The Script Manager provides:
- Web-based CSV file editor
- API key management interface
- Script execution interface
- Easy script management and organization
- Displays script instructions from docstrings
-
Navigate to the Script Manager directory:
cd scripts/script_manager -
Make sure your virtual environment is activated
-
Start the web server:
Windows:
python script_manager.py
macOS:
python3 script_manager.py
-
Open your browser to
http://localhost:8000 -
Use the web interface to:
- Load and edit CSV files
- Set API keys (stored in session)
- Select and run scripts
- View script documentation
The Script Manager includes several pre-configured scripts:
- Configure Devices.py - Bulk configure multiple devices with custom configurations
- Create NCX Resources.py - Create NCX resources from CSV data
- Create NCX Sites.py - Create NCX sites from CSV data
- Create Users.py - Create and manage users in NCM API v3
- Get Router Status.py - Get router status and information using identifiers
- Set Router Fields.py - Update router fields (name, description, asset_id, custom1, custom2)
- Unlicense Devices.py - Unlicense devices
- Unregister Routers.py - Unregister routers in batches with logging
- Update Subscriptions.py - Apply or regrade device subscriptions
Each script includes detailed documentation in its docstring explaining the required CSV format and usage.
For a convenient way to test and explore the Ericsson NetCloud Manager APIs, you can use the Ericsson NCM API Postman Collection. This collection contains pre-configured API requests that you can use to interact with the APIs directly from Postman.
If you only need the Postman collection file without cloning the entire repository:
- Navigate to the file on GitHub:
Ericsson NCM API Postman Collection.json - Click the Download button (or Download raw file icon) in the top right
- Save the file to your computer
- Open Postman
- Click Import in the top left corner
- Select File or Upload Files
- Navigate to and select the
Ericsson NCM API Postman Collection.jsonfile - Click Import
The collection will now appear in your Postman workspace. You can use it to explore and test the various API endpoints.
Problem: python or python3 command not found
- Windows: Make sure Python is installed and added to PATH
- macOS: Use
python3explicitly, or install Python via Homebrew
Problem: Virtual environment activation fails
- Make sure you're in the correct directory when creating the virtual environment
Problem: python isn't recognized, or typing python opens the Microsoft Store
- Follow the Windows Python Setup Guide for step-by-step instructions on installing Python correctly and configuring your PATH on Windows 11.
Problem: Scripts report missing API keys
- Verify environment variables are set correctly
- Make sure your virtual environment is activated
- Check that variable names match exactly (case-sensitive on macOS)
- For Script Manager, use the API Keys tab in the web interface
Problem: ModuleNotFoundError when running scripts
- Make sure your virtual environment is activated
- Verify dependencies are installed:
pip install -r requirements.txt - Some scripts may require additional dependencies - check the script's docstring
Contributions are welcome! Please feel free to submit a Pull Request.
See the LICENSE file for details.