eDocAPI
A lightweight Python framework for building document-processing and document-automation APIs.
Simple API for the developer. Powerful document processing underneath.
Built on Starlette. Version 0.0.2.
Installation
Core (PDF, DOCX text/HTML, images, Markdown text/HTML, uploads, CLI):
pip install edocapi
With HTML/Markdown/DOCX → PDF (pulls in WeasyPrint):
pip install edocapi[html]
WeasyPrint needs system libraries. On Debian/Ubuntu:
sudo apt-get install -y libcairo2 libpango-1.0-0 libpangocairo-1.0-0 \
libgdk-pixbuf-2.0-0 libffi-dev shared-mime-info
With PDF → images (requires poppler):
pip install edocapi[pdf-images]
# system: sudo apt-get install -y poppler-utils
Everything:
pip install edocapi[all]
Development (from source):
pip install -e ".[dev,html]"
Build and publish
From the repository root, build and check the package before uploading:
py -m pip install --upgrade build twine
py -m build
py -m twine check dist/*
py -m twine upload dist/*
Use __token__ as the Twine username and your PyPI API token as the password
when prompted. Do not commit the token. See PUBLISH.md for the
full checklist.
Quick Start
Create main.py:
from edocapi import App, Document
app = App()
@app.post("/convert")
def convert(file):
return Document(file).to_pdf()
@app.post("/compress")
def compress(file):
return Document(file).compress()
@app.post("/extract")
def extract(file):
return {"text": Document(file).extract_text()}
@app.post("/merge")
def merge(files):
return Document.merge(files)
@app.get("/")
def home():
return {"message": "eDocAPI v0.0.2", "supported": Document.supported_types()}
Run the development server:
edocapi run
# or with auto-reload:
edocapi run --reload
Upload a document to POST /convert and receive a PDF.
Core Concepts
Application
from edocapi import App
app = App(
debug=True,
max_file_size="25MB",
)
Document
from edocapi import Document
# From uploaded file (Path)
doc = Document(file)
# From HTML string
doc = Document.html("<h1>Invoice</h1><p>Total: ₦50,000</p>")
# From Markdown
doc = Document.markdown("# Hello World")
Conversions
Document(file).to_pdf() # → Document (PDF)
Document(file).to_text() # → str
Document(file).extract_text() # → str
Document(file).to_html() # → str
Document(file).to_images() # → list[Document]
PDF Operations
Document(file).compress(level="medium")
Document(file).split() # list of single-page Documents
Document(file).extract_pages(1, 5) # 1-based inclusive
Document(file).rotate(90, pages=[1, 2])
Document.merge([file1, file2])
Document(file).info() # dict of metadata
Supported Formats (v0.0.2)
| Input | to_pdf | to_text | to_html | to_images | Notes |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓* | ✓** | *text-based HTML | |
| DOCX | ✓ | ✓ | ✓ | – | |
| HTML | ✓ | ✓ | ✓ | – | |
| Markdown | ✓ | ✓ | ✓ | – | |
| JPG/PNG/WEBP | ✓ | – | – | ✓ | |
| TXT | – | ✓ | – | – | via Document constructor |
* PDF→HTML is a simple text extraction wrapper, not a visual rendering.
** PDF→Images requires optional pdf2image + system poppler.
Deploying
The package exposes an ASGI application. In your application's main.py, create
app = App() and start it with an ASGI server. For example:
uvicorn main:app.asgi --host 0.0.0.0 --port ${PORT:-8000} --workers 2
Keep debug=False in hosted environments. If you enable HTML-to-PDF conversion,
install WeasyPrint's operating-system libraries in the image or host as well as
the html extra. Set the reverse proxy's request-body limit to match
max_file_size; for larger workloads, use a worker queue and monitor temporary
disk usage.
Configuration
app = App(
debug=False, # more detailed errors when True
max_file_size="10MB", # "10MB", "25MB", 10485760, etc.
temp_dir=None, # custom temp directory (optional)
)
Error Handling
eDocAPI raises specific exceptions that become consistent JSON responses:
{
"error": "UnsupportedFileType",
"message": "The uploaded file type is not supported. (extension: .xlsx)"
}
Available exceptions: EdocAPIError, UnsupportedFileType, InvalidDocument, FileTooLarge, FileNotFound, ConversionError, ProcessingError, ValidationError.
CLI
edocapi --version
edocapi run # main:app on http://0.0.0.0:8000
edocapi run --reload
edocapi run myapp:app --port 8080
Architecture
eDocAPI
│
Document abstraction
│
+───────────+───────────+
│ │ │
PDF DOCX Images …
│ │ │
pypdf python-docx Pillow
│
weasyprint (HTML/PDF)
Processors are registered internally and can be extended in future versions.
Development
pip install -e ".[dev]"
pytest
Release status
eDocAPI is alpha software. Review conversion behavior, optional system dependencies, and workload limits before exposing it to untrusted public traffic. See PUBLISH.md for the release checklist.
Roadmap
- v0.1 – OpenAPI generation, more formats, plugin system
- v0.2 – OCR, background jobs, cloud storage adapters
- v0.3+ – Document signing, AI integrations, advanced workflows
Author
EMMANUEL EMMANUEL ETIM
Email: emmanuel224etim089@gmail.com
GitHub: https://github.com/emmanuelemmanueletim/edocApi
License
MIT — Copyright (c) 2026 EMMANUEL EMMANUEL ETIM
Metadata
Release files for edocapi 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| edocapi-0.0.2.tar.gz | 24.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| edocapi-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 55.9 kB
Release files / edocapi-0.0.2.tar.gz
| Download URL | edocapi-0.0.2.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aac90b5f09ea9192313272c6f62c20b5f1d73567f6e33d76182a1462232474b5
|
|
BLAKE2b-256 checksum How to use checksums |
eec35ed9c9ae583084c776c55bb7787f24ab3ee7fd030837c7d89cc1ac73207c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / edocapi-0.0.2-py3-none-any.whl
| Download URL | edocapi-0.0.2-py3-none-any.whl |
|---|---|
| Size | 31.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78d77fc2af944ec12cb328d959fdfec3b2ad4a638a059d8256ed2a9a5371da21
|
|
BLAKE2b-256 checksum How to use checksums |
160602b9a6a14f2e81effbd62979d9b2049f44207042d63c3c0d321b5b435001
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|