Snippets
Here is some request samples
Third party libraries
The node
, ruby
and python
snippets require third-party libraries:
- node: node-fetch library.
- python: request library.
- ruby: HTTParty library.
Genus
Get all genus
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/genus?token=YOUR_TREFLE_TOKEN
Plants & Species
Reminder
In all the following samples, /plants
can be switched to /species
and /species
can be switched to /plants
.
The only difference is that /species
API calls will return matching species, subspecies, varieties etc..., and /plants
API calls will only return main species (without all the children species).
Get all plants
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/plants?token=YOUR_TREFLE_TOKEN
Get all species
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/species?token=YOUR_TREFLE_TOKEN
Get only edible plants
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/plants?filter_not%5Bedible_part%5D=null&token=YOUR_TREFLE_TOKEN
Get tallest trees
Explanation
- Get all plants
- With tree ligneous type
filter[ligneous_type]=tree
- Without plants with no maximum height
filter_not[maximum_height_cm]=null
- Ordered by maximum height descending (highest first)
order[maximum_height_cm]=desc
- CURL
- Browser
- NodeJS
- Python
- Ruby
Get plants in Antartica
See Distributions to learn more about distributions zones.
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/distributions/antarctica/plants?token=YOUR_TREFLE_TOKEN
Get plants introduced in Marion-Prince Edward
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/distributions/marion-prince-edward/plants?filter%5Bestablishment%5D=introduced&token=YOUR_TREFLE_TOKEN
Get plants native from Tibet
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/distributions/tibet/plants?filter%5Bestablishment%5D=native&token=YOUR_TREFLE_TOKEN
Get species with height between 5cm and 20cm
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/species?range%5Bmaximum_height_cm%5D=5%2C20&token=YOUR_TREFLE_TOKEN
Get species with red flowers
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/species?filter%5Bflower_color%5D=red&token=YOUR_TREFLE_TOKEN
Get search for coconut species
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/species/search?q=coconut&token=YOUR_TREFLE_TOKEN
Get species with oldest discoveries first
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/species?order%5Byear%5D=asc&token=YOUR_TREFLE_TOKEN
Zones & Distributions
See Distributions to learn more about distributions zones.
Get all countries / zones
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/distributions?token=YOUR_TREFLE_TOKEN
Get countries / zones with less than 10 species
- CURL
- Browser
- NodeJS
- Python
- Ruby
Open your browser and navigate to https://trefle.io/api/v1/distributions?range%5Bspecies_count%5D=%2C10&token=YOUR_TREFLE_TOKEN