Skip to main content

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 loginResponse passed 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/LoadIniCats
  • get_cat_info(sid) — load category children via /Content/LoadChilds

Document Operations

  • upload_file(category_sid, file_path) — upload via /Content/UploadExtended
  • download_content(sid) — download via /Content/Download (returns ResFileDownload)
  • get_document(sid) — deprecated wrapper (calls download_content())

Search

  • search_content(field_values, date_values) — search via /Content/SearchContent

Category Management

  • create_category(parent_sid, name) — create via /Content/CreateCategory
  • rename_category(sid, new_name) — rename via /Content/RenameCategory
  • delete_category(sid) — delete via /Content/DeleteCategory

Document Management

  • remove_document(sid) — remove via /Content/RemoveDocument
  • move_content(content_sid, destination_sid) — move via /Content/Move
  • update_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 loginDocGesData + loginResponse automatically)
        # Some DocGes bridge servers expect both fields in requestModel for Content endpoints.
        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.

For a working end-to-end demo (login + fetch root categories), see examples/initial_categories.py.

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) with httpx.AsyncClient
  • Replaced raw __dict__ serialization with Pydantic v2 models
  • Replaced silent return None with 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docges_api_py-0.1.3.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docges_api_py-0.1.3-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file docges_api_py-0.1.3.tar.gz.

File metadata

  • Download URL: docges_api_py-0.1.3.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.12.10

File hashes

Hashes for docges_api_py-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d09eb7f82abbdf47d647b8204f7083b564cf4c419fc827351e7ada2cb289650d
MD5 36d0c40c08b8853d4ffdf3fc6458bf3a
BLAKE2b-256 79dd63e1f623a5af56f8d73cb9a7da38c3b5214409435b70aa1952eb0f860308

See more details on using hashes here.

File details

Details for the file docges_api_py-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: docges_api_py-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.12.10

File hashes

Hashes for docges_api_py-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d81abb63bfa13555e2af23fb693a03fbffb51d0322c07aa4ca701d4c6f1f2c34
MD5 2c40cdc52903fc4a133608e00d85192c
BLAKE2b-256 78a99b0fc1aa5a39986f429638666965dd99dbaabfbc3d26da8c6ed5ca4012c4

See more details on using hashes here.

Supported by

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