The Traits database can be accessed through a REST API and returns the results in json.
The format of the API is as follows:
https://[database-URL]/{method}/{query}/?{other parameter key value pairs}
Two methods are currently available:
- taxon: searches for a taxon name and returns taxon identifier(s)
- traits: retrieves traits information for one or more taxon identifiers
taxon
A method to search for taxa in the Traits database. Returns internal matching taxon identifiers which can then be used to query for traits.
URL: https://[database-URL]/taxon/{query}/?{other parameter key value pairs}
Example: Retrieve all taxon information about taxa starting with "Anonyx" and return them as a numeric array:
https://[database-URL]/taxon/Anonyx/?exact=0&verbose=1&assoc=0
Parameter name | Data type | Allowed values | Default value | Parameter note | Output |
---|---|---|---|---|---|
query | string | any taxon name | spaces have to be url-encoded, case-insensitive | ||
exact | boolean | 1|0 | 1 | optional | When true, returns only the exact match for the query string. When false, returns all matches beginning with the query string |
verbose | boolean | 1|0 | 0 | optional | When true, returns per taxon: array (taxon ID, taxon name, authority, valid taxon ID, valid taxon name, valid authority, taxonomic status, source of synonymy, rank). When false, returns per taxon: array (taxon ID, taxon name). |
assoc | boolean | 1|0 | 0 | optional | When true, an associative array is returned with the taxon ID as keys. When false, a numeric array is returned. |
traits
A method to retrieve trait information for one or more taxon identifiers. Returns all trait information for the given IDs
URL: https://[database-URL]/traits/{query}/?{other parameter key value pairs}
Example: Retrieve all trait information about the taxa with ID 1 and 2 and return them as an associative array with the taxon IDs as keys
https://[database-URL]/traits/2399,2400/?verbose=1&assoc=1
A description of the returned fields can be found at: Return fields
Parameter name | Data type | Allowed values | Default value | Parameter note | Output |
---|---|---|---|---|---|
query | integer or string | one or more taxon identifiers, comma-separated | Use “taxon” method to retrieve a list of IDs. Up to 10 Ids are allowed. | ||
verbose | boolean | 1|0 | 1 | Optional | When true, returns per taxon the fields documented here. When false, returns per taxon: array(trait, category, traitvalue) |
assoc | boolean | 1|0 | 1 | optional | When true, an associative array is returned with the taxon ID as keys. When false, a numeric array is returned. |