SDKs overview

The Global Biodiversity Information Facility (GBIF) offers Software Development Kits (SDKs) and libraries to facilitate programmatic access to its global biodiversity data. These tools abstract the complexity of the GBIF API, allowing developers and researchers to query, filter, and retrieve species occurrence data, taxonomic information, and other biodiversity-related datasets directly within their preferred programming environments. While GBIF primarily develops official SDKs for R and Python, community-contributed libraries extend support and offer specialized functionalities.

Using SDKs can streamline workflows for tasks such as downloading large datasets for ecological modeling, integrating species checklists into conservation planning tools, or building applications that visualize biodiversity trends. The GBIF API itself is a RESTful interface, and the SDKs handle HTTP requests, JSON parsing, and pagination, reducing boilerplate code for common operations. Developers can refer to the GBIF developer summary for an overview of available tools and API endpoints.

Official SDKs by language

GBIF maintains two primary official SDKs, catering to the scientific computing communities that frequently work with biodiversity data:

  • rgbif (R): A comprehensive package for the R statistical programming language, widely used in ecology and environmental science. It provides functions for searching occurrences, species, datasets, and publishing organizations, as well as accessing images and multimedia associated with records. The rgbif package on CRAN offers details on its latest version and dependencies.
  • pygbif (Python): The official Python client library, enabling Python developers to interact with the GBIF API. It supports similar functionalities to rgbif, including searching for occurrences, taxa, datasets, and publishers, making it suitable for data analysis, web development, and scripting applications. Further information is available on the pygbif PyPI page.

These SDKs are actively maintained and updated to reflect changes in the GBIF API and to incorporate new features or data types. They adhere to the API's rate limits, which are generous for research use, as noted in the GBIF developer experience notes.

Language Package Name Installation Command Maturity
R rgbif install.packages("rgbif") Stable, Actively Maintained
Python pygbif pip install pygbif Stable, Actively Maintained

Installation

Installing GBIF SDKs is typically straightforward using the standard package managers for R and Python.

R (rgbif)

To install the rgbif package in R, open your R console and execute the following command:

install.packages("rgbif")

After installation, load the package into your current R session to begin using its functions:

library(rgbif)

Ensure you have a recent version of R installed. The official R Installation and Administration manual provides detailed instructions for various operating systems.

Python (pygbif)

For Python, pygbif can be installed using pip, the Python package installer. Open your terminal or command prompt and run:

pip install pygbif

You can then import the necessary modules in your Python script:

import pygbif
from pygbif import occurrences

It is generally recommended to use a virtual environment for Python projects to manage dependencies. Information on setting up Python virtual environments is available in the official Python documentation.

Quickstart example

Here are quickstart examples demonstrating how to retrieve species occurrence data using both rgbif in R and pygbif in Python.

R (rgbif) example: Searching for a species' occurrences

This example searches for occurrence records of the species Panthera tigris (tiger) and displays the first few results.

# Load the rgbif library
library(rgbif)

# Search for occurrences of 'Panthera tigris'
tiger_occurrences <- occ_search(scientificName = "Panthera tigris", limit = 10)

# Print the summary of the search results
print(tiger_occurrences)

# Access the data frame of occurrences
head(tiger_occurrences$data)

The occ_search function allows various parameters for filtering, such as geographic coordinates, year ranges, and dataset keys. More advanced usage patterns are covered in the rgbif getting started guide.

Python (pygbif) example: Retrieving dataset metadata

This Python example demonstrates how to retrieve metadata for a specific dataset using its UUID. We will use a placeholder UUID; in a real scenario, you would use an actual dataset identifier from GBIF.

import pygbif
from pygbif import datasets

# Replace with a real GBIF dataset UUID
dataset_uuid = "7e50257e-77d9-4809-af0e-3ffc080c98f5" # Example: 'Bird observations from a specific region'

# Retrieve dataset metadata
dataset_meta = datasets.get(dataset_uuid)

# Print key information from the metadata
if dataset_meta:
    print(f"Dataset Title: {dataset_meta.get('title')}")
    print(f"Dataset Description: {dataset_meta.get('description', '')[:150]}...")
    print(f"Publishing Organization: {dataset_meta.get('publishingOrganizationTitle')}")
    print(f"Record Count: {dataset_meta.get('occurrenceCount')}")
else:
    print(f"Dataset with UUID {dataset_uuid} not found.")

This snippet illustrates fetching structured data, which can be useful for understanding the provenance and scope of biodiversity records. Detailed API endpoints and parameters for such calls are documented in the GBIF API Swagger YAML specification.

Community libraries

Beyond the official SDKs, the GBIF ecosystem benefits from community-driven libraries and tools that extend functionality or integrate GBIF data into other platforms. These libraries are developed and maintained independently by researchers and developers, often addressing specific use cases or providing interfaces in additional programming languages.

Examples of community contributions may include:

  • Data visualization tools: Libraries that specialize in mapping species distributions or visualizing biodiversity trends using GBIF data.
  • Tools for specific ecological analyses: Packages designed to perform niche modeling, diversity indices calculation, or conservation prioritization using GBIF occurrence records.
  • Web frameworks integrations: Components or plugins that simplify the display of GBIF data within popular web development frameworks.

While GBIF encourages and supports community contributions, the support and maintenance cycles for these libraries may vary. Developers interested in exploring or contributing to community efforts can often find relevant projects on platforms like GitHub or through discussions within the GBIF community forums. The GBIF developer page often highlights notable community tools or provides links to resources for discovering them.