SDKs overview

Crossref Metadata Search offers various Software Development Kits (SDKs) and libraries designed to streamline interaction with its API. These tools cater to different programming environments, abstracting the complexities of HTTP requests, response parsing, and rate limiting. The primary goal of these SDKs is to enable developers and researchers to programmatically access and manipulate scholarly metadata, including Digital Object Identifiers (DOIs), publication details, and citation information, as outlined in the official Crossref REST API documentation.

The availability of both official and community-contributed libraries reflects the diverse needs of the academic and development communities. While official SDKs are maintained directly by Crossref, community libraries often provide specialized functionalities or integrations with specific data analysis frameworks. Users can query the Crossref API directly using standard HTTP clients, but SDKs typically offer a more idiomatic and efficient approach, reducing boilerplate code and potential errors.

For instance, an SDK might handle URL construction for complex queries, automatically paginate results, or convert JSON responses into language-specific data structures. This simplifies the development process, allowing users to focus on data utilization rather than API mechanics. The Crossref API itself is a RESTful interface, making it accessible via any language capable of making HTTP requests, as described in general principles of RESTful web services on MDN Web Docs.

Official SDKs by language

Crossref provides official tools and recommended libraries primarily for Python and R, which are widely used in academic research and data science. These tools are designed to offer robust and reliable access to the Crossref Metadata Search API.

Language Package/Tool Install Command Maturity
Python habanero pip install habanero Stable, actively maintained
R rcrossref install.packages("rcrossref") Stable, actively maintained
Command Line crossref-cli pip install crossref-cli Stable

The habanero Python library provides a comprehensive interface for the Crossref API, supporting various endpoints such as works, members, and journals. It handles API authentication, rate limiting, and result parsing, offering a Pythonic way to interact with Crossref data. Similarly, rcrossref in R integrates seamlessly with the R ecosystem, allowing researchers to fetch and analyze Crossref data directly within their R scripts and environments. The crossref-cli offers a command-line interface for quick queries and data retrieval without needing to write code.

Installation

Installing the official Crossref SDKs and tools typically involves using standard package managers for each respective language environment.

Python (habanero)

To install the habanero library for Python, use pip, the Python package installer:

pip install habanero

This command downloads and installs the latest version of habanero and its dependencies from PyPI. Ensure you have Python and pip installed on your system. For more detailed installation instructions and system requirements, refer to the Crossref Python documentation.

R (rcrossref)

For R users, the rcrossref package can be installed directly from CRAN within your R environment:

install.packages("rcrossref")

After installation, you can load the package using library(rcrossref) to begin using its functions. The Crossref R documentation provides further guidance on installation and usage.

Command Line (crossref-cli)

The crossref-cli tool, also available via pip, provides a convenient command-line interface:

pip install crossref-cli

Once installed, you can use commands like crossref-cli works --query "data science" to search for works without writing a script. This tool is useful for quick data retrieval or scripting in shell environments without requiring extensive Python knowledge.

Quickstart example

This quickstart example demonstrates how to use the habanero Python library to search for works and retrieve metadata from Crossref's API.

Python example with habanero

First, ensure you have habanero installed (pip install habanero). Then, you can use the following Python code to perform a search:

from habanero import Crossref

# Initialize the Crossref client
cr = Crossref()

# Perform a search for works containing "artificial intelligence"
# Limit to 5 results for brevity
search_results = cr.works(query = "artificial intelligence", limit = 5)

# Print basic information for each result
if search_results and 'message' in search_results:
    for item in search_results['message']['items']:
        title = item.get('title', ['No Title'])[0]
        doi = item.get('DOI', 'No DOI')
        print(f"Title: {title}")
        print(f"DOI: {doi}")
        print("---------------------")
else:
    print("No results found or an error occurred.")

This script initializes the Crossref client, performs a query for scholarly works related to "artificial intelligence," and then iterates through the top 5 results to print their titles and DOIs. The habanero library handles the underlying API request, JSON parsing, and error handling, simplifying the interaction for the developer.

R example with rcrossref

For R users, a similar search can be performed using the rcrossref package:

# Install and load rcrossref if you haven't already
# install.packages("rcrossref")
library(rcrossref)

# Perform a search for works containing "machine learning"
# Limit to 3 results for brevity
search_results <- cr_works(query = "machine learning", limit = 3)

# Print basic information for each result
if (!is.null(search_results) && nrow(search_results) > 0) {
  for (i in 1:nrow(search_results)) {
    title <- search_results$title[i]
    doi <- search_results$doi[i]
    cat(paste0("Title: ", title, "\n"))
    cat(paste0("DOI: ", doi, "\n"))
    cat("---------------------\n")
  }
} else {
  cat("No results found or an error occurred.\n")
}

This R script uses cr_works to query for "machine learning" related publications, then prints the titles and DOIs of the first three results. The outputs demonstrate how both libraries provide structured access to Crossref metadata, enabling integration into data analysis and application development.

Community libraries

Beyond the officially supported SDKs, the Crossref API's open nature has fostered the development of various community-contributed libraries and tools. These libraries often extend functionality, integrate with specific platforms, or offer alternative interfaces based on community preferences.

  • JavaScript/Node.js Libraries: While Crossref does not officially maintain a JavaScript SDK, developers can use standard HTTP client libraries like axios or node-fetch to interact with the REST API. For example, a Node.js application could use axios to make requests and process JSON responses, similar to how it would interact with any other asynchronous JavaScript API.
  • Other Language Bindings: Depending on the specific programming language, developers might find community-maintained wrappers or helpers. These can be discovered through package repositories (e.g., PyPI for Python, CRAN for R, npm for Node.js) by searching for "Crossref" or "DOI" related packages.
  • Data Science and Visualization Tools: Some community tools focus on integrating Crossref data directly into data science workflows, offering functions for data cleaning, transformation, and visualization alongside retrieval. These might build upon the official SDKs or implement direct API calls.

When considering community libraries, it is advisable to check their maintenance status, documentation, and community support to ensure they are suitable for your project's requirements. The Crossref API is well-documented, allowing developers to build custom integrations if existing libraries do not meet specific needs, as detailed in the comprehensive Crossref API reference.