GET Staff - nybgvh/IH-API GitHub Wiki

Get all Staff

Resource URL

/v1/staff

Sample Request

http://sweetgum.nybg.org/science/api/v1/staff

Search staff by irn

Resource URL

/v1/staff/{irn}

Sample Request

https://sweetgum.nybg.org/science/api/v1/staff/134209

Search Staff by record property

Returns a list of staff matching a search term.

Resource URL

/v1/staff/search

Parameters

Name Data Type Description
irn number Search staff by unique identifier (e.g. 134209)
firstName string Search staff by first Name (e.g. "john")
lastName string Search staff by last Name (e.g. "miller")
specialities string Search staff by research pursuits (e.g. "algae")
correspondent string Search correspondents (values: "yes", "no")
city string Search staff by city (e.g. "las vegas")
state string Search staff by state (e.g. "texas")
country string Search staff by country (e.g. "brazil")
code string Search staff by institution code (e.g. "ny")
sort string Sort results (values: "firstName", "lastName")
limit number Specify the number of records to return (e.g. 10)
dateModified string Date of the last modification of the record. (mm/dd/yyyy Format, operators: <, >) (e.g. ">10/6/2015")
download string Download as CSV File (value: "yes")

Sample Request

http://sweetgum.nybg.org/science/api/v1/staff/search?lastName=miller&state=Wisconsin

http://sweetgum.nybg.org/science/api/v1/staff/search?country=u.s.a.&sort=lastName&limit=10

http://sweetgum.nybg.org/science/api/v1/staff/search?country=brazil&dateModified=>3/7/2015

http://sweetgum.nybg.org/science/api/v1/staff/search?city=beijing&download=yes

Sample Response

          {
                "meta": {
                      "hits": 1,
                      "code": 200
                },
                "data": [
                   {
                      "irn": 134209,
                      "code": "UNM",
                      "lastName": "Tonne",
                      "middleName": "C.",
                      "firstName": "Phil",
                      "birthDate": "",
                      "correspondent": "No",
                      "position": "",
                      "currentStatus": "Active",
                      "specialities": "Flora of New Mexico\nthreatened and endangered species",
                      "address": {
                             "street": "",
                             "city": "Albuquerque",
                             "state": "New Mexico",
                             "zipCode": "",
                             "country": "U.S.A."
                       },
                       "contact": {
                             "phone": "",
                             "fax": "",
                             "email": ""
                       },
                       "dateModified": "2017-09-12"
                    }
                ]
          }

Response Values

Name Data Type Description
irn number Unique person identifier for IH record (e.g. http://sweetgum.nybg.org/science/ih/person-details/?irn=250479)
code string Institution code for this person
lastName string Last name for this person
middleName string Middle name for this person
firstName string First name for this person
birthDate string Year of birth for this person
correspondent string Whether person is correspondent of institution
position string Position for this person
currentStatus String Current status of person
specialities string Research pursuits for this person
address dict Address data for this person
address.street string Street address for this person
address.city string City for this person
address.state string State for this person
address.zipCode string Zip code for this person
address.country string Country for this person
contact dict Contact data for this person
contact.phone string Phone number for this person
contact.fax string Fax number for this person
contact.email string Email for this person
dateModified string Date of the last modification of the record

Javascript

Make a Javascript AJAX request:

     $.ajax({
              url: 'http://sweetgum.nybg.org/science/api/v1/staff/search',
              dataType: 'json',
              type: 'GET',
              data: {country: "bolivia", sort: "lastName", limit: 10},
              success: function(res)
              {
                 $.each(res.data, function(index, element){
		    $('#staff').append(element.firstName + ' ' + element.lastName + '<br>');
		});
              }
            });   

PHP

Using the API with PHP:

      $url = "http://sweetgum.nybg.org/science/api/v1/staff/search?country=bolivia&sort=lastName&limit=10";
      $curl = curl_init();
      curl_setopt_array($curl, array(
         CURLOPT_RETURNTRANSFER => 1,
         CURLOPT_URL => $url
      ));
 
      $response = curl_exec($curl);
      curl_close($curl);

      $json = json_decode($response);

      foreach( $json->data as $staff )
      {
         echo $staff->firstName . ' ' . $staff->lastName . '<br>';
      }

R

Using the API with R:

      library(jsonlite)
      url <- "http://sweetgum.nybg.org/science/api/v1/staff/search?country=bolivia&sort=lastName&limit=10"
      df <- fromJSON(url)$data
      paste0(df$firstName," ",df$lastName)