A lightweight Python client for interacting with Sonatype Nexus3 repositories via REST API.
This package helps you search, list, and delete components from Nexus3 repositories with minimal code.
- 🔍 Search for components in Nexus3 repositories
- 🗑️ Delete components easily
- 🧩 Supports authentication for secure Nexus3 servers
- ⚡ Built for automation and CI/CD integration
- ✅ Fully tested with pytest
Install the package from PyPI:
pip install nexus3clientOr install from source:
git clone https://github.com/<your-username>/nexus3client.git
cd nexus3client
pip install -e .from nexus3client import Nexus3Client
# Initialize the client
client = Nexus3Client()results = client.search_components(
base_url="http://localhost:8084",
repository="test-repo",
username="admin",
password="admin123",
verify_ssl=False,
timeout=10,
*fields=["id", "repository"]
)
print(results)Example Output:
[
{
"id": "d2a3f2b6f3f2",
"repository": "test-repo",
"name": "my-artifact",
"version": "1.0.0"
}
]results = client.search_components(
"http://localhost:8084",
"test-repo",
"admin",
"admin123",
False,
10,
"id"
)
for result in results:
component_id = result.get("id")
client.delete_components(
"http://localhost:8084",
component_id,
"admin",
"admin123",
False,
10
)We use pytest for testing. To run tests locally:
pytest tests/Example Test (tests/test_nexus3client.py):
import pytest
from nexus3client import Nexus3Client
client = Nexus3Client()
def test_nexus3_search():
results = client.search_components(
"http://localhost:8084",
"test-repo",
"admin",
"admin123",
False,
10,
"id",
"repository"
)
assert isinstance(results, list)
assert len(results) >= 0
def test_nexus3_delete():
results = client.search_components(
"http://localhost:8084",
"test-repo",
"admin",
"admin123",
False,
10,
"id"
)
assert isinstance(results, list)
assert len(results) > 0
for result in results:
component_id = result.get("id")
assert component_id is not None
client.delete_components(
"http://localhost:8084",
component_id,
"admin",
"admin123",
False,
10
)nexus3client/
├── nexus3client/
│ ├── __init__.py
│ ├── client.py
├── tests/
│ ├── test_nexus3client.py
├── README.md
├── setup.py
├── pyproject.toml
└── LICENSE
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions, issues, and feature requests are welcome!
Feel free to open an issue or submit a pull request.
Author: Prabhu Thangaraj
Email: thangaraj.prabhu@gmail.com
GitHub: https://github.com/thangap-cloud