Skip to main content

gramps-api-client

A minimal, dependency-free Python client for Gramps Web API. Standard library only (urllib, json, base64) — no requests, no gramps package needed.

Install

pip install -e .

(Not yet published to PyPI.)

Credentials

The client is built from a single GRAMPS_WEB_API_KEY-shaped string, <REFRESH_TOKEN>*<BASE64URL(URL)>. Mint one once via username/password, either from the CLI:

gramps-api-client generate-key --url https://your-server/api --username youruser
# prompts for the password (getpass, never a CLI flag), prints the key to stdout

or in Python:

from gramps_api_client import Client

api_key = Client.mint_api_key("https://your-server/api", "username", "password")
# store api_key somewhere safe (env var, secrets manager, ...) -- it is a
# long-lived, non-revocable-except-by-password-change credential, treat it
# like a password.

From then on, either construct directly from that key, or set it as GRAMPS_WEB_API_KEY in the environment and use Client.from_env():

import os
from gramps_api_client import Client

os.environ["GRAMPS_WEB_API_KEY"] = api_key
client = Client.from_env()

transactions, total = client.get_transaction_history(after=0)

See Client's and push_transaction()'s docstrings in src/gramps_api_client/client.py for the full credential-tradeoff writeup and conflict-handling semantics.

Origin

This client began life inside the GrampsWebSync addon and the GrampsWebApiDb addon (both gramps-project/addons-source; GrampsWebApiDb is not yet merged upstream), which each needed a dependency-free HTTP client to talk to a Gramps Web API server. This package is now the standalone, canonical home for that code — GrampsWebApiDb vendors a synced copy of client.py, since Gramps addons are self-contained tarballs with no mechanism to declare a pip dependency on an external package.

Development

python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/pytest -v

License

GPL-2.0-or-later, matching the addon code this was extracted from. See LICENSE.

Download files

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

Source Distribution

gramps_api_client-1.2.0.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

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

gramps_api_client-1.2.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file gramps_api_client-1.2.0.tar.gz.

File metadata

  • Download URL: gramps_api_client-1.2.0.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for gramps_api_client-1.2.0.tar.gz
Algorithm Hash digest
SHA256 3a914c349542e5198cccc02cea636db504eb85fa421e19667b8a2f2b4f34088f
MD5 ba1b64cad739928e9a9fd00e47217fd1
BLAKE2b-256 089dd211503cff499dd55cd8583d7728b4f9c9165a7df4b6ccf4bf0450de19c2

See more details on using hashes here.

File details

Details for the file gramps_api_client-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gramps_api_client-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d479925b8f991e7d472b87a735ec99b48b56b35ac5f8f940f1d3bf25e78bc3d6
MD5 8104991dc40242b74110573c2d56f1f1
BLAKE2b-256 09e5b75d321898faf2a80f680c62b42416ba81a9fcbd0d2d268c8f0afed10e8c

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 Sentry Error logging StatusPage Status page