edocapi 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- edocapi-0.0.2/AUTHORS.md +12 -0
- edocapi-0.0.2/LICENSE +21 -0
- edocapi-0.0.2/MANIFEST.in +11 -0
- edocapi-0.0.2/PKG-INFO +335 -0
- edocapi-0.0.2/PUBLISH.md +51 -0
- edocapi-0.0.2/README.md +285 -0
- edocapi-0.0.2/edocapi/__init__.py +49 -0
- edocapi-0.0.2/edocapi/app.py +255 -0
- edocapi-0.0.2/edocapi/cli/__init__.py +3 -0
- edocapi-0.0.2/edocapi/cli/main.py +94 -0
- edocapi-0.0.2/edocapi/config.py +76 -0
- edocapi-0.0.2/edocapi/document.py +290 -0
- edocapi-0.0.2/edocapi/exceptions.py +104 -0
- edocapi-0.0.2/edocapi/files.py +97 -0
- edocapi-0.0.2/edocapi/processors/__init__.py +16 -0
- edocapi-0.0.2/edocapi/processors/base.py +101 -0
- edocapi-0.0.2/edocapi/processors/docx.py +112 -0
- edocapi-0.0.2/edocapi/processors/html.py +64 -0
- edocapi-0.0.2/edocapi/processors/image.py +80 -0
- edocapi-0.0.2/edocapi/processors/markdown.py +64 -0
- edocapi-0.0.2/edocapi/processors/pdf.py +231 -0
- edocapi-0.0.2/edocapi/processors/txt.py +58 -0
- edocapi-0.0.2/edocapi/responses.py +88 -0
- edocapi-0.0.2/edocapi/storage/__init__.py +3 -0
- edocapi-0.0.2/edocapi/storage/temporary.py +132 -0
- edocapi-0.0.2/edocapi/validation/__init__.py +13 -0
- edocapi-0.0.2/edocapi/validation/files.py +209 -0
- edocapi-0.0.2/edocapi.egg-info/SOURCES.txt +27 -0
- edocapi-0.0.2/pyproject.toml +93 -0
- edocapi-0.0.2/setup.cfg +4 -0
edocapi-0.0.2/AUTHORS.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Authors
|
|
2
|
+
|
|
3
|
+
**eDocAPI** is created and maintained by:
|
|
4
|
+
|
|
5
|
+
| Field | Value |
|
|
6
|
+
|--------|-------|
|
|
7
|
+
| Name | EMMANUEL EMMANUEL ETIM |
|
|
8
|
+
| Email | emmanuel224etim089@gmail.com |
|
|
9
|
+
| GitHub | https://github.com/emmanuelemmanueletim/edocApi |
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 EMMANUEL EMMANUEL ETIM.
|
|
12
|
+
Licensed under the MIT License — see `LICENSE`.
|
edocapi-0.0.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 EMMANUEL EMMANUEL ETIM
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
include LICENSE
|
|
2
|
+
include README.md
|
|
3
|
+
include AUTHORS.md
|
|
4
|
+
include PUBLISH.md
|
|
5
|
+
include pyproject.toml
|
|
6
|
+
recursive-include edocapi *.py
|
|
7
|
+
recursive-exclude * __pycache__
|
|
8
|
+
recursive-exclude * *.py[cod]
|
|
9
|
+
prune tests
|
|
10
|
+
prune .pytest_cache
|
|
11
|
+
prune edocapi.egg-info
|
edocapi-0.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: edocapi
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: A lightweight Python framework for building document-processing and document-automation APIs.
|
|
5
|
+
Author-email: EMMANUEL EMMANUEL ETIM <emmanuel224etim089@gmail.com>
|
|
6
|
+
Maintainer-email: EMMANUEL EMMANUEL ETIM <emmanuel224etim089@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/emmanuelemmanueletim/edocApi
|
|
9
|
+
Project-URL: Documentation, https://github.com/emmanuelemmanueletim/edocApi#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/emmanuelemmanueletim/edocApi.git
|
|
11
|
+
Project-URL: Issues, https://github.com/emmanuelemmanueletim/edocApi/issues
|
|
12
|
+
Keywords: document,api,pdf,docx,conversion,starlette,framework,document-processing
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Framework :: AsyncIO
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
24
|
+
Classifier: Topic :: Text Processing
|
|
25
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: starlette>=0.37.0
|
|
30
|
+
Requires-Dist: python-multipart>=0.0.9
|
|
31
|
+
Requires-Dist: uvicorn[standard]>=0.27.0
|
|
32
|
+
Requires-Dist: pypdf>=4.0.0
|
|
33
|
+
Requires-Dist: python-docx>=1.1.0
|
|
34
|
+
Requires-Dist: markdown>=3.5
|
|
35
|
+
Requires-Dist: Pillow>=10.0.0
|
|
36
|
+
Provides-Extra: html
|
|
37
|
+
Requires-Dist: weasyprint>=61.0; extra == "html"
|
|
38
|
+
Provides-Extra: pdf-images
|
|
39
|
+
Requires-Dist: pdf2image>=1.17.0; extra == "pdf-images"
|
|
40
|
+
Provides-Extra: all
|
|
41
|
+
Requires-Dist: weasyprint>=61.0; extra == "all"
|
|
42
|
+
Requires-Dist: pdf2image>=1.17.0; extra == "all"
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
45
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
46
|
+
Requires-Dist: httpx>=0.26.0; extra == "dev"
|
|
47
|
+
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
48
|
+
Requires-Dist: twine>=5.0.0; extra == "dev"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# eDocAPI
|
|
52
|
+
|
|
53
|
+
**A lightweight Python framework for building document-processing and document-automation APIs.**
|
|
54
|
+
|
|
55
|
+
> Simple API for the developer. Powerful document processing underneath.
|
|
56
|
+
|
|
57
|
+
Built on [Starlette](https://www.starlette.io/). Version **0.0.2**.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
**Core** (PDF, DOCX text/HTML, images, Markdown text/HTML, uploads, CLI):
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install edocapi
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**With HTML/Markdown/DOCX → PDF** (pulls in WeasyPrint):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install edocapi[html]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
WeasyPrint needs system libraries. On Debian/Ubuntu:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
sudo apt-get install -y libcairo2 libpango-1.0-0 libpangocairo-1.0-0 \
|
|
79
|
+
libgdk-pixbuf-2.0-0 libffi-dev shared-mime-info
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**With PDF → images** (requires poppler):
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install edocapi[pdf-images]
|
|
86
|
+
# system: sudo apt-get install -y poppler-utils
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Everything:**
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pip install edocapi[all]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Development (from source):**
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pip install -e ".[dev,html]"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Build and publish
|
|
102
|
+
|
|
103
|
+
From the repository root, build and check the package before uploading:
|
|
104
|
+
|
|
105
|
+
```powershell
|
|
106
|
+
py -m pip install --upgrade build twine
|
|
107
|
+
py -m build
|
|
108
|
+
py -m twine check dist/*
|
|
109
|
+
py -m twine upload dist/*
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Use `__token__` as the Twine username and your PyPI API token as the password
|
|
113
|
+
when prompted. Do not commit the token. See [PUBLISH.md](PUBLISH.md) for the
|
|
114
|
+
full checklist.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Quick Start
|
|
119
|
+
|
|
120
|
+
Create `main.py`:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from edocapi import App, Document
|
|
124
|
+
|
|
125
|
+
app = App()
|
|
126
|
+
|
|
127
|
+
@app.post("/convert")
|
|
128
|
+
def convert(file):
|
|
129
|
+
return Document(file).to_pdf()
|
|
130
|
+
|
|
131
|
+
@app.post("/compress")
|
|
132
|
+
def compress(file):
|
|
133
|
+
return Document(file).compress()
|
|
134
|
+
|
|
135
|
+
@app.post("/extract")
|
|
136
|
+
def extract(file):
|
|
137
|
+
return {"text": Document(file).extract_text()}
|
|
138
|
+
|
|
139
|
+
@app.post("/merge")
|
|
140
|
+
def merge(files):
|
|
141
|
+
return Document.merge(files)
|
|
142
|
+
|
|
143
|
+
@app.get("/")
|
|
144
|
+
def home():
|
|
145
|
+
return {"message": "eDocAPI v0.0.2", "supported": Document.supported_types()}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Run the development server:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
edocapi run
|
|
152
|
+
# or with auto-reload:
|
|
153
|
+
edocapi run --reload
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Upload a document to `POST /convert` and receive a PDF.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Core Concepts
|
|
161
|
+
|
|
162
|
+
### Application
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from edocapi import App
|
|
166
|
+
|
|
167
|
+
app = App(
|
|
168
|
+
debug=True,
|
|
169
|
+
max_file_size="25MB",
|
|
170
|
+
)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Document
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from edocapi import Document
|
|
177
|
+
|
|
178
|
+
# From uploaded file (Path)
|
|
179
|
+
doc = Document(file)
|
|
180
|
+
|
|
181
|
+
# From HTML string
|
|
182
|
+
doc = Document.html("<h1>Invoice</h1><p>Total: ₦50,000</p>")
|
|
183
|
+
|
|
184
|
+
# From Markdown
|
|
185
|
+
doc = Document.markdown("# Hello World")
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Conversions
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
Document(file).to_pdf() # → Document (PDF)
|
|
192
|
+
Document(file).to_text() # → str
|
|
193
|
+
Document(file).extract_text() # → str
|
|
194
|
+
Document(file).to_html() # → str
|
|
195
|
+
Document(file).to_images() # → list[Document]
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### PDF Operations
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
Document(file).compress(level="medium")
|
|
202
|
+
Document(file).split() # list of single-page Documents
|
|
203
|
+
Document(file).extract_pages(1, 5) # 1-based inclusive
|
|
204
|
+
Document(file).rotate(90, pages=[1, 2])
|
|
205
|
+
Document.merge([file1, file2])
|
|
206
|
+
Document(file).info() # dict of metadata
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Supported Formats (v0.0.2)
|
|
212
|
+
|
|
213
|
+
| Input | to_pdf | to_text | to_html | to_images | Notes |
|
|
214
|
+
|-----------|--------|---------|---------|-----------|------------------------|
|
|
215
|
+
| PDF | ✓ | ✓ | ✓* | ✓** | *text-based HTML |
|
|
216
|
+
| DOCX | ✓ | ✓ | ✓ | – | |
|
|
217
|
+
| HTML | ✓ | ✓ | ✓ | – | |
|
|
218
|
+
| Markdown | ✓ | ✓ | ✓ | – | |
|
|
219
|
+
| JPG/PNG/WEBP | ✓ | – | – | ✓ | |
|
|
220
|
+
| TXT | – | ✓ | – | – | via Document constructor |
|
|
221
|
+
|
|
222
|
+
\* PDF→HTML is a simple text extraction wrapper, not a visual rendering.
|
|
223
|
+
\*\* PDF→Images requires optional `pdf2image` + system poppler.
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
## Deploying
|
|
229
|
+
|
|
230
|
+
The package exposes an ASGI application. In your application's `main.py`, create
|
|
231
|
+
`app = App()` and start it with an ASGI server. For example:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
uvicorn main:app.asgi --host 0.0.0.0 --port ${PORT:-8000} --workers 2
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Keep `debug=False` in hosted environments. If you enable HTML-to-PDF conversion,
|
|
238
|
+
install WeasyPrint's operating-system libraries in the image or host as well as
|
|
239
|
+
the `html` extra. Set the reverse proxy's request-body limit to match
|
|
240
|
+
`max_file_size`; for larger workloads, use a worker queue and monitor temporary
|
|
241
|
+
disk usage.
|
|
242
|
+
|
|
243
|
+
## Configuration
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
app = App(
|
|
247
|
+
debug=False, # more detailed errors when True
|
|
248
|
+
max_file_size="10MB", # "10MB", "25MB", 10485760, etc.
|
|
249
|
+
temp_dir=None, # custom temp directory (optional)
|
|
250
|
+
)
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Error Handling
|
|
256
|
+
|
|
257
|
+
eDocAPI raises specific exceptions that become consistent JSON responses:
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"error": "UnsupportedFileType",
|
|
262
|
+
"message": "The uploaded file type is not supported. (extension: .xlsx)"
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Available exceptions: `EdocAPIError`, `UnsupportedFileType`, `InvalidDocument`, `FileTooLarge`, `FileNotFound`, `ConversionError`, `ProcessingError`, `ValidationError`.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## CLI
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
edocapi --version
|
|
274
|
+
edocapi run # main:app on http://0.0.0.0:8000
|
|
275
|
+
edocapi run --reload
|
|
276
|
+
edocapi run myapp:app --port 8080
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Architecture
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
eDocAPI
|
|
285
|
+
│
|
|
286
|
+
Document abstraction
|
|
287
|
+
│
|
|
288
|
+
+───────────+───────────+
|
|
289
|
+
│ │ │
|
|
290
|
+
PDF DOCX Images …
|
|
291
|
+
│ │ │
|
|
292
|
+
pypdf python-docx Pillow
|
|
293
|
+
│
|
|
294
|
+
weasyprint (HTML/PDF)
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Processors are registered internally and can be extended in future versions.
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Development
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
pip install -e ".[dev]"
|
|
305
|
+
pytest
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
## Release status
|
|
312
|
+
|
|
313
|
+
eDocAPI is alpha software. Review conversion behavior, optional system
|
|
314
|
+
dependencies, and workload limits before exposing it to untrusted public
|
|
315
|
+
traffic. See [PUBLISH.md](PUBLISH.md) for the release checklist.
|
|
316
|
+
|
|
317
|
+
## Roadmap
|
|
318
|
+
|
|
319
|
+
- **v0.1** – OpenAPI generation, more formats, plugin system
|
|
320
|
+
- **v0.2** – OCR, background jobs, cloud storage adapters
|
|
321
|
+
- **v0.3+** – Document signing, AI integrations, advanced workflows
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Author
|
|
326
|
+
|
|
327
|
+
**EMMANUEL EMMANUEL ETIM**
|
|
328
|
+
Email: [emmanuel224etim089@gmail.com](mailto:emmanuel224etim089@gmail.com)
|
|
329
|
+
GitHub: [https://github.com/emmanuelemmanueletim/edocApi](https://github.com/emmanuelemmanueletim/edocApi)
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## License
|
|
334
|
+
|
|
335
|
+
MIT — Copyright (c) 2026 EMMANUEL EMMANUEL ETIM
|
edocapi-0.0.2/PUBLISH.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Release checklist
|
|
2
|
+
|
|
3
|
+
This document describes the release process. Publishing requires the maintainer's
|
|
4
|
+
PyPI credentials and is a separate step from preparing the package.
|
|
5
|
+
|
|
6
|
+
## Before release
|
|
7
|
+
|
|
8
|
+
1. Update the version in `pyproject.toml`, `edocapi/__init__.py`, and README.
|
|
9
|
+
2. Review the changes and run the project test suite on supported Python versions.
|
|
10
|
+
3. Build and inspect both distributions:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
python -m pip install --upgrade build twine
|
|
14
|
+
python -m build
|
|
15
|
+
python -m twine check dist/*
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
4. Install the wheel in a clean environment and verify `import edocapi`, the
|
|
19
|
+
`edocapi --version` command, and the documented optional extras.
|
|
20
|
+
5. Upload to TestPyPI and install the candidate package from a clean environment.
|
|
21
|
+
|
|
22
|
+
## Publish
|
|
23
|
+
|
|
24
|
+
Use a PyPI API token and Trusted Publishing where configured. Otherwise upload
|
|
25
|
+
with Twine, entering `__token__` as the username and the token as the password:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
python -m twine upload dist/*
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Do not commit API tokens. A version already uploaded to PyPI cannot be replaced;
|
|
32
|
+
increment the version for every follow-up release.
|
|
33
|
+
|
|
34
|
+
For the first upload, build with an empty `dist/` directory so the command cannot
|
|
35
|
+
accidentally include stale artifacts from an earlier version. Verify that the
|
|
36
|
+
filenames are `edocapi-0.0.2.tar.gz` and `edocapi-0.0.2-py3-none-any.whl` before
|
|
37
|
+
uploading.
|
|
38
|
+
|
|
39
|
+
## Hosted deployment
|
|
40
|
+
|
|
41
|
+
Create an application module exposing `app = App()` and run an ASGI server, for
|
|
42
|
+
example:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uvicorn main:app.asgi --host 0.0.0.0 --port ${PORT:-8000} --workers 2
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Use `debug=False`, configure the proxy body-size limit to match the app's upload
|
|
49
|
+
limit, and install the required operating-system libraries for optional PDF
|
|
50
|
+
conversions. Monitor temporary disk usage and use a queue for CPU-heavy or
|
|
51
|
+
long-running document conversions.
|
edocapi-0.0.2/README.md
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# eDocAPI
|
|
2
|
+
|
|
3
|
+
**A lightweight Python framework for building document-processing and document-automation APIs.**
|
|
4
|
+
|
|
5
|
+
> Simple API for the developer. Powerful document processing underneath.
|
|
6
|
+
|
|
7
|
+
Built on [Starlette](https://www.starlette.io/). Version **0.0.2**.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
**Core** (PDF, DOCX text/HTML, images, Markdown text/HTML, uploads, CLI):
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install edocapi
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**With HTML/Markdown/DOCX → PDF** (pulls in WeasyPrint):
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install edocapi[html]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
WeasyPrint needs system libraries. On Debian/Ubuntu:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
sudo apt-get install -y libcairo2 libpango-1.0-0 libpangocairo-1.0-0 \
|
|
29
|
+
libgdk-pixbuf-2.0-0 libffi-dev shared-mime-info
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**With PDF → images** (requires poppler):
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install edocapi[pdf-images]
|
|
36
|
+
# system: sudo apt-get install -y poppler-utils
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Everything:**
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install edocapi[all]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Development (from source):**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install -e ".[dev,html]"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Build and publish
|
|
52
|
+
|
|
53
|
+
From the repository root, build and check the package before uploading:
|
|
54
|
+
|
|
55
|
+
```powershell
|
|
56
|
+
py -m pip install --upgrade build twine
|
|
57
|
+
py -m build
|
|
58
|
+
py -m twine check dist/*
|
|
59
|
+
py -m twine upload dist/*
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Use `__token__` as the Twine username and your PyPI API token as the password
|
|
63
|
+
when prompted. Do not commit the token. See [PUBLISH.md](PUBLISH.md) for the
|
|
64
|
+
full checklist.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
|
|
70
|
+
Create `main.py`:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from edocapi import App, Document
|
|
74
|
+
|
|
75
|
+
app = App()
|
|
76
|
+
|
|
77
|
+
@app.post("/convert")
|
|
78
|
+
def convert(file):
|
|
79
|
+
return Document(file).to_pdf()
|
|
80
|
+
|
|
81
|
+
@app.post("/compress")
|
|
82
|
+
def compress(file):
|
|
83
|
+
return Document(file).compress()
|
|
84
|
+
|
|
85
|
+
@app.post("/extract")
|
|
86
|
+
def extract(file):
|
|
87
|
+
return {"text": Document(file).extract_text()}
|
|
88
|
+
|
|
89
|
+
@app.post("/merge")
|
|
90
|
+
def merge(files):
|
|
91
|
+
return Document.merge(files)
|
|
92
|
+
|
|
93
|
+
@app.get("/")
|
|
94
|
+
def home():
|
|
95
|
+
return {"message": "eDocAPI v0.0.2", "supported": Document.supported_types()}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Run the development server:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
edocapi run
|
|
102
|
+
# or with auto-reload:
|
|
103
|
+
edocapi run --reload
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Upload a document to `POST /convert` and receive a PDF.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Core Concepts
|
|
111
|
+
|
|
112
|
+
### Application
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from edocapi import App
|
|
116
|
+
|
|
117
|
+
app = App(
|
|
118
|
+
debug=True,
|
|
119
|
+
max_file_size="25MB",
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Document
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from edocapi import Document
|
|
127
|
+
|
|
128
|
+
# From uploaded file (Path)
|
|
129
|
+
doc = Document(file)
|
|
130
|
+
|
|
131
|
+
# From HTML string
|
|
132
|
+
doc = Document.html("<h1>Invoice</h1><p>Total: ₦50,000</p>")
|
|
133
|
+
|
|
134
|
+
# From Markdown
|
|
135
|
+
doc = Document.markdown("# Hello World")
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Conversions
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
Document(file).to_pdf() # → Document (PDF)
|
|
142
|
+
Document(file).to_text() # → str
|
|
143
|
+
Document(file).extract_text() # → str
|
|
144
|
+
Document(file).to_html() # → str
|
|
145
|
+
Document(file).to_images() # → list[Document]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### PDF Operations
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
Document(file).compress(level="medium")
|
|
152
|
+
Document(file).split() # list of single-page Documents
|
|
153
|
+
Document(file).extract_pages(1, 5) # 1-based inclusive
|
|
154
|
+
Document(file).rotate(90, pages=[1, 2])
|
|
155
|
+
Document.merge([file1, file2])
|
|
156
|
+
Document(file).info() # dict of metadata
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Supported Formats (v0.0.2)
|
|
162
|
+
|
|
163
|
+
| Input | to_pdf | to_text | to_html | to_images | Notes |
|
|
164
|
+
|-----------|--------|---------|---------|-----------|------------------------|
|
|
165
|
+
| PDF | ✓ | ✓ | ✓* | ✓** | *text-based HTML |
|
|
166
|
+
| DOCX | ✓ | ✓ | ✓ | – | |
|
|
167
|
+
| HTML | ✓ | ✓ | ✓ | – | |
|
|
168
|
+
| Markdown | ✓ | ✓ | ✓ | – | |
|
|
169
|
+
| JPG/PNG/WEBP | ✓ | – | – | ✓ | |
|
|
170
|
+
| TXT | – | ✓ | – | – | via Document constructor |
|
|
171
|
+
|
|
172
|
+
\* PDF→HTML is a simple text extraction wrapper, not a visual rendering.
|
|
173
|
+
\*\* PDF→Images requires optional `pdf2image` + system poppler.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
## Deploying
|
|
179
|
+
|
|
180
|
+
The package exposes an ASGI application. In your application's `main.py`, create
|
|
181
|
+
`app = App()` and start it with an ASGI server. For example:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
uvicorn main:app.asgi --host 0.0.0.0 --port ${PORT:-8000} --workers 2
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Keep `debug=False` in hosted environments. If you enable HTML-to-PDF conversion,
|
|
188
|
+
install WeasyPrint's operating-system libraries in the image or host as well as
|
|
189
|
+
the `html` extra. Set the reverse proxy's request-body limit to match
|
|
190
|
+
`max_file_size`; for larger workloads, use a worker queue and monitor temporary
|
|
191
|
+
disk usage.
|
|
192
|
+
|
|
193
|
+
## Configuration
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
app = App(
|
|
197
|
+
debug=False, # more detailed errors when True
|
|
198
|
+
max_file_size="10MB", # "10MB", "25MB", 10485760, etc.
|
|
199
|
+
temp_dir=None, # custom temp directory (optional)
|
|
200
|
+
)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Error Handling
|
|
206
|
+
|
|
207
|
+
eDocAPI raises specific exceptions that become consistent JSON responses:
|
|
208
|
+
|
|
209
|
+
```json
|
|
210
|
+
{
|
|
211
|
+
"error": "UnsupportedFileType",
|
|
212
|
+
"message": "The uploaded file type is not supported. (extension: .xlsx)"
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Available exceptions: `EdocAPIError`, `UnsupportedFileType`, `InvalidDocument`, `FileTooLarge`, `FileNotFound`, `ConversionError`, `ProcessingError`, `ValidationError`.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## CLI
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
edocapi --version
|
|
224
|
+
edocapi run # main:app on http://0.0.0.0:8000
|
|
225
|
+
edocapi run --reload
|
|
226
|
+
edocapi run myapp:app --port 8080
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Architecture
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
eDocAPI
|
|
235
|
+
│
|
|
236
|
+
Document abstraction
|
|
237
|
+
│
|
|
238
|
+
+───────────+───────────+
|
|
239
|
+
│ │ │
|
|
240
|
+
PDF DOCX Images …
|
|
241
|
+
│ │ │
|
|
242
|
+
pypdf python-docx Pillow
|
|
243
|
+
│
|
|
244
|
+
weasyprint (HTML/PDF)
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Processors are registered internally and can be extended in future versions.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Development
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
pip install -e ".[dev]"
|
|
255
|
+
pytest
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
## Release status
|
|
262
|
+
|
|
263
|
+
eDocAPI is alpha software. Review conversion behavior, optional system
|
|
264
|
+
dependencies, and workload limits before exposing it to untrusted public
|
|
265
|
+
traffic. See [PUBLISH.md](PUBLISH.md) for the release checklist.
|
|
266
|
+
|
|
267
|
+
## Roadmap
|
|
268
|
+
|
|
269
|
+
- **v0.1** – OpenAPI generation, more formats, plugin system
|
|
270
|
+
- **v0.2** – OCR, background jobs, cloud storage adapters
|
|
271
|
+
- **v0.3+** – Document signing, AI integrations, advanced workflows
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Author
|
|
276
|
+
|
|
277
|
+
**EMMANUEL EMMANUEL ETIM**
|
|
278
|
+
Email: [emmanuel224etim089@gmail.com](mailto:emmanuel224etim089@gmail.com)
|
|
279
|
+
GitHub: [https://github.com/emmanuelemmanueletim/edocApi](https://github.com/emmanuelemmanueletim/edocApi)
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## License
|
|
284
|
+
|
|
285
|
+
MIT — Copyright (c) 2026 EMMANUEL EMMANUEL ETIM
|