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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pymementodb-1.0.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for pymementodb-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e1487e4129cc7d0ceb35c0efec9dcafb71d8cd9241aa96ae693578007214c855
MD5 9dbac18b0b753b74cdf39d2078513d8a
BLAKE2b-256 f3081aea93113c4d6a370e1c5117232281164f74aad78f18caf32b1809e019f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymementodb-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for pymementodb-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c26f5d89957214623939693d0b0eb5754d3f609ac2aba2661f03816ede87360e
MD5 c22fe155208c57f104e72bcf6049a0e5
BLAKE2b-256 6f30e462fd8d49d10099ee973df204b3953db1fb9ea72c7879ad4c30e7c786dd

See more details on using hashes here.

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