SDKs overview

iDigBio provides access to a comprehensive database of digitized natural history specimens through its API, which is supported by both official and community-developed SDKs and libraries. These tools abstract the underlying HTTP requests and JSON parsing, allowing developers to interact with the iDigBio data portal using familiar programming constructs. The primary official SDKs are available for Python and R, catering to common scientific computing and data analysis environments iDigBio API documentation. Community contributions further extend this ecosystem, offering utilities and integrations in various other languages and platforms.

The iDigBio API itself is a RESTful interface, returning data primarily in JSON format. Understanding RESTful API principles, as outlined by sources like the Mozilla Developer Network's guide to REST, can enhance the use of these SDKs. The API allows for complex queries, including filtering by scientific name, geographic location, date, and institution code, facilitating detailed data retrieval for biodiversity research and ecological studies iDigBio API usage examples.

Official SDKs by language

iDigBio maintains official Software Development Kits (SDKs) to streamline interaction with its API. These SDKs are designed to provide a consistent and documented interface for common data retrieval tasks.

Python

The official Python SDK for iDigBio simplifies data access for Python developers. It typically provides functions to construct queries, execute searches, and parse the JSON responses into Python objects, such as lists of dictionaries or custom data models. This allows for direct integration into Python-based data analysis pipelines, web applications, or scripting for automated data collection.

R

For users in the R statistical computing environment, an official R package facilitates interaction with the iDigBio API. This package is particularly useful for researchers and data scientists who primarily work with R for statistical analysis, visualization, and ecological modeling. It typically offers functions that mirror the API's capabilities, returning data in R-friendly formats like data frames.

Official SDKs Table

Language Package Name Install Command Maturity
Python pyidigbio (unofficial, widely used) pip install pyidigbio Community-maintained
R ridigbio (unofficial, widely used) install.packages("ridigbio") Community-maintained

Note: While iDigBio provides extensive API documentation and examples, specific "official" SDKs in the traditional sense (directly maintained and published by iDigBio as core products) are less emphasized than robust community-contributed libraries that closely follow the API specification. The listed packages are widely adopted and function as de facto SDKs for their respective languages iDigBio API community resources.

Installation

The installation process for iDigBio-related libraries follows standard practices for Python and R packages. Ensure you have the respective language environment set up before proceeding.

Python Installation

To install the pyidigbio package, open your terminal or command prompt and execute the following command. This command uses pip, the standard package installer for Python Python packaging documentation:

pip install pyidigbio

It is recommended to use a virtual environment to manage dependencies for your Python projects:

python -m venv idigbio_env
source idigbio_env/bin/activate  # On Windows: .\idigbio_env\Scripts\activate
pip install pyidigbio

R Installation

For R, the ridigbio package can be installed directly from CRAN (Comprehensive R Archive Network) within your R console:

install.packages("ridigbio")

If you encounter issues, ensure your R installation is up to date. For more advanced package management in R, consider using tools like devtools for installing from GitHub or packrat for project-specific dependency management.

Quickstart example

These quickstart examples demonstrate basic data retrieval using the Python and R libraries. They illustrate how to query the iDigBio API for occurrence records.

Python Quickstart

This Python example uses the pyidigbio library to search for occurrence records of a specific genus, Panthera, and print the total number of results found.

import pyidigbio

def get_panthera_occurrences():
    # Initialize the iDigBio client
    client = pyidigbio.IDigBioClient()

    # Define query parameters
    # Searching for occurrences where the genus is 'Panthera'
    query = {
        "genus": "Panthera"
    }

    # Execute the search for occurrences
    # 'limit' can be adjusted, 'fields' specifies desired return fields
    results = client.search_records(rq=query, limit=10, fields=["uuid", "scientificname", "country"])

    print(f"Found {results['itemCount']} records for Panthera.")
    if results['itemCount'] > 0:
        print("First 5 records:")
        for i, record in enumerate(results['records'][:5]):
            print(f"  UUID: {record.get('uuid')}, Scientific Name: {record.get('scientificname')}, Country: {record.get('country')}")

if __name__ == "__main__":
    get_panthera_occurrences()

R Quickstart

This R example uses the ridigbio package to search for occurrence records of the genus Panthera and display the first few results in a data frame.

# Install and load the ridigbio package if not already installed
# install.packages("ridigbio")
library(ridigbio)

# Define query parameters
# Searching for occurrences where the genus is 'Panthera'
query_params <- list(genus = "Panthera")

# Execute the search for occurrences
# 'limit' can be adjusted for the number of records to retrieve
# 'fields' specifies desired return fields
panthera_records <- idig_search_records(rq = query_params, limit = 10, fields = c("uuid", "scientificname", "country"))

# Print the total number of records found
cat(paste0("Found ", panthera_records$itemCount, " records for Panthera.\n"))

# Display the first few records
if (panthera_records$itemCount > 0) {
  cat("First 5 records:\n")
  print(head(panthera_records$data, 5))
}

Community libraries

Beyond the primary Python and R interfaces, the iDigBio ecosystem benefits from various community-contributed libraries and tools. These libraries often address specific use cases, integrate with other scientific platforms, or provide functionalities in different programming languages.

  • JavaScript/Node.js Libraries: While no single official JavaScript SDK exists, developers can interact with the iDigBio API directly using standard HTTP request libraries like axios or the built-in fetch API. This allows for front-end web applications or Node.js backends to consume iDigBio data. A basic example might involve constructing a URL with query parameters and parsing the JSON response.
  • Data Visualization Tools: Some community efforts focus on integrating iDigBio data directly into visualization platforms or generating specific types of plots (e.g., species distribution maps) using libraries like ggplot2 in R or matplotlib/seaborn in Python after data retrieval.
  • Workflow Integrations: Users in bioinformatics or ecological modeling might develop scripts or tools that chain iDigBio data retrieval with other data sources or analytical workflows, often leveraging common data science libraries.
  • Language-Specific Wrappers: Developers in other languages (e.g., Java, C#, Go) might create thin wrappers around the iDigBio REST API to facilitate integration within their respective environments. These are typically found in personal repositories on platforms like GitHub and may not have the same level of maintenance or documentation as the more established Python and R tools.

For a comprehensive list of community resources and tools, including those that interact with iDigBio, refer to the iDigBio community resources section within their API documentation. Many scientific organizations also publish their code on platforms like GitHub, which can be a valuable source for finding additional community tools.