Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c7b7702
Bump version: 0.0.62 → 0.0.63
Jan 13, 2026
2e3f465
Enhance API key management and CSV input handling
phate999 Jan 13, 2026
9a05352
Restructured repo to consolidate excessive folders
phate999 Jan 13, 2026
0cd5c85
Organized folders
phate999 Jan 13, 2026
313200d
Organized repo and added readme.md
phate999 Jan 13, 2026
f648790
Update README.md
phate999 Jan 13, 2026
9f3c911
Reorder features in README for clarity
phate999 Jan 13, 2026
c780305
Organized repo
phate999 Jan 13, 2026
75308c9
Merge branch 'master' of https://github.com/phate999/api-samples
phate999 Jan 13, 2026
f2db759
Organized repo
phate999 Jan 13, 2026
7163fe2
Update link to CSV Script Manager in README
phate999 Jan 13, 2026
181adde
Clean up README by removing outdated sections
phate999 Jan 13, 2026
ba8873b
Remove router_grid.csv reference from last_file.txt
phate999 Jan 13, 2026
77531f1
Add files via upload
phate999 Jan 14, 2026
cde6f08
readme
phate999 Jan 15, 2026
6fba24b
Update README.md
phate999 Jan 15, 2026
018a50c
Remove usage instructions from README
phate999 Jan 15, 2026
0f2deef
Revise README with usage and web interface details
phate999 Jan 15, 2026
e5b4a99
Enhance README with sample scripts and CSV manager info
phate999 Jan 15, 2026
8818f41
Improve README links for scripts and CSV Script Manager
phate999 Jan 15, 2026
7a20433
Update README.md
phate999 Jan 15, 2026
af5e853
Update README.md
phate999 Jan 15, 2026
b70aa0f
added docsctring descriptions to scripts UI
phate999 Jan 22, 2026
5744f4b
Delete scripts/csv_script_manager/README.md
phate999 Jan 22, 2026
b5e9062
fooMerge branch 'master' of https://github.com/phate999/api-samples
phate999 Jan 22, 2026
d27d751
Merge branch 'master' of https://github.com/phate999/api-samples
phate999 Jan 22, 2026
c53ec57
Create readme.md
phate999 Jan 22, 2026
0295c8e
Update readme.md
phate999 Jan 22, 2026
fef9def
Add instruction display feature to CSV script manager
phate999 Jan 22, 2026
3621567
Update README.md
phate999 Jan 23, 2026
ed515f2
Merge branch 'cradlepoint:master' into master
phate999 Jan 23, 2026
436a659
Bump version: 0.0.63 → 0.0.64
Jan 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15,961 changes: 15,961 additions & 0 deletions Ericsson NCM API Postman Collection.json

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions NCM_Config_Backup/README.md

This file was deleted.

240 changes: 212 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,229 @@
# api-samples
Sample code using the NetCloud Manager API for key use cases
# API Samples

# How To Try
A collection of Python scripts for interacting with Ericsson NetCloud Manager APIs.

## Setup a python virtual environment
## Getting Started

python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
### Prerequisites

## Setup your keys in your environment
- Python 3.7 or higher
- Git (optional, for cloning the repository)

You need to create API keys in NCM to use these scripts so they can
access your NCM account. To make them available to the script, set
them in the environment, for example:
### Download and Extract the Repository

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
**Using Git (Recommended):**
```bash
git clone <repository-url>
cd api-samples
```

(These are not valid keys, get your own from the NCM site!)
**Downloading as ZIP:**
1. Download the repository as a ZIP file
2. Extract the ZIP file to your desired location
3. Navigate to the extracted `api-samples` folder

## Running the examples
```bash
cd path/to/extracted/api-samples
```

Remember to enter your virtual environment again if you are in a new terminal
and to export your keys (see above).
## Setup

. .venv/bin/activate
### 1. Create a Python Virtual Environment

Enter the `examples` directory:
Creating a virtual environment isolates project dependencies from your system Python installation.

cd examples
**Windows:**
```cmd
python -m venv .venv
.venv\Scripts\activate
```

