Skip to main content

DocAPI is a Python package that automatically generates API documentation using LLM.

Project description

image

Python Version OS Lisence PyPI GitHub pull request

[ English | 中文 ]

DocAPI is a Python package that automatically generates API documentation using a large model. It automatically scans the API routing structure, generates or updates API documentation, gives code call examples, and deploys and displays documentation using web pages.

Installation

pip install docapi

or

pip install -U docapi -i https://pypi.org/simple

GitHub source code installation

pip install git+https://github.com/Shulin-Zhang/docapi

Usage

Method 1 (Recommended)

Automatically scan the routing structure. This is only valid for flask projects and must be used in the environment of api projects.

export OPENAI_API_KEY=your_key

# Generate API documentation
docapi generate server.py

# Update API documentation
docapi update server.py

# Start the web service
docapi serve

or

export OPENAI_API_KEY=your_key

export OPENAI_API_BASE=api_base_url

export OPENAI_API_MODEL=model_name

# 生成文档
docapi generate server.py

# 更新文档
docapi update server.py

# 启动web服务
docapi serve

Method 2

Generate the configuration file

docapi init

Edit the config.yaml file

# API file list

api_files: 
  - 'flask_server.py'
  - 'flask_api.py'

# OpenAI

openai_api_key: xxx

openai_base_url: 'http://ip:port/v1'

openai_model: 'qwen-plus'

# Azure OpenAI

azure_api_key: null

azure_endpoint: null

azure_api_version: null

azure_model: null
# Generate API documentation
docapi generate --doc_dir ./docs --lang zh --config config.yaml

# Update API documentation
docapi update --doc_dir ./docs --lang zh --config config.yaml

# Start the web service
docapi serve ./docs -h 127.0.0.1 -p 9000

Supported Models

  • OpenAI

  • AzureOpenAI

  • Tongyi Qianwen

Supported API Frameworks

  • Flask

Automatic scanning is only valid for the Flask framework and is recommended for use on Flask services.

API Web Page

image

TODO

  • Supports large models such as Wenxin Yiyan and Zhipu AI.

  • Supports automatic scanning of frameworks such as fastapi and Django.

  • Supports online web page display of documents.

  • Supports custom document templates.

  • Multithreading accelerates requests.

  • Import to postman.

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

docapi-0.0.10.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

docapi-0.0.10-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file docapi-0.0.10.tar.gz.

File metadata

  • Download URL: docapi-0.0.10.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.20

File hashes

Hashes for docapi-0.0.10.tar.gz
Algorithm Hash digest
SHA256 9e3cb9c36808a5dd7ed88ef0a12db163869244bd2fb9da79f70f0fe589d7f6ad
MD5 d1fed89e1f5a28d13b54d049099b88e8
BLAKE2b-256 3cb08a24773762b14a8a359a6b2d55e7051f1391ed1ad5acd2da13745cd296b1

See more details on using hashes here.

File details

Details for the file docapi-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: docapi-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.20

File hashes

Hashes for docapi-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 ec82a83b270c781e1c0e73484a7000532d0e67d3c454f56ef13cf8841c598bb6
MD5 41f8dd282fdcf7f70b8ef7ddee022249
BLAKE2b-256 590bbd87e41f6b26a0b7c42db2a4b320e3a10e90954b93d27ed903d32ac9e2bc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page