Skip to content

Instantly share code, notes, and snippets.

@jalavik
Created August 1, 2014 09:37
Show Gist options
  • Save jalavik/6527af5edecd188a431e to your computer and use it in GitHub Desktop.
Save jalavik/6527af5edecd188a431e to your computer and use it in GitHub Desktop.
Playing with INSPIRE API
from invenio.invenio_connector import InvenioConnector
# 1. Connect to INSPIRE testing node
inspire = InvenioConnector(url="http://inspireheptest.cern.ch")
# 2. Do a search which returns a list of ids with the phrase "ellis"
res = inspire.search(p="ellis", of="intbitset")
# We asked for an intbitset, which is a comes over the wire as
# binary format - which means we convert it back to a proper intbitset
# structure on our end and cast to to a familiar list.
from invenio.intbitset import intbitset
results = list(intbitset(res))
len(results) # returns now 3205 ids in a list.
# Get data from the first record as a json object
import json
record_as_json = inspire.search(recid=results[0], of="recjson")
record = json.loads(record_as_json)
print(record)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment