Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Django TypeScript API Generator

A zero-dependency Django plugin that automatically generates TypeScript interfaces and documentation from your Django models.

Features

  • Zero Dependencies: Uses only Django and Python standard libraries
  • Type-Safe Interfaces: Generate TypeScript interfaces from Django models
  • Comprehensive Documentation: Automatic JSDoc generation with field descriptions and validation rules
  • Validation Constraints: Extracts min/max length, value constraints, regex patterns, and choices
  • Highly Configurable: Customize through Django settings or command-line options
  • Scalable Architecture: Built with design patterns for future extensibility

Installation

Add to your INSTALLED_APPS:

# settings.py
INSTALLED_APPS = [
    # ...
    'django_typescript_api',
]

Configure (optional):

# settings.py
DJANGO_TYPESCRIPT_API = {
    'OUTPUT_PATH': 'frontend/src/api/generated.ts',
    'INCLUDE_DOCS': True,
    'INCLUDE_VALIDATORS': True,
    'TYPE_MAPPINGS': {
        'DecimalField': 'string',  # Override default mapping
    }
}

Usage

# Generate TypeScript interfaces
python manage.py generate_ts_client

# Specific output file
python manage.py generate_ts_client --output frontend/src/api/models.ts

# Only specific apps
python manage.py generate_ts_client --apps blog users

# Skip documentation
python manage.py generate_ts_client --no-docs

# Skip validation constraints
python manage.py generate_ts_client --no-validators

# Verbose output with details
python manage.py generate_ts_client --verbose

# Dry run (preview without writing)
python manage.py generate_ts_client --dry-run

Example Output

// Generated by django-typescript-api
// DO NOT EDIT THIS FILE DIRECTLY

/**
 * Blog post
 * @interface Post
 */
export interface Post {
  /**
   * Post title
   * @minLength 5
   * @maxLength 200
   */
  title: string;
  
  /**
   * Publication status
   * @enum {'draft', 'published', 'archived'}
   */
  status: 'draft' | 'published' | 'archived';
  
  /**
   * When the post was created
   */
  created_at: string;
}

export interface User {
  // ... with similar documentation
}

Supported Field Types

  • String fields: CharField, TextField, EmailField, SlugField, etc.
  • Numeric fields: IntegerField, FloatField, DecimalField, etc.
  • Boolean fields: BooleanField
  • Date/time fields: DateField, DateTimeField, TimeField
  • Relations: ForeignKey, OneToOneField, ManyToManyField
  • Special fields: UUIDField, JSONField, FileField

Configuration Options

Setting Default Description
OUTPUT_PATH frontend/src/api/generated.ts Output file path
INCLUDE_DOCS True Generate JSDoc documentation
INCLUDE_VALIDATORS True Include validation constraints
TYPE_MAPPINGS {} Custom Django-to-TypeScript type mappings
CUSTOM_HEADERS Predefined Custom file header comments

Roadmap

  • Phase 2: API endpoint generation from DRF viewsets
  • Phase 3: Query parameter typing and advanced features
  • Phase 4: Performance optimizations and extensibility hooks

Contributing

This is currently in active development. The architecture is designed with scalability in mind using Builder, Visitor, and Strategy patterns.

License

MIT License – feel free to use and contribute!


Metadata

Release files for django-typescript-api 0.1.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-typescript-api 0.1.0rc1
File Size Uploaded
django_typescript_api-0.1.0rc1.tar.gz 12.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-typescript-api 0.1.0rc1
File Interpreter ABI Platform
django_typescript_api-0.1.0rc1-py3-none-any.whl Python 3 none any Details

Total release size: 26.4 kB

Release files / django_typescript_api-0.1.0rc1.tar.gz

Download URL django_typescript_api-0.1.0rc1.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
45d5df7204075fc105a32e83d0e94635c92cb8bbf085c5bc9bba1efb7bd7c6ae
BLAKE2b-256 checksum
How to use checksums
d3e1ab0fbcc9758147c6de36d120dd2703e57ea4a15ca4df6f73abf4d24bc532
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2025.

Transparency log

Release files / django_typescript_api-0.1.0rc1-py3-none-any.whl

Download URL django_typescript_api-0.1.0rc1-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45908eda9cf143f8fb7a1adf5d892f418c053928b515748253b1fc3b5a8b0e1d
BLAKE2b-256 checksum
How to use checksums
9677696aa0ad7339610ee451b682f163496ba94cd14862bc75a281a215649b90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0rc1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page