SDKs & Code Examples

Integrate ETERA with TypeScript, Python, and any HTTP client

Direct API Access

ETERA APIs are standard REST endpoints — use any HTTP client to integrate. All endpoints accept JSON and return JSON responses.

1const ETERA_BASE = "https://api.etera.dev";
2
3async function eteraFetch(path: string, options: RequestInit = {}) {
4 const res = await fetch(`${ETERA_BASE}${path}`, {
5 ...options,
6 headers: {
7 Authorization: `Bearer ${process.env.ETERA_TOKEN}`,
8 "Content-Type": "application/json",
9 ...options.headers,
10 },
11 });
12
13 if (!res.ok) {
14 const error = await res.json();
15 throw new Error(error.error?.message || `HTTP ${res.status}`);
16 }
17
18 return res.json();
19}

Common Operations

Search Restaurants
1const restaurants = await eteraFetch(
2 "/restaurant/search/recommendations/"
3);
1const hotels = await eteraFetch(
2 "/hotel/search/v2/search?city=dubai&checkIn=2025-03-01&checkOut=2025-03-05"
3);
1const flights = await eteraFetch(
2 "/flight/search/search?from=DXB&to=LHR&date=2025-03-01"
3);
1const booking = await eteraFetch("/restaurant/booking/bookings/", {
2 method: "POST",
3 body: JSON.stringify({
4 restaurantId: "rest_123",
5 date: "2025-03-01",
6 time: "19:00",
7 partySize: 4,
8 }),
9});
1// List available tools
2const tools = await eteraFetch("/restaurant/mcp/mcp/tools");
3
4// Execute a tool
5const result = await eteraFetch(
6 "/restaurant/mcp/mcp/execute/search_restaurants",
7 {
8 method: "POST",
9 body: JSON.stringify({ query: "Italian in Dubai Marina" }),
10 }
11);
1const conversation = await eteraFetch("/ai/input", {
2 method: "POST",
3 body: JSON.stringify({
4 inputType: "text",
5 text: "Find me a beachfront hotel in Dubai for next weekend",
6 context: {
7 location: { type: "pinned", city: "Dubai" },
8 },
9 }),
10});
11
12// Check status
13const status = await eteraFetch(
14 `/ai/status/${conversation.conversationId}`
15);

OpenAPI Specs & Code Generation

All ETERA services expose OpenAPI 3.0.3 specs for automated client generation.

Generate a TypeScript Client

1

Install the generator

$npm install -D openapi-typescript
2

Generate types from a spec

$npx openapi-typescript https://api-dev.etera.dev/restaurant/search/swagger/json \
> -o ./src/types/restaurant-search.ts
3

Use the generated types

1import type { paths } from "./types/restaurant-search";
2
3type SearchResponse =
4 paths["/recommendations/"]["get"]["responses"]["200"]["content"]["application/json"];

Error Handling

1try {
2 const data = await eteraFetch("/restaurant/search/recommendations/");
3} catch (error) {
4 if (error.message.includes("401")) {
5 // Re-authenticate
6 } else if (error.message.includes("429")) {
7 // Rate limited — back off and retry
8 } else {
9 console.error("ETERA API error:", error.message);
10 }
11}

Next Steps