Public
Edited
Sep 6, 2023
Importers
Insert cell
Insert cell
Insert cell
function generate_get_request_url(query='', type='', quality='', country='') {
// A query looks like this:
// https://cors-anywhere.herokuapp.com/https://www.xeno-canto.org/api/2/recordings?query=troglodytes%20troglodytes"
//?query=troglodytes%20troglodytes%20type%3A%22male%22%20cnt%3A%22Italy%22

let base_url = cors_anywhere+xeno_endpoint + "query="
let elems = []
elems.push(query)
if (type != '') {
elems.push(`type:"${type}"`)
}
if (quality != '') {
elems.push(`q:"${quality}"`)
}
if (country != '') {
elems.push(`cnt:"${toTitleCase(country)}"`)
}
let query_string = elems.join(" ")
query_string = encodeURIComponent(query_string)

return base_url + query_string
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
results = xeno_canto_query(
"troglodytes troglodytes",
"song",
"A",
"United Kingdom"
)
Insert cell
Insert cell
htl = require("htl@0.2")
Insert cell
Insert cell
rec = get_n_from_array_at_random(results.recordings, 3)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more