Note that this service is still experimental.
This is a simple service to provide access to BCI data as Javascript Object Notation (JSON). The endpoint for the service is: http://biocol.org/json
Please raise issues and suggestions on the Google Group.
There are two methods you can call on this service
Simply pass this script between 1 and 100 BCI LSIDs as a space delimited list in the 'lsid' parameter and the script will return an array of JavaScript objects each of which represents a collections community record in the database. Each object will have around 30 properties with self explanatory names. The list of properties is given in the table below. Your code should handle nulls and missing properties as the list may change. Guaranteed properties are 'lsid', 'name' and 'url' (which is the human readable page for the collection on BCI).
The LSIDs can be passed as part of the URL path, in the query string of the URL or as a POST variable.
e.g. http://biocol.org/json/fetch/lsid/urn:lsid:biocol.org:col:15670 will return the record for the Royal Botanic Garden Edinburgh.
http://biocol.org/json/fetch?lsid=urn:lsid:biocol.org:col:15670 is equivalent
http://biocol.org/json/fetch?lsid=urn:lsid:biocol.org:col:15670+urn:lsid:biocol.org:col:15763 will return Edinburgh and Paris.
To pass larger numbers of LSIDs (up to 100) it would obviously be better to use a POST request.
By default the results are wrapped in a callback call: "callback([...])". You can change the name of this call by passing the callback parameter. e.g.
http://biocol.org/json/fetch/callback/mycallback/lsid/urn:lsid:biocol.org:col:15670
http://biocol.org/json/fetch?callback=mycallback&lsid=urn:lsid:biocol.org:col:15670
The JSON search method allows the construction of complex searches. The parameter encoding and return type are the same as for the Fetch method above.
To search for records that have a particular value in a particular field simply pass that field in the query parameter e.g. http://biocol.org/json/search?code=CAS will return the community records where the code field contains 'CAS'. For string fields these comparisons are case insensitive.
Multiple parameters are ANDed together so http://biocol.org/json/search?code=CAS&kind=herbarium will return community records for collections that have the code = 'CAS' AND kind = 'herbarium'.
For fields of type string you can include % signs in the parameter value and an SQL LIKE comparison will be carried out rather than an equals. So http://biocol.org/json/search?code=CA%&kind=herbarium will return the community records of kind = herbarium and codes that start with CA. Like queries are not carried out on fields of type number or date
Both Like and Equality string comparisons can be negated by starting the value with a '-' (minus sign). So http://biocol.org/json/search?code=CA%&kind=-herbarium will return community records for collections that have codes that start with CA but are not of kind = herbarium.
For fields of type number or date you can start the parameter value with a < or >. So http://biocol.org/json/search?founded_year=<1900 will return the community records with a founding year less than 1900
You can repeat the same parameter in a search but you must append square brackets to the end of the parameter name if you do so (PHP style). So http://biocol.org/json/search?founded_year[]=<1900&founded_year[]=>1890 will return community records for collections founded after 1890 but before 1900. A similar technique could be used for lat/long bounding boxes.
The maximum number of results returned is 50. If there are more than 50 you will get the first 50 and no warning that there are more. You can limit the results to less that 50 by specifying the parameter limit= as a number less than 50. You can specify and offset to say what index you would like your results to start. So http://biocol.org/json/search?founded_year[]=<1900&founded_year[]=>1890&limit=10&offset=10 will return the second 'page' of ten results.
Paging is pretty useless unless the results can be guaranteed to come in a particular order so we have the ability to specify an order-by parameter so http://biocol.org/json/search?founded_year[]=<1900&founded_year[]=>1890&limit=10&offset=10&order-by=founded_year,name will order the results by founded_year then name. Prepending the field name with a '-' (minus sign) will cause the order to be descending. Ordering depends on the data type of the field. Strings are alphabetical, numbers numeric and dates by date!
By default all queries are run against the community records as these are often the most complete in terms of BCI data and every collection has a community editable record. If you would like to query collection records from a particular source you can specify a 'source' parameter with one of the following values: ih for Index Herbariorum, iscw for Insect and Spider Collections of the World or Bioreposit for BioRepositories.org records. So http://biocol.org/json/search?code=CAS&source=ih will return only records from Index Herbariorum with code CAS
| Name | Type | Documentation |
|---|---|---|
| address | display-string | You can not query this. It is provided as a convenience concatenation of location fields |
| code | string | Preferred code for the collection |
| contact_email | string | Contact email to use for the collection. |
| contact_fax | string | Fax number to use for the collection. |
| contact_person | string | Name of the contact person. |
| contact_phone | string | Phone number to call for the collection. |
| contact_position | string | Job title of the person to contact |
| created | date | Created date time MySQL format. Value treated the same as numbers for greater-than and less-than |
| description_pub | string | A accessible description of the collection using words a 10 year old would understand. |
| description_tech | string | A technical description of the collection (using long words and bio-jargon). |
| founded_year | number | The founding year as an integer. Supports less-than, greater-than |
| geo_scope | string | Geographic scope in words |
| institution_name | string | The name of the host institution. |
| institution_type | string | The kind of institution the host institution is. |
| institution_uri | string | The URL of the host institutions website. |
| kind | string | The kind of collection. |
| location_alt | number | The altitude about sea level in metres of the collection. Supports less-than, greater-than |
| location_city | string | The name of the city the collection is located in. |
| location_country_iso | string | The two letter ISO code for the country the collection is located in. |
| location_country_name | string | The name of the country the collection is located in. |
| location_department | string | The name of the department to use in an address label. |
| location_lat | number | The decimal lat (WGS84) of the collection. Supports less-than, greater-than |
| location_long | number | The decimal longitude (WGS84) of the collection. Supports less-than, greater-than |
| location_notes | string | Some notes about the location. |
| location_post_box | string | The PO Box to send things to. |
| location_postcode | string | The postal code or zip code of the collection. |
| location_state | string | The name of the state the collection is located in. |
| location_street | string | The street address including building name/number. |
| lsid | display-string | You can not query this. Use the fetch method to get collections by LSID |
| modified | date | Modified date time MySQL format. Value treated the same as numbers for greater-than and less-than |
| name | string | The name of the collection. |
| notes | string | Notes field for the collection. |
| record_id | string | The id of the record not the collection. Collections can have more than one record. |
| size | string | The size of the collection in words |
| size_approx_int | number | The approximate size of the collection as a number. Supports less-than, greater-than |
| taxon_scope | string | Taxonomic scope in words. |
| url | display-string | You can not query this. It is provided as a convenience link to the collection page on the BCI website |
| web_service_type | string | The kind of web service e.g. TAPIR or DiGIR. This is a hint. Call the web_service_uri to identify it for real. |
| web_service_uri | string | The URL of a web service end point that covers this collection. |
| web_site | string | The URL of the website for the collection. |
BCI Links is an example of the use of the JSON service to provide dynamic linking. By including a very small amount of script in their web pages system administrators can automatically link occurrences of collection codes, LSIDs and names to actual collection resources.
System administrators or web developers include the following code in their pages.
In the header section they include:
<script type="text/javascript" charset="utf-8" src="http://biocol.org/js/BCILinks.js"></script>
In the body tag they include a call to the BCILinks.parseLinks() method. This may be combined with other method calls already in the onload event.
<body onload="BCILinks.parseLinks()">
In the text of the page they can now surround the code, LSID or names of collections with 'a' tags that have any one of three classes.
<a class="BCI-Code-Link">E</a>
<a class="BCI-Name-Link">Royal Botanic Garden Edinburgh Herbarium</a>
<a class="BCI-LSID-Link">urn:lsid:biocol.org:col:15670</a>
When the page loads the parseLinks method works through the document, finds the 'a' tags with any of these three classes and turns them into the appropriate links. It does this by calling the BCI JSON service to search for the contents of the tag. The calls to BCI are made asynchronously so the generation of the links should not effect the overall page load time. Failure is graceful. If JavaScript is not enabled or the BCI site can not be reached then the link text is left as it is.
The kind of links that are generated depend on the link class and the results of the search. The behaviour is described here but is probably easier to understand by doing some worked examples with your own data.
This page uses the BCILinks JavaScript as described above.
| Description | Data | HTML | Demo |
|---|---|---|---|
| A code which (at time of writing) returns a single collection. | E | <a class="BCI-Code-Link">E</a> | E |
| An ambiguous code which returns multiple collections. | CAS | <a class="BCI-Code-Link">CAS</a> | CAS |
| A code which (at time of writing) returns no collections. | DHDHDHD | <a class="BCI-Code-Link">DHDHDHD</a> | DHDHDHD |
| An LSID for a collection which (at time of writing) has a web page URL. | urn:lsid:biocol.org:col:15670 | <a class="BCI-LSID-Link">urn:lsid:biocol.org:col:15670</a> | urn:lsid:biocol.org:col:15670 |
| An LSID for a collection which (at time of writing) does not have a web page URL. | urn:lsid:biocol.org:col:27074 | <a class="BCI-LSID-Link">urn:lsid:biocol.org:col:27074</a> | urn:lsid:biocol.org:col:27074 |
| A valid but non-existent LSID. | urn:lsid:biocol.org:col:0 | <a class="BCI-LSID-Link">urn:lsid:biocol.org:col:0</a> | urn:lsid:biocol.org:col:0 |
| A name that matches a collections name (at time of writing) | urn:lsid:biocol.org:col:0 | <a class="BCI-Name-Link">Royal Botanic Garden Edinburgh Herbarium</a> | Royal Botanic Garden Edinburgh Herbarium |
| A name that does not matche a collections name (at time of writing) | urn:lsid:biocol.org:col:0 | <a class="BCI-Name-Link">Royal Botanic Gardens Edinburgh</a> | Royal Botanic Gardens Edinburgh |
If you set BCILinks.debug to true like this:
<body onload="BCILinks.debug = true; BCILinks.parseLinks()">
Then alert messages will be displayed when BCILinks fails to turn the 'a' tag into a link.