SonarQube SDK
A fully-typed Python SDK for the SonarQube API.
Features
- Full API Coverage: Support for all 30+ SonarQube API domains
- Type Safety: Complete type hints with Pydantic models
- Authentication: Support for both token and basic authentication
- Async Support: Built on httpx for modern async/sync HTTP handling
- Python 3.9+: Compatible with Python 3.9 through 3.13
Installation
pip install sonarqube-sdk
Or with uv:
uv add sonarqube-sdk
Quick Start
from sonarqube import SonarQubeClient
# Initialize client with token authentication
client = SonarQubeClient(
base_url="https://sonarqube.example.com",
token="your-token"
)
# Or with basic authentication
client = SonarQubeClient(
base_url="https://sonarqube.example.com",
username="admin",
password="admin"
)
# Create an application
app = client.applications.create(
name="My Application",
key="my-app",
visibility="private"
)
# Add a project to the application
client.applications.add_project(
application="my-app",
project="my-project"
)
# Search for projects
projects = client.projects.search(q="backend")
for project in projects.components:
print(f"Project: {project.name} ({project.key})")
# Get issues
issues = client.issues.search(
project_keys=["my-project"],
severities=["CRITICAL", "BLOCKER"]
)
for issue in issues.issues:
print(f"Issue: {issue.message}")
API Domains
The SDK provides access to all SonarQube API domains through a namespace pattern:
| Domain | Description |
|---|---|
client.applications |
Manage applications |
client.projects |
Manage projects |
client.issues |
Manage issues |
client.rules |
Manage rules |
client.qualitygates |
Manage quality gates |
client.qualityprofiles |
Manage quality profiles |
client.users |
Manage users |
client.user_tokens |
Manage user tokens |
client.permissions |
Manage permissions |
client.settings |
Manage settings |
| ... | And 20+ more domains |
Documentation
Full documentation is available at https://sonarqube-sdk.readthedocs.io
Development
Setup
# Clone the repository
git clone https://github.com/silasvasconcelos/sonarqube-sdk.git
cd sonarqube-sdk
# Install development dependencies
make dev
Common Commands
make help # Show all available commands
make test # Run tests
make test-cov # Run tests with coverage
make lint # Run linter
make format # Format code
make type # Run type checker
make security # Run security checks
make check # Run all checks
make tox # Run tests on all Python versions
make docs # Build documentation
make build # Build package
Testing
# Run all tests
make test
# Run tests with coverage
make test-cov
# Run tests on all Python versions
make tox
# Run specific Python version
make tox-py312
Contributing
Contributions are welcome! Please read our Contributing Guide for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
See CHANGELOG.md for a history of changes.
Metadata
Release files for sonarqube-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sonarqube_sdk-0.1.0.tar.gz | 42.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sonarqube_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 106.6 kB
Release files / sonarqube_sdk-0.1.0.tar.gz
| Download URL | sonarqube_sdk-0.1.0.tar.gz |
|---|---|
| Size | 42.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
01f815b4a60c1750610dcd2ce510b282d82c558209c314cdc19821ac8df92f98
|
|
BLAKE2b-256 checksum How to use checksums |
9c2ed6e600d71b37feba14e5b353bb21a3b0a6cf940ed0a2b37f3d5971a415c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.12
|
Release files / sonarqube_sdk-0.1.0-py3-none-any.whl
| Download URL | sonarqube_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 64.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68638af43b07f7d9641ee3fa6a2d0f75cac818d3de37786505e0aa6f89332345
|
|
BLAKE2b-256 checksum How to use checksums |
5fad83a749def047bcdae4e4e5148cc8e22e3d2a375c7db2e943766d0361415a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.12
|