Searching the nanopub server

The NanopubClient provides methods for searching the nanopub server. It provides an (uncomplete) mapping to the nanopub server grlc endpoint.

Search on introduced concept

Search for any nanopublications that introduce a concept of the given type, that contain text with the given search term.

from nanopub import NanopubClient
client = NanopubClient()
# Search for nanopublications that introduce a concept that is a ```p-plan:Step```.
results = client.find_things('')

Interpreting search results

Each search method returns a generator of dicts depicting matching nanopublications.

Each dict has the following key-value pairs:

  • date: The date and time the nanopublication was created.

  • description: A description of the nanopublication that was parsed from the nanopublication RDF.

  • np: The URI of the matching nanopublication.

Example results (from NanopubClient.find_nanopubs_with_text('fair')):

>>> print(list(results))
[{'date': '2020-05-01T08:05:25.575Z',
  'description': 'The primary objective of the VODAN Implementation Network is '
                 'to showcase the creation and deployment of FAIR data related '
                 'to COVID-19',
  'np': ''},
 {'date': '2020-05-14T09:34:53.554Z',
  'description': 'FAIR IN community',
  'np': ''}]

Filtering search results for a particular publication key

You can filter search results to publications that are signed with a specific publication key (effectively filtering on publications from a single author). You use the pubkey argument for that. Here is an example with NanopubClient.find_nanopubs_with_text:

from nanopub import NanopubClient, profile
# Search for nanopublications containing the text 'test',
# filtering on publications signed with my publication key.
client = NanopubClient(use_test_server=True)
my_public_key = profile.get_public_key()
results = client.find_nanopubs_with_text('test', pubkey=my_public_key)