Skip to main content

Official Python SDK for BugBountyKE-KSP platform API

Project description

BugBountyKE-KSP Python SDK

Official Python SDK for the BugBountyKE-KSP Platform API.

PyPI License Tests

pip install bugbounty-ksp-api-client

Features

  • โœจ Official SDK with full type hints & docstrings
  • ๐Ÿ” Secure API key generation & validation
  • ๐Ÿ”‘ Authentication with API keys
  • ๐Ÿ“ค Article publishing & management
  • โšก Comprehensive error handling
  • ๐Ÿงช 100% test coverage (33 tests)
  • ๐Ÿ“š Full documentation & examples
  • ๐Ÿš€ Published on PyPI

Quick Start

1. Install the SDK

pip install bugbounty-ksp-api-client

2. Generate an API Key

from bugbounty_ksp.api import generate_api_key, APIKeyGenerator

# Generate a test API key
test_key = generate_api_key()  # Returns sk_test_*****
print(test_key)  # sk_test_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456

# Or generate multiple keys
keys = APIKeyGenerator.generate_batch(count=5, test=True)

# Validate a key
is_valid = APIKeyGenerator.is_valid_format(test_key)  # True

# Mask key for safe logging
masked = APIKeyGenerator.mask_key(test_key)  # sk_test_****...6

3. Create Client & Publish

from bugbounty_ksp import BugBountyKSPAPIClient
import os

# Initialize client with API key
api_key = os.environ.get('BUGBOUNTY_API_KEY', 'sk_test_your_key')
client = BugBountyKSPAPIClient(api_key=api_key)

# Publish an article
response = client.publish_article(
    title="Security Vulnerability Report",
    content="# Vulnerability Details\n\nDetails here...",
    frontmatter={
        "title": "Security Vulnerability Report",
        "tags": ["security", "bug-bounty"],
        "category": "web"
    },
    file_path="/path/to/article.md"
)

print(f"Published! View at: {response.web_url}")

Installation

From PyPI (Recommended)

Latest version: 1.0.0 PyPI

pip install bugbounty-ksp-api-client

From Source

git clone https://github.com/BugBounty-MockingBird/bugbounty-ksp-api-client.git
cd bugbounty-ksp-api-client
pip install -e .

Verify Installation

from bugbounty_ksp import BugBountyKSPAPIClient
from bugbounty_ksp.api import generate_api_key
print("SDK installed successfully!")

API Reference

Core Classes

BugBountyKSPAPIClient

Main client for interacting with the API.

client = BugBountyKSPAPIClient(
    api_key="sk_test_...",                  # Required: API key
    api_url="https://api.bugbounty-ksp.com", # Optional: Custom API URL
    verify_ssl=True,                         # Optional: SSL verification
    timeout=30                               # Optional: Request timeout
)

Methods:

  • publish_article(title, content, frontmatter, file_path) - Publish article
  • delete_article(article_id) - Delete article
  • _verify_authentication() - Check API key validity (called automatically)

APIKeyGenerator

Secure API key generation & validation.

from bugbounty_ksp.api.key_generator import APIKeyGenerator

# Generate single key
key = APIKeyGenerator.generate(test=True)  # sk_test_*
prod_key = APIKeyGenerator.generate(test=False)  # sk_*

# Generate batch
keys = APIKeyGenerator.generate_batch(count=5, test=True)

# Validate format
is_valid = APIKeyGenerator.is_valid_format(key)

# Mask for logging
masked = APIKeyGenerator.mask_key(key, visible_chars=4)

# Get info
info = APIKeyGenerator.get_key_info(key)
# Returns: {is_valid, length, masked, environment, type, prefix}

Convenience Functions:

from bugbounty_ksp.api import generate_api_key, generate_api_keys

# Generate test key
key = generate_api_key()  # sk_test_*

# Generate multiple test keys
keys = generate_api_keys(count=5)

Exception Classes

from bugbounty_ksp.api.exceptions import (
    APIError,                # Base exception
    AuthenticationError,     # Invalid/missing API key
    ValidationError,         # Invalid input
    RateLimitError,         # Too many requests
    NotFoundError,          # Resource not found
    NetworkError,           # Network/connection issues
)

Getting Your API Key

  1. Log in to https://bugbountyke-ksp.com
  2. Go to Settings โ†’ API Keys
  3. Click "Generate New Key"
  4. Copy the key immediately (shown only once)
  5. Store securely in environment variables
# .env or environment
export BUGBOUNTY_API_KEY="sk_test_your_key_here"

Error Handling

All API errors inherit from APIError and provide helpful messages.

from bugbounty_ksp import BugBountyKSPAPIClient
from bugbounty_ksp.api.exceptions import (
    ValidationError,
    AuthenticationError,
    NetworkError,
    RateLimitError,
)

