Async, typed Python client for DocGes REST API
Project description
docges-api-py
Async, typed Python client for the DocGes REST API.
Work in progress — bootstrapped via SDD (Spec-Driven Development).
Phase 1-4 completed: async client with auth, retry, token refresh, and tests. Phase 5 completed: All core endpoints implemented.
Features
- ✅ Async HTTP client using
httpx - ✅ Typed request/response models with Pydantic v2
- ✅ Configurable retries and timeouts
- ✅ Session-based auth using
loginResponsepassed to Content endpoints - ✅ Full test coverage (pytest + respx)
- ✅ Complete DocGes API client (upload, download, search, categories)
Implemented endpoints
Auth
auth()— authenticate against/Auth/Login
Content Tree
get_initial_cats()— load initial categories via/Content/LoadIniCatsget_cat_info(sid)— load category children via/Content/LoadChilds
Document Operations
upload_file(category_sid, file_path)— upload via/Content/UploadExtendeddownload_content(sid)— download via/Content/Download(returnsResFileDownload)get_document(sid)— deprecated wrapper (callsdownload_content())
Search
search_content(field_values, date_values)— search via/Content/SearchContent
Category Management
create_category(parent_sid, name)— create via/Content/CreateCategoryrename_category(sid, new_name)— rename via/Content/RenameCategorydelete_category(sid)— delete via/Content/DeleteCategory
Document Management
remove_document(sid)— remove via/Content/RemoveDocumentmove_content(content_sid, destination_sid)— move via/Content/Moveupdate_content(sid, erp_relation, erp_property)— update via/Content/Update
Quick start
pip install -e ".[dev]"
import asyncio
from docges_api_py import AsyncDocGes
async def main():
async with AsyncDocGes(
"https://docges.example.com", "user", "password", "appid"
) as client:
# Auth
auth_resp = await client.auth()
# The API is session-based: auth_resp contains user_info and ware_house_info
print(f"User: {auth_resp.user_info.get('Nombre')}")
print(f"Warehouse: {auth_resp.ware_house_info.get('Nombre')}")
# Load initial categories (the client injects loginResponse automatically)
cats = await client.get_initial_cats()
print(f"Initial categories: {len(cats.CategoriasHijas)}")
# Search documents
results = await client.search_content(
field_values=[{"field": "name", "mode": "contains", "text": "invoice"}]
)
print(f"Search results: {len(results.results)}")
asyncio.run(main())
See docs/quickstart.md or examples/quickstart.py for a more complete example.
Development
pip install -e ".[dev]"
ruff check src/ tests/
mypy src/
pytest --cov=docges_api_py
Migration
The library is being migrated from a sync requests-based client (see wm-sync reference code). See docs/MIGRATION.md for details.
Key changes:
- Replaced
requests(sync) withhttpx.AsyncClient - Replaced raw
__dict__serialization with Pydantic v2 models - Replaced silent
return Nonewith typed exceptions (AuthenticationError,RequestError) - Added configurable retries with exponential backoff
Project structure
docges-api-py/
├── src/docges_api_py/
│ ├── __init__.py # Exports AsyncDocGes, models (ResCat, ResFileDownload, etc.)
│ ├── client.py # AsyncDocGes client (auth + all endpoints)
│ └── models/
│ ├── auth.py # AuthRequest, AuthResponse
│ ├── document.py # Document
│ ├── requests.py # Request models (ReqUpload, ReqSearchContent, etc.)
│ ├── responses.py # Response models (ResCat, ResFileDownload, etc.)
│ └── __init__.py # Model exports
├── tests/
│ ├── conftest.py
│ ├── test_client_auth.py
│ ├── test_initial_cats.py
│ ├── test_content_methods.py
│ ├── test_remaining_methods.py
│ ├── test_models_requests.py
│ ├── test_models_responses.py
│ ├── test_models_init.py
│ ├── test_endpoints.py
│ ├── test_retry.py
│ └── test_token_refresh.py
├── examples/
│ └── quickstart.py
├── docs/
│ └── MIGRATION.md
├── pyproject.toml
├── ruff.toml
├── mypy.ini
└── README.md
Contributing
See CONTRIBUTING.md for guidelines.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docges_api_py-0.1.2.tar.gz.
File metadata
- Download URL: docges_api_py-0.1.2.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
759857f414bfaf86d43a1719535c79de7145ef3483abf82021f26a0dec201990
|
|
| MD5 |
72196e53e32f33edaf61c3d2633dd4ab
|
|
| BLAKE2b-256 |
6592468777ae9b122b4b8797db79484952ae44e2578fa8599a5640eb1095b3ff
|
File details
Details for the file docges_api_py-0.1.2-py3-none-any.whl.
File metadata
- Download URL: docges_api_py-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e01b5eca694bc4730133c2a5204760af49e38bf652533665474ab88eaf0ce7d
|
|
| MD5 |
05e849b2b444621f7e38de1145edd8e6
|
|
| BLAKE2b-256 |
e8c5fecf68105c1180614704cc8a14a840c3ef3f986b8b87413e5645c1265aea
|