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-0.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-0.1.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gramps_api_client-0.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-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3fd0a1edd094a37ef8d9446285bc6589336f1a506510134f7526bddf7107354b
MD5 0a6553bb636794eb587be09acf0ee79d
BLAKE2b-256 a53a61a523ba3ed1899d783a05b2efa00a513dbbed253bf8a58304f28473761d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gramps_api_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d9c3a94a467cce8e6e9760947410f8fda747d9b91892178f59d547eb07ca517
MD5 b53f8da9b57e6ec5c3b953ab23d21c24
BLAKE2b-256 40eefa25896fd82c285dd9c78e74341ebbf4bd76d5153e7bface8a7d149cd712

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