Words / posts / Data & Visualisation/ Research Analytics
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 called DimCli. 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 become productive with the powerful scholarly analytics API from Dimensions. See the video below for a quick overview of the available functionality.
Background
I recently joined the Dimensions team, so I needed a way to get to grips with their feature-rich API (official documentation). 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
-
Interactive Query Console: DimCli provides an interactive query console for the Dimensions Analytics API. Dimensions is a world-class research data platform including information about millions of documents such as publications, patents, grants, clinical trials, and policy documents.
-
Learning Tool: It helps you learn the Dimensions Search Language (DSL) thanks to built-in autocomplete and documentation search mechanisms.
-
Seamless Authentication: It handles authentication transparently either via a global user-specific credentials file or by passing credentials manually (e.g., when used within shared environments).
-
Flexible Export Options: It allows you to export results to CSV, JSON, and pandas dataframes, making it easier to integrate with other data analysis tools.
-
Jupyter Compatible: It includes various magic commands that make it super simple to interrogate Dimensions within Jupyter notebooks (various examples here).
Example Usage
>>> 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 and Contributions
DimCli lives on GitHub, so for any feedback or bug reports, feel free to open an issue there. Contributions are also welcome!

Cite this post
Michele Pasin. Introducing DimCli: a Python CLI for the Dimensions API. Blog post on www.michelepasin.org, 24 May 2019.
Talk back / comments via github
