IDigBio API

From iDigBio
Jump to navigation Jump to search


iDigBio API Documentation

This document is the starting point for an introduction to the iDigBio suite of APIs.

The iDigBio API Examples page includes additional examples of how to use the APIs.

iDigBio API Basics and Quick Start

The iDigBio API is a RESTful pattern HTTP API that primarily delivers data in JSON format. Currently the API supports GET requests or data read operations only.

API URLs (endpoints) have several parameters in them, and typically follow the form of

<base url>/<version>/<type>/<id> 

For example:

 Using the following parameters for an API request

 base url = http://api.idigbio.org
 version = v1
 type = records
 id = 00000230-01bc-4a4f-8389-204f39da9530

 would produce a URL of the following form

 "http://api.idigbio.org/v1/records/00000230-01bc-4a4f-8389-204f39da9530" 


There are two major types of API enpoints:

  • Collection - which is a group endpoint that returns lists of multiple records. These urls are of the form <base url>/<version>/<type>, such as http://api.idigbio.org/v1/mediarecords/ . Additionally, a collection endpoint can contain optional query parameters, ?limit indicates the number of records returned in the collection and defaults to 1000 and the ?offset parameter which indicates the number of records to skip before returning a set of records and defaults to 0. If a collection endpoint request finds more then the set limit of records it will include a "next page" link to retrieve the next set of records in the collection. See the endpoint properties section for more information on properties returned.
  • Entity - A single item endpoint which returns all of the data available about an object. These urls are of the form <base url>/<version>/<type>/<id> like the example used above.

NOTE: at this time the API does not support search capabilities on entities or collections.

Examples:

collection:
"http://api.idigbio.org/v1/mediarecords"
collection w/ optional query parameters:
"http://api.idigbio.org/v1/mediarecords?limit=100&offset=100"
entity:
"http://api.idigbio.org/v1/mediarecords/00000230-01bc-4a4f-8389-204f39da9530"


Endpoint Basics

Calling just the base URL will return a list of API version endpoints. For example a GET request to "http://api.idigbio.org" will return JSON data like the example below.

{
v1: "http://api.idigbio.org/v1/",
v0: "http://api.idigbio.org/v0/"
}

and calling a version URL endpoint will return a list of major data types available for that version, such as:

{
recordsets: "http://api.idigbio.org/v1/recordsets",
records: "http://api.idigbio.org/v1/records",
mediarecords: "http://api.idigbio.org/v1/mediarecords",
mediaaps: "http://api.idigbio.org/v1/mediaaps",
people: "http://api.idigbio.org/v1/people",
organizations: "http://api.idigbio.org/v1/organizations",
taxa: "http://api.idigbio.org/v1/taxa",
aggregates: "http://api.idigbio.org/v1/aggregates"
}


Endpoint Properties

The iDigBio API tries to follow the REST paradigm's HATEOAS (Hypermedia as the Engine of Application State) model, which basically means that within each API endpoint we provide a list of relevant links to further API actions. This list typically is stored in "idigbio:links"

Other system level property names include

For Entity Endpoints:

  • etag - the opaque identifier assigned to a specific version of a resource found at a URL
  • dateModified - The date the entity was modified
  • version - The entity's version number
  • type - The entity's type
  • uuid - The entity's uuid
  • siblings - Any siblings the entity may have as a dictionary of uuids
  • recordIds - A list of lookup keys for the entity
  • data - The entity's encapsulated data element

For Collection Endpoints:

  • items - the list of items in the collection
  • itemCount - the number of total items in the collection


Entity Data

The data element for each entity can include any number of key-value pairs containing properties of the entity, including potentially values that are themselves lists or dictionaries. Typical key namespaces that might appear in each type are (in order of decreasing usefulness):

  • Records: typically contains darwin core elements ( http://rs.tdwg.org/dwc/terms/index.htm ) describing a physical specimen, may also contain custom elements or elements defined by other standards.
  • Mediarecords: typically contains Audubon Core elements ( http://terms.gbif.org/wiki/Audubon_Core_Term_List_(1.0_normative) ) describing a media capture event, may also contain custom elements or elements defined by other standards.
  • Publishers: A top level entity for the data ingestion process, each publisher contains metadata about a piece of publishing software such as an IPT installation or Symbiota portal.
  • Recordsets: An entity largely derived from the publisher metadata. These serve as the join point between multiple data files for single collection, and all records and mediarecords in iDigBio are expected to be associated with a recordset that links them to a source.
  • All other entities exposed via the api are either internal only concepts with no fixed definition, or are unused.


Available API endpoints

All endpoints follow the form of "http://api.idigbio.org/{api_version}{endpoint}"

Endpoint Method API Versions Available Description
'/mediarecords' GET v0, v1 returns a collection of media record IDs
'/mediarecords/{ID}' GET v0, v1 returns a media record with the specific entity ID
'/mediarecords/{ID}/media' GET v0, v1 returns an image associated with the specific entity ID
'/records' GET v0, v1 returns a collection of record IDs
'/records/{ID}' GET v0, v1 returns a record with the specific entity ID
'/records/{ID}/media' GET v0, v1 returns an image associated with the specific entity ID
'/publishers' GET v0, v1 returns a collection of publisher IDs
'/publishers/{ID}' GET v0, v1 returns a publisher with specific entity ID
'/recordsets' GET v0, v1 returns a collection of recordset IDs
'/recordsets/{ID}' GET v0, v1 returns a recordset with specific entity ID


Optional API Parameters

Parameter Endpoint type Values Description Example
limit Collections [1-] Controls the number of records returned by a collection url. Large numbers may cause requests to time out, but are significantly more efficient when attempting to query large numbers of records. http://api.idigbio.org/v1/mediarecords?limit=100
offset Collections [0-] Controls how many records to skip forward when paging through the API. Large offsets are extremely inefficient, so combinations of small limits and large offsets may cause requests to fail. http://api.idigbio.org/v1/mediarecords?limit=100&offset=100
version Entities [0-current version], -1 for latest version Return a specific version of a record from the data store. Can be used to query historical data for iDigBio records. http://api.idigbio.org/v1/records/c93ebbee-64b5-4452-9e80-93bbfb11b815?version=0
quality Entities ["thumbnail", "web"], Specifiy the quality of the image returned from the API (valid values are "thumbnail" and "web"). https://api.idigbio.org/v1/records/4e98d066-f35f-4cc0-ad7c-b5b5f2175521/media?quality=thumbnail https://api.idigbio.org/v1/mediarecords/4c4c5008-5444-4348-85f5-34112b46169b/media?quality=web

Searching iDigBio

While the iDigBio API does not currently support query/search capabilities, we do offer a public facing Elastic Search server which is used to implement the iDigBio Portal search.

The Elastic Search server is located at:

https://search.idigbio.org/

This server provides a Lucene style index for querying which returns JSON formatted data:

The index provides two document types to query on; Records and Media. Each type can be queried through the following respective URLs:

https://search.idigbio.org/idigbio/records/_search

https://search.idigbio.org/idigbio/media/_search

More information about querying an Elastic Search server can be found at: http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/query-dsl.html