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.1.0.tar.gz (22.0 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.1.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gramps_api_client-1.1.0.tar.gz
  • Upload date:
  • Size: 22.0 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.1.0.tar.gz
Algorithm Hash digest
SHA256 4246477ef6a7f47bdb50c469bfb4abfcad599158aeaa3ab3587cef5ebdb42d55
MD5 0532bbb05e314507656c54087fe3fc1b
BLAKE2b-256 b8189d56852050f3c8c059707f723349ff26d8691455114883661d788f373c76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gramps_api_client-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 793ffa953f834318fed814a639a5a5a0215a4c1426407506398e3c6621c484c5
MD5 d7c910588dbd49361f1aacfd0f209121
BLAKE2b-256 f57a9791af03b5c3261091f23eb34f945fcb486f4ae243436cafab3c4020eb78

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