ktemia 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ktemia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,106 @@
1
- # Temporary Holding Version
1
+ # ktemia
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/ktemia)](https://www.npmjs.com/package/ktemia)
4
+ [![CI](https://github.com/Ktemiaa/ktemia-agent-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/Ktemiaa/ktemia-agent-toolkit/actions/workflows/ci.yml)
5
+
6
+ The official TypeScript client for the [Ktemia](https://www.ktemia.com/) travel search API. Search and compare flights, hotels, and rental cars across 100+ providers.
7
+
8
+ Ktemia searches and compares. It does not book: results carry links that hand off to the provider's own site.
9
+
10
+ - Zero dependencies. Runs on Node 20+, Bun, Deno, and edge runtimes.
11
+ - One call per search: starting a search and reading its first page happen together.
12
+ - Catches bad input before sending, so a past date or a city name in a code field never spends quota.
13
+ - Retries rate limits for you. Never retries a spent monthly quota.
14
+
15
+ [Get a free API key](https://app.ktemia.com/api-keys) · [API reference](https://www.ktemia.com/docs/api/) · [Getting started](https://www.ktemia.com/docs/getting-started/)
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ npm install ktemia
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```ts
26
+ import { Ktemia } from 'ktemia';
27
+
28
+ const kt = new Ktemia(); // reads KTEMIA_API_KEY
29
+
30
+ // Flights: IATA airport or city codes
31
+ const flights = await kt.flights.search({
32
+ origin: 'LAX',
33
+ destination: 'LON',
34
+ departureDate: '2027-03-14',
35
+ passengers: { adults: 2 },
36
+ });
37
+
38
+ // Hotels and cars need a location id from a lookup
39
+ const [paris] = (await kt.lookup({ kind: 'hotelLocation', query: 'Paris' })).locations as { locationId: string }[];
40
+ const hotels = await kt.hotels.search({ location: paris.locationId, checkin: '2027-03-14', checkout: '2027-03-17' });
41
+
42
+ // Next page, details, reviews
43
+ if (flights.nextToken) await kt.flights.page(flights.nextToken);
44
+ await kt.hotels.details(hotels.token, 'result-id');
45
+ await kt.hotels.reviews({ hotelId: 'hotel-id', travelerTypes: ['couples'] });
46
+
47
+ // Plan and remaining quota (free)
48
+ const { usage } = await kt.keyStatus();
49
+ ```
50
+
51
+ | Method | Cost |
52
+ |---|---|
53
+ | `kt.keyStatus()` | Free |
54
+ | `kt.lookup({ kind, query })` with kind `airport`, `airline`, `hotelLocation`, `carLocation` | 1 request |
55
+ | `kt.flights / hotels / cars.search(params)` | 2 requests (start, first page) |
56
+ | `.page(nextToken)` | 1 request |
57
+ | `.details(token, resultId)` | 1 request |
58
+ | `kt.hotels.reviews(params)` | 1 request |
59
+
60
+ A search that matches nothing returns a page with `noResults` set instead of throwing. Search tokens expire one hour after the search starts.
61
+
62
+ ## Errors
63
+
64
+ Everything throws `KtemiaError` with a stable `code`:
65
+
66
+ ```ts
67
+ import { KtemiaError } from 'ktemia';
68
+
69
+ try {
70
+ await kt.flights.search({ origin: 'LAX', destination: 'LON', departureDate: '2027-03-14' });
71
+ } catch (error) {
72
+ if (error instanceof KtemiaError && error.code === 'QUOTA_EXCEEDED') {
73
+ // The monthly allowance is used up. kt.keyStatus() has the reset date.
74
+ }
75
+ }
76
+ ```
77
+
78
+ | Code | Meaning | Retried? |
79
+ |---|---|---|
80
+ | `INVALID_INPUT` | Rejected before sending; nothing was spent | No |
81
+ | `RATE_LIMIT_EXCEEDED` | Too many requests per second | Yes, after `Retry-After`, up to `maxRetries` |
82
+ | `QUOTA_EXCEEDED` | Monthly quota used up | Never |
83
+ | `MISSING_API_KEY`, `INVALID_API_KEY` | Key problem | No |
84
+ | `TIMEOUT`, `NETWORK_ERROR`, 5xx | Transient | Once |
85
+
86
+ ## Options
87
+
88
+ ```ts
89
+ new Ktemia({
90
+ apiKey: '...', // default KTEMIA_API_KEY
91
+ timeoutMs: 60_000, // per request
92
+ maxRetries: 2, // rate-limit retries
93
+ fetch: customFetch, // proxies, tests
94
+ });
95
+ ```
96
+
97
+ Use it server-side: the API key must not ship to a browser.
98
+
99
+ ## For AI agents
100
+
101
+ - Vercel AI SDK: [`@ktemia/ai-sdk`](https://www.npmjs.com/package/@ktemia/ai-sdk)
102
+ - MCP (Claude, Cursor, ChatGPT): [`@ktemia/mcp`](https://github.com/Ktemiaa/ktemia-mcp)
103
+
104
+ ## License
105
+
106
+ MIT