client = BugBountyKSPAPIClient(api_key="sk_test_invalid")

try:
    response = client.publish_article(
        title="",  # Invalid: empty title
        content="Test"
    )
except ValidationError as e:
    print(f"Invalid input: {e}")
    # Handle validation errors

except AuthenticationError as e:
    print(f"Authentication failed: {e}")
    # Check API key

except RateLimitError as e:
    print(f"Rate limited: {e}")
    # Wait before retrying

except NetworkError as e:
    print(f"Network error: {e}")
    # Handle connection issues

Development

Setup Development Environment

# Clone repository
git clone https://github.com/BugBounty-MockingBird/bugbounty-ksp-api-client.git
cd bugbounty-ksp-api-client

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e ".[dev]"

Running Tests

# Run all tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=bugbounty_ksp --cov-report=html

# Run specific test class
pytest tests/test.py::TestAPIKeyGenerator -v

Code Quality

# Format code
black src/ tests/

# Lint
flake8 src/ tests/

# Type checking
mypy src/

Project Structure

bugbounty-ksp-api-client/
โ”œโ”€โ”€ src/bugbounty_ksp/
โ”‚   โ”œโ”€โ”€ __init__.py           # Package exports
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py       # API module exports
โ”‚   โ”‚   โ”œโ”€โ”€ client.py         # BugBountyKSPAPIClient class
โ”‚   โ”‚   โ”œโ”€โ”€ exceptions.py     # Custom exceptions
โ”‚   โ”‚   โ”œโ”€โ”€ key_generator.py  # APIKeyGenerator class
โ”‚   โ”‚   โ””โ”€โ”€ models.py         # Response models
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ””โ”€โ”€ validators.py     # Input validation
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ conftest.py          # Pytest fixtures
โ”‚   โ””โ”€โ”€ test.py              # 33 comprehensive tests
โ”œโ”€โ”€ docs/                    # Documentation
โ”œโ”€โ”€ setup.py                 # Package setup
โ”œโ”€โ”€ pyproject.toml          # Project config
โ””โ”€โ”€ README.md               # This file

Configuration

Environment Variables

# Required
export BUGBOUNTY_API_KEY="sk_test_your_key_here"

# Optional
export BUGBOUNTY_API_URL="https://api.bugbounty-ksp.com"  # Default
export BUGBOUNTY_VERIFY_SSL="true"  # Default
export BUGBOUNTY_TIMEOUT="30"  # Default (seconds)

Custom Configuration

client = BugBountyKSPAPIClient(
    api_key="sk_test_...",
    api_url="https://staging-api.bugbounty-ksp.com",  # Custom environment
    verify_ssl=False,  # Disable SSL for testing
    timeout=60  # Longer timeout for large uploads
)

Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Write tests for your changes
  4. Ensure all tests pass (pytest tests/)
  5. Follow code style (black, flake8, mypy)
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to your branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Code Quality Requirements:

  • โœ… All tests passing
  • โœ… Type hints on all functions
  • โœ… Docstrings on public methods
  • โœ… Code formatted with Black
  • โœ… No linting errors with Flake8
  • โœ… Type checking passes with MyPy

License

MIT License - see LICENSE

Support & Links

Changelog

v1.0.0 (February 5, 2026) - Initial Release

  • โœจ Official Python SDK release
  • ๐Ÿ” API key generation & validation
  • ๐Ÿ“ค Article publishing & management
  • โšก Comprehensive error handling
  • ๐Ÿงช 33 passing tests (100% coverage)
  • ๐Ÿ“ฆ Published to PyPI

Made with โค๏ธ by the BugBountyKE-KSP Team

Part of the BugBountyKE-KSP initiative to centralize cybersecurity knowledge and bridge hunters' expertise.

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

bugbounty_ksp_api_client-1.0.1.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

bugbounty_ksp_api_client-1.0.1-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file bugbounty_ksp_api_client-1.0.1.tar.gz.

File metadata

File hashes

Hashes for bugbounty_ksp_api_client-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4e0b58b001fde5a18d54e359694620c352c36726cf4c29876578ff03e746ca34
MD5 e5ba0d9cb1b615dffd6b4be8ced1f1e2
BLAKE2b-256 a9a88f29acddbb6eff9a2b561ad97982286ee18f4155104ee2af0fb33e1017ff

See more details on using hashes here.

File details

Details for the file bugbounty_ksp_api_client-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bugbounty_ksp_api_client-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 277f76529d05deba97b066e3c032e07f11ffea5ec77e7833216198e3b113041e
MD5 2823a961f754c4064d524d408b5d5f7a
BLAKE2b-256 8ac7b3e3c072296bed6174eb5c2cbbbd6dace8d47984f709ef54f257ff1b4bbf

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