Talk:IDigBio API: Difference between revisions
(link to section) |
(move link to examples for elasticsearch) |
||
Line 216: | Line 216: | ||
|https://search.idigbio.org/idigbio/mediarecords/_search | |https://search.idigbio.org/idigbio/mediarecords/_search | ||
|} | |} | ||
=== Elasticsearch - Records === | === Elasticsearch - Records === | ||
Line 269: | Line 267: | ||
"waterbody" | "waterbody" | ||
</pre> | </pre> | ||
See [[iDigBio API Examples#Elasticsearch_Examples]] page for Elasticsearch examples that are specific to iDigBio. | |||
=== Elasticsearch - Media Records === | === Elasticsearch - Media Records === | ||
Line 275: | Line 275: | ||
There are no useful | There are no useful terms for '''Media Records''' queries using Elasticsearch at this time. | ||
See [[iDigBio API Examples#Elasticsearch_Examples]] page for Elasticsearch examples that are specific to iDigBio. | |||
Revision as of 11:57, 9 May 2014
iDigBio API Overview
This document is the starting point for an introduction to the iDigBio Application Programming Interface (API).
The iDigBio API Examples page includes additional examples of how to use the suite of APIs available.
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 the following JSON data:
{ "v1" : "http://api.idigbio.org/v1/", "check" : "http://api.idigbio.org/check", "v0" : "http://api.idigbio.org/v0/" }
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" which return images of width 260 and 600 pixels respectively). Omitting quality will return the full-size high quality image. | http://api.idigbio.org/v1/mediarecords/55dd6860-213d-4478-8bfa-b5486afcffda/media?quality=thumbnail http://api.idigbio.org/v1/mediarecords/55dd6860-213d-4478-8bfa-b5486afcffda/media?quality=web |
Searching iDigBio
At this time the recommended method for searching iDigBio is to use the Portal search, not the API. The portal also provides bulk download capabilities for aquiring larger sets of data. See: https://www.idigbio.org/portal
The iDigBio API does not currently (yet!) provide query/search capabilities. However, the back-end Elasticsearch interface is public-facing and available for use by advanced users and programmers. This is the same interface that is used by the iDigBio Portal search.
Direct queries to the iDigBio Elasticsearch service should be considered an Advanced operation.
An overview of Elasticsearch: http://www.elasticsearch.org/overview/elasticsearch/
The iDigBio search index provides two document types to query on: Records and Media Records. Search results are returned as JSON-formatted documents. Each type can be queried through the following respective URLs:
Query Type | Search URL |
---|---|
Records | https://search.idigbio.org/idigbio/records/_search |
Media Records | https://search.idigbio.org/idigbio/mediarecords/_search |
Elasticsearch - Records
These are the terms currently available in the indexes for Records type of queries to Elasticsearch:
"barcodevalue" "catalognumber" "class" "collectioncode" "collectionid" "collectionname" "collector" "commonname" "continent" "country" "county" "datecollected" "datemodified" "etag" "family" "fieldnumber" "genus" "geopoint" "hasImage" "highertaxon" "infraspecificepithet" "institutioncode" "institutionid" "institutionname" "kingdom" "locality" "maxdepth" "maxelevation" "mediarecords" "mindepth" "minelevation" "municipality" "occurenceid" "order" "phylum" "recordset" "scientificname" "specificepithet" "stateprovince" "typestatus" "uuid" "verbatimlocality" "version" "waterbody"
See iDigBio API Examples#Elasticsearch_Examples page for Elasticsearch examples that are specific to iDigBio.
Elasticsearch - Media Records
https://search.idigbio.org/idigbio/mediarecords/_search
There are no useful terms for Media Records queries using Elasticsearch at this time.
See iDigBio API Examples#Elasticsearch_Examples page for Elasticsearch examples that are specific to iDigBio.