Run the example scripts. They will provide usage information if you use the
--help option. For instance:
**macOS (zsh):**
```bash
python3 -m venv .venv
source .venv/bin/activate
```

./location_tracking.py --help
After activation, you should see `(.venv)` at the beginning of your command prompt, indicating the virtual environment is active.

Specific examples are described below.
### 2. Install Dependencies

### Getting GPS data for a router for the last day
With your virtual environment activated, install the required packages:

### Getting GPS data for all routers in your account for the last day
```bash
pip install -r requirements.txt
```

This will install all required dependencies including:
- `ncm` - Ericsson NetCloud Manager Python library
- `flask` - Web framework (for CSV Script Manager)
- `werkzeug` - WSGI utilities
- `python-dateutil` - Date parsing utilities

### 3. Set API Keys as Environment Variables

You need to set your NCM API credentials as environment variables. The scripts will automatically use these when running.

**Windows:**
```cmd
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_token
```

To make these persistent in Windows, go to System Properties > Environment Variables and add them there.

**macOS (zsh):**
```bash
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`:
```bash
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 ~/.zshrc
```

## Sample Scripts

This 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](scripts/) folder to explore all available sample scripts.

### Running Scripts

Make sure your virtual environment is activated before running scripts.

**Windows:**
```cmd
python script_name.py
```

**macOS:**
```bash
python3 script_name.py
```

Many scripts accept command-line arguments. Check the script's docstring or run it with `--help` (if supported) for usage information.

## CSV Script Manager

For a convenient web-based interface to manage CSV files, API keys, and run scripts, check out the CSV Script Manager.
> Want just the CSV Script Manager? [Get it here!](https://github.com/phate999/csv_script_manager)

The CSV 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

### Using CSV Script Manager

1. Navigate to the CSV Script Manager directory:
```bash
cd scripts/csv_script_manager
```

2. Make sure your virtual environment is activated

3. Start the web server:

**Windows:**
```cmd
python csv_script_manager.py
```

**macOS:**
```bash
python3 csv_script_manager.py
```

4. Open your browser to `http://localhost:8000`

5. Use the web interface to:
- Load and edit CSV files
- Set API keys (stored in session)
- Select and run scripts
- View script documentation

### Available Scripts in CSV Script Manager

The CSV Script Manager includes several pre-configured scripts:

- **ncm_bulk_configure_devices.py** - Bulk configure multiple devices with custom configurations
- **ncm_v3_create_users.py** - Create and manage users in NCM API v3
- **ncm_v3_regrade_subscriptions_by_mac.py** - Apply or regrade device subscriptions by MAC address
- **ncm_v3_unlicense_devices_by_mac.py** - Unlicense devices by MAC address
- **ncm_get_router_status.py** - Get router status and information using identifiers
- **ncm_unregister_routers_batch.py** - Unregister routers in batches with logging

Each script includes detailed documentation in its docstring explaining the required CSV format and usage.

## Postman Collection

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.

### Importing the Collection

1. Open Postman
2. Click **Import** in the top left corner
3. Select **File** or **Upload Files**
4. Navigate to and select the `Ericsson NCM API Postman Collection.json` file from this repository
5. Click **Import**

The collection will now appear in your Postman workspace. You can use it to explore and test the various API endpoints.

## Troubleshooting

### Virtual Environment Issues

**Problem:** `python` or `python3` command not found
- **Windows:** Make sure Python is installed and added to PATH
- **macOS:** Use `python3` explicitly, or install Python via Homebrew

**Problem:** Virtual environment activation fails
- Make sure you're in the correct directory when creating the virtual environment

### API Key Issues

**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 CSV Script Manager, use the API Keys tab in the web interface

### Import Errors

**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

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

See the [LICENSE](LICENSE) file for details.
78 changes: 0 additions & 78 deletions bulk_config/README.md

This file was deleted.

1 change: 0 additions & 1 deletion bulk_config/requirements.txt

This file was deleted.

32 changes: 0 additions & 32 deletions historical_locations_export/readme.md

This file was deleted.

9 changes: 0 additions & 9 deletions monitoring/README.md

This file was deleted.

Loading