One call in the languages most used in travel. Replace the key with yours and keep it on your server.
curl --max-time 5 "https://api.dondoo.com/v1/donts?iata=DXB&limit=5" \
-H "X-API-Key: $DONDOO_KEY"
# The PDF, ready to attach to an email:
curl --max-time 15 "https://api.dondoo.com/v1/donts?iata=DXB&format=pdf" \
-H "X-API-Key: $DONDOO_KEY" -o dondoo-donts-DXB.pdf
// Node.js 18+ (on your server; never put your key in a web page)
const res = await fetch("https://api.dondoo.com/v1/donts?iata=DXB&limit=5", {
headers: { "X-API-Key": process.env.DONDOO_KEY },
signal: AbortSignal.timeout(5000),
});
if (res.ok) {
const data = await res.json();
for (const d of data.donts) console.log(d.rank, d.text);
} else {
const { error } = await res.json();
console.warn("Dondoo:", error.code, error.message); // carry on without the don'ts
}
import os, requests
res = requests.get(
"https://api.dondoo.com/v1/donts",
params={"iata": "DXB", "limit": 5},
headers={"X-API-Key": os.environ["DONDOO_KEY"]},
timeout=5,
)
if res.ok:
for d in res.json()["donts"]:
print(d["rank"], d["text"])
else:
err = res.json()["error"]
print("Dondoo:", err["code"], err["message"]) # carry on without the don'ts
import java.net.URI;
import java.net.http.*;
import java.time.Duration;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.dondoo.com/v1/donts?iata=DXB&limit=5"))
.header("X-API-Key", System.getenv("DONDOO_KEY"))
.timeout(Duration.ofSeconds(5))
.build();
HttpResponse<String> res = client.send(request, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() == 200) {
System.out.println(res.body()); // read "donts" with your JSON library
} else {
System.err.println("Dondoo: " + res.body()); // carry on without the don'ts
}
using System.Net.Http.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };
http.DefaultRequestHeaders.Add("X-API-Key", Environment.GetEnvironmentVariable("DONDOO_KEY"));
var res = await http.GetAsync("https://api.dondoo.com/v1/donts?iata=DXB&limit=5");
if (res.IsSuccessStatusCode)
{
var data = await res.Content.ReadFromJsonAsync<System.Text.Json.JsonElement>();
foreach (var d in data.GetProperty("donts").EnumerateArray())
Console.WriteLine($"{d.GetProperty("rank")} {d.GetProperty("text")}");
}
else
{
Console.Error.WriteLine("Dondoo: " + await res.Content.ReadAsStringAsync()); // carry on without the don'ts
}
Good to know
Send the key in the X-API-Key header, never in the address.
Use a short timeout (about 5 seconds; a first PDF can take a few seconds) and carry on if the call fails.
A 429 answer is either too_fast (wait the seconds in Retry-After) or limit_reached (your allowance is used up).
Save the X-Data-Version header if you store answers: it tells you which data they came from.