Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Memento Client Build Status

The py-memento-client library provides Memento support, as specified in RFC 7089 (

For more information about Memento, see


Just type:

pip install memento_client

and you will have the latest stable release of this library.


This source distribution contains the following folders:

  • memento_client - the memento_client module
  • test - test code for memento_client
  • LICENSE - the license for this source code
  • - this file
  • README.txt - symbolic link to
  • - Python script for building this library

To build this distribution, just type:

python bdist

and it will create a dist folder containing a tar.gz containing this distribution.

To start fresh:

python cleanall

will remove all folders (except .eggs) created during the build/test process.

To run automated tests:

python test

Note that these rely upon live web resources, which may respond differently depending on network connectivity and location.


This simple use case gets a Memento from the default Memento TimeGate for "" on April 24, 2010 at 19:00:00.

import datetime
from memento_client import MementoClient

dt = datetime.datetime(2010, 4, 24, 19, 0)

uri = ""

mc = MementoClient()

memento_uri = mc.get_memento_info(uri, dt).get("mementos").get("closest").get("uri")[0]

One can specify a specific TimeGate like so.

import datetime
from memento_client import MementoClient

dt = datetime.datetime(2010, 4, 24, 19, 0)
uri = ""

timegate = ""

mc = MementoClient(timegate_uri=timegate, check_native_timegate=False)

memento_uri = mc.get_memento_info(uri, dt).get("mementos").get("closest").get("uri")[0]

The get_memento_info method returns a dictionary much like the JSON format described by API documentation at

For example (as run in iPython):

In [48]: mc = MementoClient()

In [49]: mc.get_memento_info("", dt)
{'mementos': {'closest': {'datetime': datetime.datetime(2001, 9, 11, 18, 15, 28),
   'http_status_code': 200,
   'uri': [u'']},
  'first': {'datetime': datetime.datetime(2000, 6, 20, 18, 2, 59),
   'uri': ['']},
  'last': {'datetime': datetime.datetime(2015, 8, 7, 20, 0, 34),
   'uri': ['']}},
 'original_uri': '',
 'timegate_uri': ''}

As shown above, to get the closest memento to the datetime given, use .get("mementos").get("closest").get("uri")[0] in order to extract the first memento URI from the list.

Other information is also available from this data structure. Using .get("mementos").get("first").get("uri")[0] returns the first URI-M known for the given URI-R. This data structure also contains the "timegate_uri" refering to the URI-G that was used for datetime negotiation during this session. So backtracking is possible, the "original_uri" key is available to extract the URI-R again.

If the TimeGate has no Memento to return (i.e. the archive has no Memento for that URI-R), then the data structure returned only contains the "original_uri" and "timegate_uri" keys, as show below (as run in iPython):

In [46]: mc = MementoClient(timegate_uri="")

In [47]: mc.get_memento_info("", dt)
{'original_uri': '',
 'timegate_uri': ''}


A Memento Client Library in Python



Contributors 4



You can’t perform that action at this time.