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.0

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.0.tar.gz (12.0 kB view hashes)

Uploaded Source

Built Distribution

pymementodb-1.0.0-py3-none-any.whl (13.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page