globeapi
v1.0.2
Published
Official Node.js SDK for GlobeAPI — the unified travel API platform
Maintainers
Readme
GlobeAPI Node.js SDK
Official Node.js SDK for GlobeAPI -- the unified travel API platform.
Zero dependencies. Uses native fetch. Requires Node.js 18+.
Installation
npm install globeapiQuick Start
const { GlobeAPI } = require("globeapi");
const client = new GlobeAPI("your-api-key");Search Places
const places = await client.places.search({
query: "coffee shops",
lat: 41.3275,
lng: 19.8187,
radius: 1000,
limit: 5,
});
console.log(places.results);Reverse Geocode
const location = await client.places.geocode({ lat: 48.8566, lng: 2.3522 });
console.log(location.city); // "Paris"Search Cities
const cities = await client.cities.search({ query: "Tirana", limit: 3 });
console.log(cities.results);Search Flights
const flights = await client.flights.search({
origin: "TIA",
destination: "LHR",
date: "2026-06-15",
passengers: 2,
cabin_class: "economy",
});
console.log(flights.results);Search Hotels
const hotels = await client.hotels.search({
city: "Paris",
check_in: "2026-07-01",
check_out: "2026-07-05",
guests: 2,
rooms: 1,
});
console.log(hotels.results);AI Chat
const response = await client.ai.chat({
message: "What are the best beaches in Albania?",
});
console.log(response.reply);AI Chat (Streaming)
const stream = await client.ai.chat({
message: "Plan a 3-day trip to Tokyo",
stream: true,
});
const reader = stream.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
process.stdout.write(decoder.decode(value));
}AI Vision
const fs = require("fs");
const image = fs.readFileSync("photo.jpg").toString("base64");
const result = await client.ai.vision({
image,
message: "What landmark is in this photo?",
});
console.log(result.reply);Voice Transcription
const fs = require("fs");
const audio = fs.readFileSync("recording.wav").toString("base64");
const transcription = await client.voice.transcribe({ audio });
console.log(transcription.text);Image Moderation
const result = await client.moderation.check({ image: base64Image });
console.log(result.safe); // true or falseSearch Photos
const photos = await client.photos.search({
query: "sunset",
country: "Greece",
limit: 10,
});
console.log(photos.results);Plan a Trip
const trip = await client.trips.plan({
destination: "Rome",
days: 3,
interests: ["history", "food", "art"],
});
for (const day of trip.days) {
console.log(`Day ${day.day}: ${day.title}`);
for (const activity of day.activities) {
console.log(` ${activity.time} - ${activity.title}`);
}
}Custom Base URL
const client = new GlobeAPI("your-api-key", {
baseUrl: "https://custom-endpoint.example.com",
});Error Handling
const { GlobeAPI, GlobeAPIError } = require("globeapi");
try {
const result = await client.flights.search({ origin: "TIA", destination: "JFK", date: "2026-06-15" });
} catch (err) {
if (err instanceof GlobeAPIError) {
console.error(`API error ${err.status}: ${err.message}`);
console.error("Response body:", err.body);
} else {
throw err;
}
}TypeScript
Full type definitions are included. Import types directly:
import { GlobeAPI, GlobeAPIError } from "globeapi";
import type { Flight, Hotel, Place } from "globeapi";
const client = new GlobeAPI("your-api-key");
const flights = await client.flights.search({
origin: "TIA",
destination: "LHR",
date: "2026-06-15",
});License
MIT
