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.

Metadata

Release files for gramps-api-client 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gramps-api-client 1.2.1
File Size Uploaded
gramps_api_client-1.2.1.tar.gz 24.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gramps-api-client 1.2.1
File Interpreter ABI Platform
gramps_api_client-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 43.9 kB

Release files / gramps_api_client-1.2.1.tar.gz

Download URL gramps_api_client-1.2.1.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d08002771e2adca5b912490d0ade36436e542f6122efc94763536de74d994082
BLAKE2b-256 checksum
How to use checksums
2b2e9c7fb14774b9acb5b9de04ab94bac731f08229b93938adaf265af4eedeee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Release files / gramps_api_client-1.2.1-py3-none-any.whl

Download URL gramps_api_client-1.2.1-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c46be2fd94efa3cd311e80cae3fbc2f497121866a4836d5effee81e643d36c7c
BLAKE2b-256 checksum
How to use checksums
a3f0b330bfc04ba1f1edf86f0b497e4bf04a4415c90a728769fd7a7c414bc159
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page