A simple Python client to interact with Gramps Web API
Project description
Gramps Web API Client
A simple Python client based on requests
for interacting with a Gramps Web API server.
Warning
This is an experimental project for advanced users. The goal is to allow powerful batch operations on Gramps objects via the API. But only use it if you know what you are doing – you can easily break your Gramps database with this tool!
Quick start
First, instantiate the API instance:
from gramps_web_api_client import API
api = API(
host="https://my-gramps-web-instance.com",
basic_auth("my_user", "my_password")
)
Methods currently implemented:
Method | description |
---|---|
api.iter_people() |
Generator iterating over people |
api.iter_events() |
Generator iterating over events |
api.iter_places() |
Generator iterating over places |
api.get_person(handle) |
Get a single person by handle |
api.get_event(handle) |
Get a single event by handle |
api.get_place(handle) |
Get a single place by handle |
api.update_person(handle, data) |
Update a single person |
api.update_event(handle, data) |
Update a single event |
api.update_place(handle, data) |
Update a single place |
api.create_person(data) |
Create a new person |
api.create_event(data) |
Create a new evebt |
api.create_place(data) |
GCreateet a new place |
In all cases, data
are dictionaries for JSON objects following the Gramps Web API conventions.
Examples
Removing all citations from an existing person:
api.update_person("somehandle", {"citation_list": []})
In this example, all other properties of the person (except citations) will remain the same.
Creating a new place:
api.create_place({
"name": {
"_class": "PlaceName",
"value": "Gotham City"
}
})
Iterating over people and adding a citation if a condition is satisfied:
for person in api.iter_people():
try:
surname = person["primary_name"]["surname_list"][0]["surname"]
except (KeyError, IndexError):
continue
if surname == "Garner":
api.update_person(
person["handle"],
{"citation_list": person["citation_list"] + ["some_citation_handle"]}
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gramps-web-api-client-0.1.tar.gz
.
File metadata
- Download URL: gramps-web-api-client-0.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb6bf30e75a84d3e676edd3952e80f9955bb86546aefe251335f09368c89250b |
|
MD5 | 113c79671ba910fdfeb9282f94906f42 |
|
BLAKE2b-256 | 342aae978c219986e046b44036ff294dd1d673217b6f394f136b277938d0af14 |
File details
Details for the file gramps_web_api_client-0.1-py3-none-any.whl
.
File metadata
- Download URL: gramps_web_api_client-0.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94ef0f42fb82047c7d0890d7d81845aff4ca1c8904d9d8738cddaa0403510db1 |
|
MD5 | d2b1860223c278de47399f97dc8fea7a |
|
BLAKE2b-256 | d5be155ba23e6ced37500323a6820a2f5b710eef96d53e0abcc6668f8560a93f |