Skip to main content

Alternative to Swagger with better design, auto-detection, and AI integration

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.2.tar.gz (84.7 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.2-py3-none-any.whl (95.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bytedocs_django-0.1.2.tar.gz
  • Upload date:
  • Size: 84.7 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.2.tar.gz
Algorithm Hash digest
SHA256 621621540d9d715111336f7bc11f44b10357b912f0da36a26ba960565f8310de
MD5 59251b2a159c73586b4024444c8f2292
BLAKE2b-256 ee9acd8d4d47ccd8c4ae4e4da9cdf4c0d8629593360c9dff2a83eaea9e2d293e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bytedocs_django-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2691f186df37001a853725755a4143cf77a05b17ed4a0a9e7efd7931cabe4743
MD5 6b88b75db55d6b4cbf0f5d9292d12f18
BLAKE2b-256 ac5899ceec215fd50730e655a54cefa8ae011b11a7c4b9d41f650efd33b9a2bf

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