Skip to main content

Beautiful API documentation for Django - Alternative to Swagger/Scramble

Project description

ByteDocs Django

Beautiful API documentation for Django - A modern alternative to Swagger and Scramble.

ByteDocs Django automatically generates interactive API documentation from your Django views and Django REST Framework serializers, with optional AI-powered features.

✨ Features

  • 🚀 Zero Configuration - Works out of the box with sensible defaults
  • 📝 Auto-Detection - Automatically discovers Django views and DRF ViewSets
  • 🎨 Beautiful UI - Modern, responsive interface with 8 color themes
  • 🤖 AI-Powered - Optional AI assistant for API queries (OpenAI, Gemini, Claude, OpenRouter)
  • 🔧 Try It Out - Interactive API testing directly in the documentation
  • 📊 OpenAPI 3.0 - Full OpenAPI specification export (JSON & YAML)
  • 🎯 DRF Support - First-class Django REST Framework integration
  • 🔐 Authentication - Built-in auth support (Basic, API Key, Bearer, Session)
  • 🌍 Multi-Environment - Support for multiple base URLs (dev, staging, prod)
  • Lightweight - No heavy dependencies, fast performance

📸 Screenshots

ByteDocs Django - Interactive API Documentation

🚀 Quick Start

Installation

pip install bytedocs-django

Basic Setup

  1. Add to your Django project's urls.py:
from django.urls import path, include
from bytedocs_django import setup_bytedocs

# Setup ByteDocs
bytedocs = setup_bytedocs(config={
    "title": "My API",
    "version": "1.0.0",
    "description": "My awesome API built with Django",
})

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include('your_app.urls')),
    path('docs/', include('bytedocs_django.urls')),
]

# Auto-detect routes
bytedocs.detect_routes()
  1. That's it! Visit http://localhost:8000/docs/ to see your documentation.

📚 Documentation

Configuration

ByteDocs supports both programmatic and environment-based configuration.

Programmatic Configuration

from bytedocs_django import setup_bytedocs

bytedocs = setup_bytedocs(config={
    "title": "My API",
    "version": "1.0.0",
    "description": "API Documentation",
    "base_urls": [
        {"name": "Development", "url": "http://localhost:8000"},
        {"name": "Production", "url": "https://api.example.com"},
    ],
    "docs_path": "/docs",
    "ui_config": {
        "theme": "purple",
        "dark_mode": True,
        "show_try_it": True,
        "show_schemas": True,
    },
    "ai_config": {
        "enabled": True,
        "provider": "openai",
        "api_key": "your-api-key",
        "features": {
            "chat_enabled": True,
            "model": "gpt-4o-mini",
            "temperature": 0.7,
        },
    },
})

Environment Variables

Create a .env file:

BYTEDOCS_TITLE=My API
BYTEDOCS_VERSION=1.0.0
BYTEDOCS_DESCRIPTION=API Documentation
BYTEDOCS_BASE_URL=http://localhost:8000

# UI Configuration
BYTEDOCS_UI_THEME=purple
BYTEDOCS_UI_DARK_MODE=true

# AI Configuration
BYTEDOCS_AI_ENABLED=true
BYTEDOCS_AI_PROVIDER=openai
BYTEDOCS_AI_API_KEY=sk-...

Django REST Framework Integration

ByteDocs automatically extracts schema information from DRF serializers:

from rest_framework import viewsets, serializers
from .models import Product

class ProductSerializer(serializers.ModelSerializer):
    """Product serializer with full schema"""
    class Meta:
        model = Product
        fields = ['id', 'name', 'price', 'description']

class ProductViewSet(viewsets.ModelViewSet):
    """
    ViewSet for managing products.

    list:
    Get all products with pagination.

    create:
    Create a new product.
    """
    queryset = Product.objects.all()
    serializer_class = ProductSerializer

