@countrydataapi/sdk 1.0.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/dist/index.mjs ADDED
@@ -0,0 +1,400 @@
1
+ // src/resources/countries.ts
2
+ var Countries = class {
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /**
7
+ * Get all countries
8
+ * @example
9
+ * const countries = await api.countries.getAll({ lang: 'es', limit: 50 });
10
+ */
11
+ async getAll(options) {
12
+ return this.http.get("/v1/countries/all", options);
13
+ }
14
+ /**
15
+ * Get country by name
16
+ * @example
17
+ * const spain = await api.countries.getByName({ name: 'Spain' });
18
+ */
19
+ async getByName(options) {
20
+ return this.http.get("/v1/countries/name", options);
21
+ }
22
+ /**
23
+ * Get country by ISO code (alpha-2, alpha-3, numeric, or CIOC)
24
+ * @example
25
+ * const spain = await api.countries.getByCode({ code: 'ES' });
26
+ */
27
+ async getByCode(options) {
28
+ return this.http.get("/v1/countries/code", options);
29
+ }
30
+ /**
31
+ * Get countries by region
32
+ * @example
33
+ * const european = await api.countries.getByRegion({ region: 'Europe' });
34
+ */
35
+ async getByRegion(options) {
36
+ return this.http.get("/v1/countries/region", options);
37
+ }
38
+ /**
39
+ * Get countries by currency code
40
+ * @example
41
+ * const euroCountries = await api.countries.getByCurrency({ currency: 'EUR' });
42
+ */
43
+ async getByCurrency(options) {
44
+ return this.http.get("/v1/countries/currency", options);
45
+ }
46
+ /**
47
+ * Get countries by language
48
+ * @example
49
+ * const spanishSpeaking = await api.countries.getByLanguage({ language: 'spa' });
50
+ */
51
+ async getByLanguage(options) {
52
+ return this.http.get("/v1/countries/language", options);
53
+ }
54
+ /**
55
+ * Get countries by timezone
56
+ * @example
57
+ * const utcCountries = await api.countries.getByTimezone({ timezone: 'UTC' });
58
+ */
59
+ async getByTimezone(options) {
60
+ return this.http.get("/v1/countries/timezone", options);
61
+ }
62
+ /**
63
+ * Get countries by state
64
+ * @example
65
+ * const countries = await api.countries.getByState({ state: 'California' });
66
+ */
67
+ async getByState(options) {
68
+ return this.http.get("/v1/countries/state", options);
69
+ }
70
+ /**
71
+ * Get countries by city
72
+ * @example
73
+ * const countries = await api.countries.getByCity({ city: 'Madrid' });
74
+ */
75
+ async getByCity(options) {
76
+ return this.http.get("/v1/countries/city", options);
77
+ }
78
+ /**
79
+ * Get countries by zip code
80
+ * @example
81
+ * const countries = await api.countries.getByZipCode({ zipCode: '28001' });
82
+ */
83
+ async getByZipCode(options) {
84
+ return this.http.get("/v1/countries/zipCode", options);
85
+ }
86
+ };
87
+
88
+ // src/resources/states.ts
89
+ var States = class {
90
+ constructor(http) {
91
+ this.http = http;
92
+ }
93
+ /**
94
+ * Get all states
95
+ * @example
96
+ * const states = await api.states.getAll({ lang: 'es' });
97
+ */
98
+ async getAll(options) {
99
+ return this.http.get("/v1/states/all", options);
100
+ }
101
+ /**
102
+ * Get state by name
103
+ * @example
104
+ * const state = await api.states.getByName({ state: 'Madrid' });
105
+ */
106
+ async getByName(options) {
107
+ return this.http.get("/v1/states/", options);
108
+ }
109
+ /**
110
+ * Get states by country
111
+ * @example
112
+ * const spanishStates = await api.states.getByCountry({ country: 'Spain' });
113
+ */
114
+ async getByCountry(options) {
115
+ return this.http.get("/v1/states/country", options);
116
+ }
117
+ /**
118
+ * Get states by city
119
+ * @example
120
+ * const states = await api.states.getByCity({ city: 'Madrid' });
121
+ */
122
+ async getByCity(options) {
123
+ return this.http.get("/v1/states/city", options);
124
+ }
125
+ /**
126
+ * Get states by zipcode
127
+ * @example
128
+ * const states = await api.states.getByZipcode({ zipcode: '28001' });
129
+ */
130
+ async getByZipcode(options) {
131
+ return this.http.get("/v1/states/zipcode", options);
132
+ }
133
+ };
134
+
135
+ // src/resources/cities.ts
136
+ var Cities = class {
137
+ constructor(http) {
138
+ this.http = http;
139
+ }
140
+ /**
141
+ * Get all cities
142
+ * @example
143
+ * const cities = await api.cities.getAll({ lang: 'es', limitToken: 100 });
144
+ */
145
+ async getAll(options) {
146
+ return this.http.get("/v1/cities/all", options);
147
+ }
148
+ /**
149
+ * Get city by name or ID
150
+ * @example
151
+ * const city = await api.cities.get({ city: 'Madrid' });
152
+ */
153
+ async get(options) {
154
+ return this.http.get("/v1/cities/", options);
155
+ }
156
+ /**
157
+ * Get cities by country
158
+ * @example
159
+ * const cities = await api.cities.getByCountry({ country: 'Spain' });
160
+ */
161
+ async getByCountry(options) {
162
+ return this.http.get("/v1/cities/country", options);
163
+ }
164
+ /**
165
+ * Get cities by state
166
+ * @example
167
+ * const cities = await api.cities.getByState({ state: 'Madrid' });
168
+ */
169
+ async getByState(options) {
170
+ return this.http.get("/v1/cities/state", options);
171
+ }
172
+ };
173
+
174
+ // src/resources/zipcodes.ts
175
+ var Zipcodes = class {
176
+ constructor(http) {
177
+ this.http = http;
178
+ }
179
+ /**
180
+ * Get all zipcodes
181
+ * @example
182
+ * const zipcodes = await api.zipcodes.getAll({ limitToken: 100 });
183
+ */
184
+ async getAll(options) {
185
+ return this.http.get("/v1/zipcodes/all", options);
186
+ }
187
+ /**
188
+ * Get zipcodes by state
189
+ * @example
190
+ * const zipcodes = await api.zipcodes.getByState({ state: 'Madrid' });
191
+ */
192
+ async getByState(options) {
193
+ return this.http.get("/v1/zipcodes/state", options);
194
+ }
195
+ /**
196
+ * Get zipcodes by country
197
+ * @example
198
+ * const zipcodes = await api.zipcodes.getByCountry({ country: 'Spain' });
199
+ */
200
+ async getByCountry(options) {
201
+ return this.http.get("/v1/zipcodes/country", options);
202
+ }
203
+ /**
204
+ * Get zipcodes by region
205
+ * @example
206
+ * const zipcodes = await api.zipcodes.getByRegion({ region: 'Europe' });
207
+ */
208
+ async getByRegion(options) {
209
+ return this.http.get("/v1/zipcodes/region", options);
210
+ }
211
+ };
212
+
213
+ // src/resources/select.ts
214
+ var Select = class {
215
+ constructor(http) {
216
+ this.http = http;
217
+ }
218
+ /**
219
+ * Get countries optimized for select/dropdown (costs 1 token)
220
+ * @example
221
+ * const countries = await api.select.countries({ lang: 'es' });
222
+ */
223
+ async countries(options) {
224
+ return this.http.get("/v1/select/countries", options);
225
+ }
226
+ /**
227
+ * Get states for a country optimized for select/dropdown (costs 1 token)
228
+ * @example
229
+ * const states = await api.select.states({ country: 'ES' });
230
+ */
231
+ async states(options) {
232
+ return this.http.get("/v1/select/states", options);
233
+ }
234
+ /**
235
+ * Get cities for a state optimized for select/dropdown (costs 1 token)
236
+ * @example
237
+ * const cities = await api.select.cities({ state: 'Madrid', country: 'ES' });
238
+ */
239
+ async cities(options) {
240
+ return this.http.get("/v1/select/cities", options);
241
+ }
242
+ };
243
+
244
+ // src/utils/errors.ts
245
+ var CountryDataApiError = class extends Error {
246
+ constructor(message, statusCode, response) {
247
+ super(message);
248
+ this.statusCode = statusCode;
249
+ this.response = response;
250
+ this.name = "CountryDataApiError";
251
+ }
252
+ };
253
+ var AuthenticationError = class extends CountryDataApiError {
254
+ constructor(message = "Invalid API key") {
255
+ super(message, 401);
256
+ this.name = "AuthenticationError";
257
+ }
258
+ };
259
+ var RateLimitError = class extends CountryDataApiError {
260
+ constructor(message = "Rate limit exceeded") {
261
+ super(message, 429);
262
+ this.name = "RateLimitError";
263
+ }
264
+ };
265
+ var InsufficientTokensError = class extends CountryDataApiError {
266
+ constructor(message = "No remaining tokens available") {
267
+ super(message, 402);
268
+ this.name = "InsufficientTokensError";
269
+ }
270
+ };
271
+ var ValidationError = class extends CountryDataApiError {
272
+ constructor(message) {
273
+ super(message, 400);
274
+ this.name = "ValidationError";
275
+ }
276
+ };
277
+
278
+ // src/utils/http.ts
279
+ var HttpClient = class {
280
+ constructor(config) {
281
+ this.config = config;
282
+ }
283
+ async get(endpoint, params) {
284
+ const url = this.buildUrl(endpoint, params);
285
+ const controller = new AbortController();
286
+ const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
287
+ try {
288
+ const response = await fetch(url, {
289
+ method: "GET",
290
+ headers: {
291
+ "Accept": "application/json"
292
+ },
293
+ signal: controller.signal
294
+ });
295
+ clearTimeout(timeoutId);
296
+ const data = await response.json();
297
+ if (!response.ok) {
298
+ this.handleError(response.status, data);
299
+ }
300
+ if (data.error) {
301
+ this.handleApiError(data);
302
+ }
303
+ return data;
304
+ } catch (error) {
305
+ clearTimeout(timeoutId);
306
+ if (error instanceof CountryDataApiError) {
307
+ throw error;
308
+ }
309
+ if (error instanceof Error) {
310
+ if (error.name === "AbortError") {
311
+ throw new CountryDataApiError("Request timeout", 408);
312
+ }
313
+ throw new CountryDataApiError(error.message);
314
+ }
315
+ throw new CountryDataApiError("Unknown error occurred");
316
+ }
317
+ }
318
+ buildUrl(endpoint, params) {
319
+ const url = new URL(endpoint, this.config.baseUrl);
320
+ url.searchParams.set("apikey", this.config.apiKey);
321
+ if (params) {
322
+ for (const [key, value] of Object.entries(params)) {
323
+ if (value !== void 0 && value !== null) {
324
+ url.searchParams.set(key, String(value));
325
+ }
326
+ }
327
+ }
328
+ return url.toString();
329
+ }
330
+ handleError(statusCode, data) {
331
+ const message = data?.message || "Request failed";
332
+ switch (statusCode) {
333
+ case 401:
334
+ throw new AuthenticationError(message);
335
+ case 402:
336
+ throw new InsufficientTokensError(message);
337
+ default:
338
+ throw new CountryDataApiError(message, statusCode, data);
339
+ }
340
+ }
341
+ handleApiError(data) {
342
+ const message = data.message || "API error";
343
+ if (message.includes("Invalid API key")) {
344
+ throw new AuthenticationError(message);
345
+ }
346
+ if (message.includes("No remaining tokens")) {
347
+ throw new InsufficientTokensError(message);
348
+ }
349
+ throw new CountryDataApiError(message);
350
+ }
351
+ };
352
+
353
+ // src/client.ts
354
+ var CountryDataApi = class {
355
+ /**
356
+ * Create a new Country Data API client
357
+ * @example
358
+ * const api = new CountryDataApi({ apiKey: 'your-api-key' });
359
+ * const countries = await api.countries.getAll({ lang: 'es' });
360
+ */
361
+ constructor(config) {
362
+ if (!config.apiKey) {
363
+ throw new Error("API key is required");
364
+ }
365
+ this.config = {
366
+ apiKey: config.apiKey,
367
+ baseUrl: config.baseUrl ?? "https://api.countrydataapi.com",
368
+ timeout: config.timeout ?? 3e4,
369
+ defaultLanguage: config.defaultLanguage ?? "en"
370
+ };
371
+ this.http = new HttpClient({
372
+ apiKey: this.config.apiKey,
373
+ baseUrl: this.config.baseUrl,
374
+ timeout: this.config.timeout
375
+ });
376
+ this.countries = new Countries(this.http);
377
+ this.states = new States(this.http);
378
+ this.cities = new Cities(this.http);
379
+ this.zipcodes = new Zipcodes(this.http);
380
+ this.select = new Select(this.http);
381
+ }
382
+ /**
383
+ * Get remaining tokens for your API key
384
+ * @example
385
+ * const status = await api.getStatus();
386
+ * console.log(`Remaining tokens: ${status.remainingTokens}`);
387
+ */
388
+ async getStatus() {
389
+ return this.http.get("/v1/status");
390
+ }
391
+ };
392
+ export {
393
+ AuthenticationError,
394
+ CountryDataApi,
395
+ CountryDataApiError,
396
+ InsufficientTokensError,
397
+ RateLimitError,
398
+ ValidationError
399
+ };
400
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/resources/countries.ts","../src/resources/states.ts","../src/resources/cities.ts","../src/resources/zipcodes.ts","../src/resources/select.ts","../src/utils/errors.ts","../src/utils/http.ts","../src/client.ts"],"sourcesContent":["/**\r\n * Countries resource for Country Data API SDK\r\n */\r\n\r\nimport type { Country, ApiResponse, RequestOptions } from '../types';\r\nimport type { HttpClient } from '../utils/http';\r\n\r\nexport interface GetCountryByNameOptions extends RequestOptions {\r\n name: string;\r\n}\r\n\r\nexport interface GetCountryByCodeOptions extends RequestOptions {\r\n code: string;\r\n}\r\n\r\nexport interface GetCountriesByRegionOptions extends RequestOptions {\r\n region: string;\r\n}\r\n\r\nexport interface GetCountriesByCurrencyOptions extends RequestOptions {\r\n currency: string;\r\n}\r\n\r\nexport interface GetCountriesByLanguageOptions extends RequestOptions {\r\n language: string;\r\n}\r\n\r\nexport interface GetCountriesByTimezoneOptions extends RequestOptions {\r\n timezone: string;\r\n}\r\n\r\nexport interface GetCountriesByStateOptions extends RequestOptions {\r\n state: string;\r\n}\r\n\r\nexport interface GetCountriesByCityOptions extends RequestOptions {\r\n city: string;\r\n}\r\n\r\nexport interface GetCountriesByZipCodeOptions extends RequestOptions {\r\n zipCode: string;\r\n}\r\n\r\nexport class Countries {\r\n constructor(private readonly http: HttpClient) {}\r\n\r\n /**\r\n * Get all countries\r\n * @example\r\n * const countries = await api.countries.getAll({ lang: 'es', limit: 50 });\r\n */\r\n async getAll(options?: RequestOptions): Promise<ApiResponse<Country>> {\r\n return this.http.get<ApiResponse<Country>>('/v1/countries/all', options);\r\n }\r\n\r\n /**\r\n * Get country by name\r\n * @example\r\n * const spain = await api.countries.getByName({ name: 'Spain' });\r\n */\r\n async getByName(options: GetCountryByNameOptions): Promise<ApiResponse<Country>> {\r\n return this.http.get<ApiResponse<Country>>('/v1/countries/name', options);\r\n }\r\n\r\n /**\r\n * Get country by ISO code (alpha-2, alpha-3, numeric, or CIOC)\r\n * @example\r\n * const spain = await api.countries.getByCode({ code: 'ES' });\r\n */\r\n async getByCode(options: GetCountryByCodeOptions): Promise<ApiResponse<Country>> {\r\n return this.http.get<ApiResponse<Country>>('/v1/countries/code', options);\r\n }\r\n\r\n /**\r\n * Get countries by region\r\n * @example\r\n * const european = await api.countries.getByRegion({ region: 'Europe' });\r\n */\r\n async getByRegion(options: GetCountriesByRegionOptions): Promise<ApiResponse<Country>> {\r\n return this.http.get<ApiResponse<Country>>('/v1/countries/region', options);\r\n }\r\n\r\n /**\r\n * Get countries by currency code\r\n * @example\r\n * const euroCountries = await api.countries.getByCurrency({ currency: 'EUR' });\r\n */\r\n async getByCurrency(options: GetCountriesByCurrencyOptions): Promise<ApiResponse<Country>> {\r\n return this.http.get<ApiResponse<Country>>('/v1/countries/currency', options);\r\n }\r\n\r\n /**\r\n * Get countries by language\r\n * @example\r\n * const spanishSpeaking = await api.countries.getByLanguage({ language: 'spa' });\r\n */\r\n async getByLanguage(options: GetCountriesByLanguageOptions): Promise<ApiResponse<Country>> {\r\n return this.http.get<ApiResponse<Country>>('/v1/countries/language', options);\r\n }\r\n\r\n /**\r\n * Get countries by timezone\r\n * @example\r\n * const utcCountries = await api.countries.getByTimezone({ timezone: 'UTC' });\r\n */\r\n async getByTimezone(options: GetCountriesByTimezoneOptions): Promise<ApiResponse<Country>> {\r\n return this.http.get<ApiResponse<Country>>('/v1/countries/timezone', options);\r\n }\r\n\r\n /**\r\n * Get countries by state\r\n * @example\r\n * const countries = await api.countries.getByState({ state: 'California' });\r\n */\r\n async getByState(options: GetCountriesByStateOptions): Promise<ApiResponse<Country>> {\r\n return this.http.get<ApiResponse<Country>>('/v1/countries/state', options);\r\n }\r\n\r\n /**\r\n * Get countries by city\r\n * @example\r\n * const countries = await api.countries.getByCity({ city: 'Madrid' });\r\n */\r\n async getByCity(options: GetCountriesByCityOptions): Promise<ApiResponse<Country>> {\r\n return this.http.get<ApiResponse<Country>>('/v1/countries/city', options);\r\n }\r\n\r\n /**\r\n * Get countries by zip code\r\n * @example\r\n * const countries = await api.countries.getByZipCode({ zipCode: '28001' });\r\n */\r\n async getByZipCode(options: GetCountriesByZipCodeOptions): Promise<ApiResponse<Country>> {\r\n return this.http.get<ApiResponse<Country>>('/v1/countries/zipCode', options);\r\n }\r\n}\r\n","/**\r\n * States resource for Country Data API SDK\r\n */\r\n\r\nimport type { State, ApiResponse, RequestOptions } from '../types';\r\nimport type { HttpClient } from '../utils/http';\r\n\r\nexport interface GetStateByNameOptions extends RequestOptions {\r\n state: string;\r\n}\r\n\r\nexport interface GetStatesByCountryOptions extends RequestOptions {\r\n country: string;\r\n}\r\n\r\nexport interface GetStatesByCityOptions extends RequestOptions {\r\n city: string;\r\n}\r\n\r\nexport interface GetStatesByZipcodeOptions extends RequestOptions {\r\n zipcode: string;\r\n}\r\n\r\nexport class States {\r\n constructor(private readonly http: HttpClient) {}\r\n\r\n /**\r\n * Get all states\r\n * @example\r\n * const states = await api.states.getAll({ lang: 'es' });\r\n */\r\n async getAll(options?: RequestOptions & { limitStates?: number }): Promise<ApiResponse<State>> {\r\n return this.http.get<ApiResponse<State>>('/v1/states/all', options);\r\n }\r\n\r\n /**\r\n * Get state by name\r\n * @example\r\n * const state = await api.states.getByName({ state: 'Madrid' });\r\n */\r\n async getByName(options: GetStateByNameOptions): Promise<ApiResponse<State>> {\r\n return this.http.get<ApiResponse<State>>('/v1/states/', options);\r\n }\r\n\r\n /**\r\n * Get states by country\r\n * @example\r\n * const spanishStates = await api.states.getByCountry({ country: 'Spain' });\r\n */\r\n async getByCountry(options: GetStatesByCountryOptions): Promise<ApiResponse<State>> {\r\n return this.http.get<ApiResponse<State>>('/v1/states/country', options);\r\n }\r\n\r\n /**\r\n * Get states by city\r\n * @example\r\n * const states = await api.states.getByCity({ city: 'Madrid' });\r\n */\r\n async getByCity(options: GetStatesByCityOptions): Promise<ApiResponse<State>> {\r\n return this.http.get<ApiResponse<State>>('/v1/states/city', options);\r\n }\r\n\r\n /**\r\n * Get states by zipcode\r\n * @example\r\n * const states = await api.states.getByZipcode({ zipcode: '28001' });\r\n */\r\n async getByZipcode(options: GetStatesByZipcodeOptions): Promise<ApiResponse<State>> {\r\n return this.http.get<ApiResponse<State>>('/v1/states/zipcode', options);\r\n }\r\n}\r\n","/**\r\n * Cities resource for Country Data API SDK\r\n */\r\n\r\nimport type { City, ApiResponse, RequestOptions } from '../types';\r\nimport type { HttpClient } from '../utils/http';\r\n\r\nexport interface GetCityOptions extends RequestOptions {\r\n city: string;\r\n}\r\n\r\nexport interface GetCitiesByCountryOptions extends RequestOptions {\r\n country: string;\r\n}\r\n\r\nexport interface GetCitiesByStateOptions extends RequestOptions {\r\n state: string;\r\n}\r\n\r\nexport class Cities {\r\n constructor(private readonly http: HttpClient) {}\r\n\r\n /**\r\n * Get all cities\r\n * @example\r\n * const cities = await api.cities.getAll({ lang: 'es', limitToken: 100 });\r\n */\r\n async getAll(options?: RequestOptions): Promise<ApiResponse<City>> {\r\n return this.http.get<ApiResponse<City>>('/v1/cities/all', options);\r\n }\r\n\r\n /**\r\n * Get city by name or ID\r\n * @example\r\n * const city = await api.cities.get({ city: 'Madrid' });\r\n */\r\n async get(options: GetCityOptions): Promise<ApiResponse<City>> {\r\n return this.http.get<ApiResponse<City>>('/v1/cities/', options);\r\n }\r\n\r\n /**\r\n * Get cities by country\r\n * @example\r\n * const cities = await api.cities.getByCountry({ country: 'Spain' });\r\n */\r\n async getByCountry(options: GetCitiesByCountryOptions): Promise<ApiResponse<City>> {\r\n return this.http.get<ApiResponse<City>>('/v1/cities/country', options);\r\n }\r\n\r\n /**\r\n * Get cities by state\r\n * @example\r\n * const cities = await api.cities.getByState({ state: 'Madrid' });\r\n */\r\n async getByState(options: GetCitiesByStateOptions): Promise<ApiResponse<City>> {\r\n return this.http.get<ApiResponse<City>>('/v1/cities/state', options);\r\n }\r\n}\r\n","/**\r\n * Zipcodes resource for Country Data API SDK\r\n */\r\n\r\nimport type { ApiResponse, RequestOptions } from '../types';\r\nimport type { HttpClient } from '../utils/http';\r\n\r\nexport interface GetZipcodesByStateOptions extends RequestOptions {\r\n state: string;\r\n}\r\n\r\nexport interface GetZipcodesByCountryOptions extends RequestOptions {\r\n country: string;\r\n}\r\n\r\nexport interface GetZipcodesByRegionOptions extends RequestOptions {\r\n region: string;\r\n}\r\n\r\nexport class Zipcodes {\r\n constructor(private readonly http: HttpClient) {}\r\n\r\n /**\r\n * Get all zipcodes\r\n * @example\r\n * const zipcodes = await api.zipcodes.getAll({ limitToken: 100 });\r\n */\r\n async getAll(options?: RequestOptions): Promise<ApiResponse<string>> {\r\n return this.http.get<ApiResponse<string>>('/v1/zipcodes/all', options);\r\n }\r\n\r\n /**\r\n * Get zipcodes by state\r\n * @example\r\n * const zipcodes = await api.zipcodes.getByState({ state: 'Madrid' });\r\n */\r\n async getByState(options: GetZipcodesByStateOptions): Promise<ApiResponse<string>> {\r\n return this.http.get<ApiResponse<string>>('/v1/zipcodes/state', options);\r\n }\r\n\r\n /**\r\n * Get zipcodes by country\r\n * @example\r\n * const zipcodes = await api.zipcodes.getByCountry({ country: 'Spain' });\r\n */\r\n async getByCountry(options: GetZipcodesByCountryOptions): Promise<ApiResponse<string>> {\r\n return this.http.get<ApiResponse<string>>('/v1/zipcodes/country', options);\r\n }\r\n\r\n /**\r\n * Get zipcodes by region\r\n * @example\r\n * const zipcodes = await api.zipcodes.getByRegion({ region: 'Europe' });\r\n */\r\n async getByRegion(options: GetZipcodesByRegionOptions): Promise<ApiResponse<string>> {\r\n return this.http.get<ApiResponse<string>>('/v1/zipcodes/region', options);\r\n }\r\n}\r\n","/**\r\n * Select resource for Country Data API SDK\r\n * Optimized endpoints for dropdowns (costs only 1 token)\r\n */\r\n\r\nimport type { SelectCountry, SelectState, SelectCity, ApiResponse, Language } from '../types';\r\nimport type { HttpClient } from '../utils/http';\r\n\r\nexport interface SelectCountriesOptions {\r\n lang?: Language;\r\n [key: string]: unknown;\r\n}\r\n\r\nexport interface SelectStatesOptions {\r\n country: string;\r\n lang?: Language;\r\n [key: string]: unknown;\r\n}\r\n\r\nexport interface SelectCitiesOptions {\r\n state: string;\r\n country?: string;\r\n lang?: Language;\r\n [key: string]: unknown;\r\n}\r\n\r\nexport class Select {\r\n constructor(private readonly http: HttpClient) {}\r\n\r\n /**\r\n * Get countries optimized for select/dropdown (costs 1 token)\r\n * @example\r\n * const countries = await api.select.countries({ lang: 'es' });\r\n */\r\n async countries(options?: SelectCountriesOptions): Promise<ApiResponse<SelectCountry>> {\r\n return this.http.get<ApiResponse<SelectCountry>>('/v1/select/countries', options);\r\n }\r\n\r\n /**\r\n * Get states for a country optimized for select/dropdown (costs 1 token)\r\n * @example\r\n * const states = await api.select.states({ country: 'ES' });\r\n */\r\n async states(options: SelectStatesOptions): Promise<ApiResponse<SelectState>> {\r\n return this.http.get<ApiResponse<SelectState>>('/v1/select/states', options);\r\n }\r\n\r\n /**\r\n * Get cities for a state optimized for select/dropdown (costs 1 token)\r\n * @example\r\n * const cities = await api.select.cities({ state: 'Madrid', country: 'ES' });\r\n */\r\n async cities(options: SelectCitiesOptions): Promise<ApiResponse<SelectCity>> {\r\n return this.http.get<ApiResponse<SelectCity>>('/v1/select/cities', options);\r\n }\r\n}\r\n","/**\r\n * Error classes for Country Data API SDK\r\n */\r\n\r\nexport class CountryDataApiError extends Error {\r\n constructor(\r\n message: string,\r\n public readonly statusCode?: number,\r\n public readonly response?: unknown\r\n ) {\r\n super(message);\r\n this.name = 'CountryDataApiError';\r\n }\r\n}\r\n\r\nexport class AuthenticationError extends CountryDataApiError {\r\n constructor(message: string = 'Invalid API key') {\r\n super(message, 401);\r\n this.name = 'AuthenticationError';\r\n }\r\n}\r\n\r\nexport class RateLimitError extends CountryDataApiError {\r\n constructor(message: string = 'Rate limit exceeded') {\r\n super(message, 429);\r\n this.name = 'RateLimitError';\r\n }\r\n}\r\n\r\nexport class InsufficientTokensError extends CountryDataApiError {\r\n constructor(message: string = 'No remaining tokens available') {\r\n super(message, 402);\r\n this.name = 'InsufficientTokensError';\r\n }\r\n}\r\n\r\nexport class ValidationError extends CountryDataApiError {\r\n constructor(message: string) {\r\n super(message, 400);\r\n this.name = 'ValidationError';\r\n }\r\n}\r\n","/**\r\n * HTTP client for Country Data API SDK\r\n */\r\n\r\nimport { CountryDataApiError, AuthenticationError, InsufficientTokensError } from './errors';\r\n\r\nexport interface HttpClientConfig {\r\n apiKey: string;\r\n baseUrl: string;\r\n timeout: number;\r\n}\r\n\r\nexport class HttpClient {\r\n private readonly config: HttpClientConfig;\r\n\r\n constructor(config: HttpClientConfig) {\r\n this.config = config;\r\n }\r\n\r\n async get<T>(endpoint: string, params?: Record<string, unknown>): Promise<T> {\r\n const url = this.buildUrl(endpoint, params);\r\n\r\n const controller = new AbortController();\r\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\r\n\r\n try {\r\n const response = await fetch(url, {\r\n method: 'GET',\r\n headers: {\r\n 'Accept': 'application/json',\r\n },\r\n signal: controller.signal,\r\n });\r\n\r\n clearTimeout(timeoutId);\r\n\r\n const data = await response.json();\r\n\r\n if (!response.ok) {\r\n this.handleError(response.status, data);\r\n }\r\n\r\n if (data.error) {\r\n this.handleApiError(data);\r\n }\r\n\r\n return data as T;\r\n } catch (error) {\r\n clearTimeout(timeoutId);\r\n\r\n if (error instanceof CountryDataApiError) {\r\n throw error;\r\n }\r\n\r\n if (error instanceof Error) {\r\n if (error.name === 'AbortError') {\r\n throw new CountryDataApiError('Request timeout', 408);\r\n }\r\n throw new CountryDataApiError(error.message);\r\n }\r\n\r\n throw new CountryDataApiError('Unknown error occurred');\r\n }\r\n }\r\n\r\n private buildUrl(endpoint: string, params?: Record<string, unknown>): string {\r\n const url = new URL(endpoint, this.config.baseUrl);\r\n\r\n // Always add API key\r\n url.searchParams.set('apikey', this.config.apiKey);\r\n\r\n if (params) {\r\n for (const [key, value] of Object.entries(params)) {\r\n if (value !== undefined && value !== null) {\r\n url.searchParams.set(key, String(value));\r\n }\r\n }\r\n }\r\n\r\n return url.toString();\r\n }\r\n\r\n private handleError(statusCode: number, data: unknown): never {\r\n const message = (data as { message?: string })?.message || 'Request failed';\r\n\r\n switch (statusCode) {\r\n case 401:\r\n throw new AuthenticationError(message);\r\n case 402:\r\n throw new InsufficientTokensError(message);\r\n default:\r\n throw new CountryDataApiError(message, statusCode, data);\r\n }\r\n }\r\n\r\n private handleApiError(data: { error: boolean; message: string }): never {\r\n const message = data.message || 'API error';\r\n\r\n if (message.includes('Invalid API key')) {\r\n throw new AuthenticationError(message);\r\n }\r\n\r\n if (message.includes('No remaining tokens')) {\r\n throw new InsufficientTokensError(message);\r\n }\r\n\r\n throw new CountryDataApiError(message);\r\n }\r\n}\r\n","/**\r\n * Main client for Country Data API SDK\r\n */\r\n\r\nimport { Countries } from './resources/countries';\r\nimport { States } from './resources/states';\r\nimport { Cities } from './resources/cities';\r\nimport { Zipcodes } from './resources/zipcodes';\r\nimport { Select } from './resources/select';\r\nimport { HttpClient } from './utils/http';\r\nimport type { Language, StatusResponse } from './types';\r\n\r\nexport interface CountryDataApiConfig {\r\n /**\r\n * Your API key from countrydataapi.com\r\n */\r\n apiKey: string;\r\n /**\r\n * Base URL for the API (default: https://api.countrydataapi.com)\r\n */\r\n baseUrl?: string;\r\n /**\r\n * Request timeout in milliseconds (default: 30000)\r\n */\r\n timeout?: number;\r\n /**\r\n * Default language for responses (default: 'en')\r\n */\r\n defaultLanguage?: Language;\r\n}\r\n\r\nexport class CountryDataApi {\r\n private readonly http: HttpClient;\r\n private readonly config: Required<CountryDataApiConfig>;\r\n\r\n /**\r\n * Countries resource - query country data\r\n */\r\n public readonly countries: Countries;\r\n\r\n /**\r\n * States resource - query state/province data\r\n */\r\n public readonly states: States;\r\n\r\n /**\r\n * Cities resource - query city data\r\n */\r\n public readonly cities: Cities;\r\n\r\n /**\r\n * Zipcodes resource - query postal code data\r\n */\r\n public readonly zipcodes: Zipcodes;\r\n\r\n /**\r\n * Select resource - optimized endpoints for dropdowns (1 token each)\r\n */\r\n public readonly select: Select;\r\n\r\n /**\r\n * Create a new Country Data API client\r\n * @example\r\n * const api = new CountryDataApi({ apiKey: 'your-api-key' });\r\n * const countries = await api.countries.getAll({ lang: 'es' });\r\n */\r\n constructor(config: CountryDataApiConfig) {\r\n if (!config.apiKey) {\r\n throw new Error('API key is required');\r\n }\r\n\r\n this.config = {\r\n apiKey: config.apiKey,\r\n baseUrl: config.baseUrl ?? 'https://api.countrydataapi.com',\r\n timeout: config.timeout ?? 30000,\r\n defaultLanguage: config.defaultLanguage ?? 'en',\r\n };\r\n\r\n this.http = new HttpClient({\r\n apiKey: this.config.apiKey,\r\n baseUrl: this.config.baseUrl,\r\n timeout: this.config.timeout,\r\n });\r\n\r\n this.countries = new Countries(this.http);\r\n this.states = new States(this.http);\r\n this.cities = new Cities(this.http);\r\n this.zipcodes = new Zipcodes(this.http);\r\n this.select = new Select(this.http);\r\n }\r\n\r\n /**\r\n * Get remaining tokens for your API key\r\n * @example\r\n * const status = await api.getStatus();\r\n * console.log(`Remaining tokens: ${status.remainingTokens}`);\r\n */\r\n async getStatus(): Prom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EAmC1B,YAAY,QAA8B;AACxC,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,qBAAqB;AAAA,IACvC;AAEA,SAAK,SAAS;AAAA,MACZ,QAAQ,OAAO;AAAA,MACf,SAAS,OAAO,WAAW;AAAA,MAC3B,SAAS,OAAO,WAAW;AAAA,MAC3B,iBAAiB,OAAO,mBAAmB;AAAA,IAC7C;AAEA,SAAK,OAAO,IAAI,WAAW;AAAA,MACzB,QAAQ,KAAK,OAAO;AAAA,MACpB,SAAS,KAAK,OAAO;AAAA,MACrB,SAAS,KAAK,OAAO;AAAA,IACvB,CAAC;AAED,SAAK,YAAY,IAAI,UAAU,KAAK,IAAI;AACxC,SAAK,SAAS,IAAI,OAAO,KAAK,IAAI;AAClC,SAAK,SAAS,IAAI,OAAO,KAAK,IAAI;AAClC,SAAK,WAAW,IAAI,SAAS,KAAK,IAAI;AACtC,SAAK,SAAS,IAAI,OAAO,KAAK,IAAI;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,YAAqC;AACzC,WAAO,KAAK,KAAK,IAAoB,YAAY;AAAA,EACnD;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@countrydataapi/sdk",
3
+ "version": "1.0.0",
4
+ "description": "Official TypeScript/JavaScript SDK for Country Data API - Access countries, states, cities, and postal codes worldwide",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/index.mjs",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "dev": "tsup --watch",
22
+ "clean": "rimraf dist",
23
+ "prepublishOnly": "npm run build",
24
+ "test": "vitest",
25
+ "test:coverage": "vitest --coverage",
26
+ "lint": "eslint src --ext .ts",
27
+ "typecheck": "tsc --noEmit"
28
+ },
29
+ "keywords": [
30
+ "countries",
31
+ "states",
32
+ "cities",
33
+ "zipcodes",
34
+ "postal-codes",
35
+ "geography",
36
+ "api",
37
+ "rest",
38
+ "sdk",
39
+ "typescript",
40
+ "javascript"
41
+ ],
42
+ "author": "Country Data API <support@countrydataapi.com>",
43
+ "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "https://github.com/countrydataapi/country-data-api-sdk"
47
+ },
48
+ "homepage": "https://countrydataapi.com",
49
+ "bugs": {
50
+ "url": "https://github.com/countrydataapi/country-data-api-sdk/issues"
51
+ },
52
+ "engines": {
53
+ "node": ">=16.0.0"
54
+ },
55
+ "devDependencies": {
56
+ "@types/node": "^20.0.0",
57
+ "rimraf": "^5.0.0",
58
+ "tsup": "^8.0.0",
59
+ "typescript": "^5.3.0"
60
+ }
61
+ }