Skip to main content

Memento Database Python SDK

Project description

Memento Database Python SDK

This is the python SDK for Memento Database API. Pull requests and bug reports are welcomed.

Latest Version

The latest version of Memento Database API SDK is PyMementoDB-1.0.2

Installation

Install using pip :

$ pip install pymementodb

Get access tokens

Install desktop application and get authorisation token in Account menu.

Include memento in your application

from pymementodb import Memento

Get memento instance

To get an instance of memento just provide the access token.

server = Memento('<access token>')

Optionally, the custom server can be specified.

server = Memento('<access token>', '<memento token>')

Usage

Once you have the access token you can make the calls to the server. Get the memento instance and set the access token and then make authorized calls.

List library info

You can use list_libraries() to list all available libraries and their main info.

server = Memento('<access token>')
libs_info = server.list_libraries()

Get Library

You can use get_library() to get the specific library. It returns a Library object.

server = Memento('<access token>')
lib = server.get_library('<library id>')

Get Entries

You can use get_entries() to get entries of the library. It returns a list of Entry objects.

server = Memento('<access token>')
lib = server.get_entries('<library id>')

Optional parameters:

  • limit (int, all by default) - limits the query result to the limit number of the newest entries
  • field_ids (list of ints, all by default) - include only the specified entry field values in results
  • start_revision (int, oldest by default) - return entries since the provided library revision only

Get Entry

You can use get_entry() to get a specific entry. It returns an Entry object.

server = Memento('<access token>')
entry = server.get_entry('<library id>', '<entry id>')

Create Entry

Use create_entry() to create a new entry. It returns an Entry object that represents the newly created entry.

'<field values>' is the list of dictionaries: [{'id': <field id>, 'value': <field value>}, ...]. Datetime fields to be provided in the '2023-08-31T16:47:00+00:00' format.

server = Memento('<access token>')
new_entry = server.create_entry('<library id>', '<field values>')

Edit Entry

Use edit_entry() to modify a specific entry. It returns an Entry object that represents the modified entry.

server = Memento('<access token>')
server.edit_entry('<library id>', '<entry id>', '<field values>')

Delete Entry

Use delete_entry() to delete a specific entry.

server = Memento('<access token>')
lib = server.delete_entry('<library id>', '<entry id>')

Objects

All objects are derived from dataclasses.dataclass.

Library

Properties:

  1. id
  2. createdTime
  3. modifiedTime
  4. fields
  5. name
  6. owner
  7. revision
  8. size

Entry

Properties:

  1. id
  2. createdTime
  3. modifiedTime
  4. fields
  5. status
  6. author
  7. revision
  8. size

Methods:

  1. get_field_value(field_id) - returns the value of the field.

Field

Properties:

  1. id
  2. name
  3. options
  4. order
  5. role
  6. type

License

MIT

Project details


Download files

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

Source Distribution

pymementodb-1.0.2.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

pymementodb-1.0.2-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file pymementodb-1.0.2.tar.gz.

File metadata

  • Download URL: pymementodb-1.0.2.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for pymementodb-1.0.2.tar.gz
Algorithm Hash digest
SHA256 668d949f27fb1db1d35e0a50722aae2287ed0ddf384d01eb907de6f479869f64
MD5 75807fb0b8e45a7ed50d28bc795600f7
BLAKE2b-256 1bb7ac67ee304265ebac91d0805acf3e4d12989b61cbb12ba2bb3fde37da7bbe

See more details on using hashes here.

File details

Details for the file pymementodb-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pymementodb-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for pymementodb-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 77b8e18d28b2e3f4be02762c32308d98f7b70ef63d91011d2a56b3484017974d
MD5 a14a48f2fdcc57155cd753d172cf9d3c
BLAKE2b-256 d5ca48019f809a663dcfa52ab93e5caac03a2dffd423ff9e5310ea64bae62f1e

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