ByteDocs will automatically:

  • ✅ Extract field types and descriptions
  • ✅ Detect required fields
  • ✅ Parse docstrings for endpoint descriptions
  • ✅ Generate request/response schemas
  • ✅ Create interactive examples

Customization

Add Tags

class ProductViewSet(viewsets.ModelViewSet):
    bytedocs_tags = ["Products", "E-commerce"]
    # ...

Custom Schemas

ByteDocs supports:

  • Django REST Framework Serializers
  • Pydantic models (django-ninja)
  • Django model forms
  • Dataclasses
  • Type hints

AI Features

Enable AI-powered documentation assistant:

BYTEDOCS_AI_ENABLED=true
BYTEDOCS_AI_PROVIDER=openai
BYTEDOCS_AI_API_KEY=your-key-here

Supported providers:

  • OpenAI (GPT-4, GPT-3.5)
  • Google Gemini (gemini-2.0-flash, gemini-1.5-pro)
  • Anthropic Claude (claude-3-5-sonnet, claude-3-opus)
  • OpenRouter (access to multiple models)

Features:

  • 💬 Chat with AI about your API
  • 🔍 Context-aware responses
  • 📉 70-80% token savings with optimization
  • 🎯 Endpoint-specific queries

Authentication

Protect your documentation with built-in authentication:

BYTEDOCS_AUTH_ENABLED=true
BYTEDOCS_AUTH_TYPE=session
BYTEDOCS_AUTH_PASSWORD=your-secure-password

Supported auth types:

  • Session - Password-protected with sessions
  • Basic - HTTP Basic authentication
  • API Key - Custom header authentication
  • Bearer - Bearer token authentication

Themes

Choose from 8 beautiful themes:

  • green (default)
  • blue
  • purple
  • red
  • orange
  • teal
  • pink
  • auto (system preference)

OpenAPI Export

ByteDocs generates full OpenAPI 3.0 specifications:

  • JSON: http://localhost:8000/docs/openapi.json
  • YAML: http://localhost:8000/docs/openapi.yaml

Use these files with other tools like Postman, Insomnia, or code generators.

🎯 Use Cases

  • API Documentation - Beautiful, interactive documentation for your Django API
  • API Testing - Test endpoints directly in the browser
  • Team Collaboration - Share documentation with your team
  • Client Integration - Help clients understand your API
  • OpenAPI Export - Generate OpenAPI specs for other tools

📦 Requirements

  • Python 3.8+
  • Django 3.2+
  • Django REST Framework (optional, for DRF support)
  • OpenAI/Gemini/Anthropic API key (optional, for AI features)

🤝 Contributing

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

📄 License

MIT License - see LICENSE file for details.

💡 Example Projects

Check out the examples/ directory for complete example projects:

  • Basic Example - Simple Django + DRF API with ByteDocs
  • More examples coming soon!

Made with ❤️ by the ByteDocs team

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

bytedocs_django-0.1.1.tar.gz (84.6 kB view details)

Uploaded Source

Built Distribution

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

bytedocs_django-0.1.1-py3-none-any.whl (95.0 kB view details)

Uploaded Python 3

File details

Details for the file bytedocs_django-0.1.1.tar.gz.

File metadata

  • Download URL: bytedocs_django-0.1.1.tar.gz
  • Upload date:
  • Size: 84.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for bytedocs_django-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5ac1d4db4f65e0287cb79f7412dce4c2b06afa777ba8d69a49c5a2ba6f2c78c1
MD5 a0efff730880347e3cd372779fc34be3
BLAKE2b-256 28fc8241986183f599eccec80726ab90e7f3fe7d87ccaa4cacdbe402518a7178

See more details on using hashes here.

File details

Details for the file bytedocs_django-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bytedocs_django-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e439ee91386be3f7fc115292de04fc14d1ed3e227ff3c5650b06a300c6456a2a
MD5 e5f52125ca5c15124606f3b2127cc9f4
BLAKE2b-256 c29fa58fe84f8c8d47386d4a9866193acc86c6b53d457339ce8511c665d7630f

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