API

The Python code examples below use the third-party package requests.

Fetch publication by PMID of DOI

URL /publication
Method POST
Payload (JSON body) { "identifier": "{PMID or DOI}", "labels": {"{labelname}": "{optional qualifier}"}}
Description The server is instructed to to fetch publication data from PubMed or Crossref given a PubMed identifier (PMID) or Digital Object Identifier (DOI). This API call fetches only one publication at a time. The labels item in the payload is optional.
Example code
import json
import requests

url = "http://your-server/api/publication"
headers = {'X-API-key': "my-API-key"}

# PMID identifier in this example.
data = dict(identifier="1557129", labels={"MyLab": "Collaboration"})

response = requests.post(url, headers=headers, json=data)

if response.status_code != 200:
    raise ValueError(f"Error {response.status_code}: {response.reason}")
else:
    print(json.dumps(response.json(), indent=2))

Change labels for a publication

URL /publication/{iuid}/labels
Method POST
Payload (JSON body) { "labels": {"{labelname}": "{optional qualifier}"}}
Description Change the labels of the given publication. The labels provided must contain all labels to be set for the publication among those that the account specified by the API key can edit. That is, if the account has three labels associated with it, and only two of those are specified, then the third will be removed if it was already present for the publication.
Example code
import json
import requests

url = "http://your-server/api/publication/{publication-iuid}/labels"
headers = {'X-API-key': "my-API-key"}

data = dict(labels={"MyLab": "Service"})

response = requests.post(url, headers=headers, json=data)

if response.status_code != 200:
    raise ValueError(f"Error {response.status_code}: {response.reason}")
else:
    print(json.dumps(response.json(), indent=2))

Publications 7.0.1