Introducing DimCli: a Python CLI for the Dimensions API


For the last couple of months I've been working on a new open source Python project. This is called DimCli  and it's a command-line library aimed at making it simpler to work with the Dimensions Analytics API.

The project is available on Github. In a nutshell, DimCli helps people becoming productive with the powerful scholarly analytics API from Dimensions. See the video below for a quick taster of the functionalities available.

Background

I recenlty joined the Dimensions team, so needed a way to get to grips with their feature-rich API (official docs). So, building DimCli has been a fun way for me to dig into the logic of the Dimensions Search Language (DSL).

Plus, this project gave me a chance to learn more about two awesome Python technologies: JupyterLab and its magic commands, as well as the Python Prompt Toolkit library.

Features, at a glance

  • DimCli is an interactive query console for the Dimensions Analytics API (ps: Dimensions is a world-class research-data platform including information about millions of documents like publications, patents, grants, clinical trials and policy documents.
  • It helps learning the Dimensions Search Language (DSL) thanks to a built-in autocomplete and documentation search mechanism.
  • It handles authentication transparently either via a global user-specific credentials file, or by passing credentials manually (e.g. when used within shared environments).
  • It allows to export results to CSV, JSON and pandas dataframes, hence making it easier to integrate with other data analysis tools.
  • It is compatible with Jupyter, e.g. it includes various magic commands that make it super simple to interrogate Dimensions (various examples here).
>>> import dimcli

>>> dimcli.login(username="mary.poppins", password="chimneysweeper")

>>> dsl = dimcli.Dsl()

>>> res = dsl.query("""search grants for "malaria" return researchers""")

>>> print(res.json)
{'researchers': [{'id': 'ur.01332073522.49',
   'count': 75,
   'last_name': 'White',
   'first_name': 'Nicholas J'},
  {'id': 'ur.01343654360.43',
   'count': 59,
   'last_name': 'Marsh',
   'first_name': 'Kevin'},
  .............
  ],
 '_stats': {'total_count': 8735}}

Feedback

DimCli lives on Github, so for any feedback or bug reports, feel free to open an issue there.

Cite this blog post:


Michele Pasin. Introducing DimCli: a Python CLI for the Dimensions API. Blog post on www.michelepasin.org. Published on May 24, 2019.

Comments:


See also: