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
curl -X GET "https://trefle.io/api/v1/genus?token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/genus?token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/genus?token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/genus?token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/genus',
query: {
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
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
curl -X GET "https://trefle.io/api/v1/plants?token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/plants?token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/plants?token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/plants?token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/plants',
query: {
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
Get all species
- CURL
- Browser
- NodeJS
- Python
- Ruby
curl -X GET "https://trefle.io/api/v1/species?token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/species?token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/species?token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/species?token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/species',
query: {
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
Get only edible plants
- CURL
- Browser
- NodeJS
- Python
- Ruby
curl -X GET "https://trefle.io/api/v1/plants?filter_not%5Bedible_part%5D=null&token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/plants?filter_not%5Bedible_part%5D=null&token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/plants?filter_not%5Bedible_part%5D=null&token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/plants?filter_not%5Bedible_part%5D=null&token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/plants',
query: {
"filter_not": {
"edible_part": "null"
},
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
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
curl -X GET "https://trefle.io/api/v1/plants?filter_not%5Bmaximum_height_cm%5D=null&filter%5Bligneous_type%5D=tree&order%5Bmaximum_height_cm%5D=desc&token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/plants?filter_not%5Bmaximum_height_cm%5D=null&filter%5Bligneous_type%5D=tree&order%5Bmaximum_height_cm%5D=desc&token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/plants?filter_not%5Bmaximum_height_cm%5D=null&filter%5Bligneous_type%5D=tree&order%5Bmaximum_height_cm%5D=desc&token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/plants?filter_not%5Bmaximum_height_cm%5D=null&filter%5Bligneous_type%5D=tree&order%5Bmaximum_height_cm%5D=desc&token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/plants',
query: {
"filter_not": {
"maximum_height_cm": "null"
},
"filter": {
"ligneous_type": "tree"
},
"order": {
"maximum_height_cm": "desc"
},
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
Get plants in Antartica
See Distributions to learn more about distributions zones.
- CURL
- Browser
- NodeJS
- Python
- Ruby
curl -X GET "https://trefle.io/api/v1/distributions/antarctica/plants?token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/distributions/antarctica/plants?token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/distributions/antarctica/plants?token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/distributions/antarctica/plants?token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/distributions/antarctica/plants',
query: {
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
Get plants introduced in Marion-Prince Edward
- CURL
- Browser
- NodeJS
- Python
- Ruby
curl -X GET "https://trefle.io/api/v1/distributions/marion-prince-edward/plants?filter%5Bestablishment%5D=introduced&token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/distributions/marion-prince-edward/plants?filter%5Bestablishment%5D=introduced&token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/distributions/marion-prince-edward/plants?filter%5Bestablishment%5D=introduced&token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/distributions/marion-prince-edward/plants?filter%5Bestablishment%5D=introduced&token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/distributions/marion-prince-edward/plants',
query: {
"filter": {
"establishment": "introduced"
},
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
Get plants native from Tibet
- CURL
- Browser
- NodeJS
- Python
- Ruby
curl -X GET "https://trefle.io/api/v1/distributions/tibet/plants?filter%5Bestablishment%5D=native&token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/distributions/tibet/plants?filter%5Bestablishment%5D=native&token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/distributions/tibet/plants?filter%5Bestablishment%5D=native&token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/distributions/tibet/plants?filter%5Bestablishment%5D=native&token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/distributions/tibet/plants',
query: {
"filter": {
"establishment": "native"
},
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
Get species with height between 5cm and 20cm
- CURL
- Browser
- NodeJS
- Python
- Ruby
curl -X GET "https://trefle.io/api/v1/species?range%5Bmaximum_height_cm%5D=5%2C20&token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/species?range%5Bmaximum_height_cm%5D=5%2C20&token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/species?range%5Bmaximum_height_cm%5D=5%2C20&token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/species?range%5Bmaximum_height_cm%5D=5%2C20&token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/species',
query: {
"range": {
"maximum_height_cm": "5,20"
},
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
Get species with red flowers
- CURL
- Browser
- NodeJS
- Python
- Ruby
curl -X GET "https://trefle.io/api/v1/species?filter%5Bflower_color%5D=red&token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/species?filter%5Bflower_color%5D=red&token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/species?filter%5Bflower_color%5D=red&token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/species?filter%5Bflower_color%5D=red&token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/species',
query: {
"filter": {
"flower_color": "red"
},
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
Get search for coconut species
- CURL
- Browser
- NodeJS
- Python
- Ruby
curl -X GET "https://trefle.io/api/v1/species/search?q=coconut&token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/species/search?q=coconut&token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/species/search?q=coconut&token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/species/search?q=coconut&token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/species/search',
query: {
"q": "coconut",
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
Get species with oldest discoveries first
- CURL
- Browser
- NodeJS
- Python
- Ruby
curl -X GET "https://trefle.io/api/v1/species?order%5Byear%5D=asc&token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/species?order%5Byear%5D=asc&token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/species?order%5Byear%5D=asc&token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/species?order%5Byear%5D=asc&token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/species',
query: {
"order": {
"year": "asc"
},
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
Zones & Distributions
See Distributions to learn more about distributions zones.
Get all countries / zones
- CURL
- Browser
- NodeJS
- Python
- Ruby
curl -X GET "https://trefle.io/api/v1/distributions?token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/distributions?token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/distributions?token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/distributions?token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/distributions',
query: {
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response
Get countries / zones with less than 10 species
- CURL
- Browser
- NodeJS
- Python
- Ruby
curl -X GET "https://trefle.io/api/v1/distributions?range%5Bspecies_count%5D=%2C10&token=YOUR_TREFLE_TOKEN"
Open your browser and navigate to https://trefle.io/api/v1/distributions?range%5Bspecies_count%5D=%2C10&token=YOUR_TREFLE_TOKEN
const fetch = require('node-fetch');
(async () => {
const response = await fetch('https://trefle.io/api/v1/distributions?range%5Bspecies_count%5D=%2C10&token=YOUR_TREFLE_TOKEN');
const json = await response.json();
console.log(json);
})();
import requests
r = requests.get('https://trefle.io/api/v1/distributions?range%5Bspecies_count%5D=%2C10&token=YOUR_TREFLE_TOKEN')
r.json
require 'httparty'
r = HTTParty.get(
'https://trefle.io/api/v1/distributions',
query: {
"range": {
"species_count": ",10"
},
"token": "YOUR_TREFLE_TOKEN"
}
)
r.parsed_response