@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/README.md +222 -0
- package/dist/index.d.mts +562 -0
- package/dist/index.d.ts +562 -0
- package/dist/index.js +432 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +400 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +61 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common types for Country Data API SDK
|
|
3
|
+
*/
|
|
4
|
+
type Language = 'en' | 'es' | 'pt' | 'fr' | 'de' | 'it';
|
|
5
|
+
interface ApiResponse<T> {
|
|
6
|
+
success: boolean;
|
|
7
|
+
data: T[];
|
|
8
|
+
count: number;
|
|
9
|
+
tokens_used: number;
|
|
10
|
+
remaining_tokens?: number;
|
|
11
|
+
cost_per_item?: number;
|
|
12
|
+
}
|
|
13
|
+
interface ApiError {
|
|
14
|
+
error: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
interface RequestOptions {
|
|
18
|
+
fields?: string;
|
|
19
|
+
lang?: Language;
|
|
20
|
+
limit?: number;
|
|
21
|
+
limitToken?: number;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
interface StatusResponse {
|
|
25
|
+
remainingTokens: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Country types for Country Data API SDK
|
|
30
|
+
*/
|
|
31
|
+
interface Currency {
|
|
32
|
+
currency: string;
|
|
33
|
+
name: string;
|
|
34
|
+
symbol: string;
|
|
35
|
+
}
|
|
36
|
+
interface CountryLanguage {
|
|
37
|
+
language: string;
|
|
38
|
+
name: string;
|
|
39
|
+
}
|
|
40
|
+
interface Translation {
|
|
41
|
+
translation: string;
|
|
42
|
+
official: string;
|
|
43
|
+
common: string;
|
|
44
|
+
}
|
|
45
|
+
interface CarInfo {
|
|
46
|
+
signs: string[];
|
|
47
|
+
side: string;
|
|
48
|
+
}
|
|
49
|
+
interface CapitalInfo {
|
|
50
|
+
lat: string;
|
|
51
|
+
lng: string;
|
|
52
|
+
}
|
|
53
|
+
interface IddInfo {
|
|
54
|
+
root: string;
|
|
55
|
+
suffixes: string[];
|
|
56
|
+
}
|
|
57
|
+
interface Gini {
|
|
58
|
+
year: string;
|
|
59
|
+
value: string;
|
|
60
|
+
}
|
|
61
|
+
interface Demonym {
|
|
62
|
+
lang: string;
|
|
63
|
+
f: string;
|
|
64
|
+
m: string;
|
|
65
|
+
}
|
|
66
|
+
interface Country {
|
|
67
|
+
id: string;
|
|
68
|
+
lang: string;
|
|
69
|
+
country_name: string;
|
|
70
|
+
country_short_iso?: string;
|
|
71
|
+
country_phone_code?: string;
|
|
72
|
+
country_cca2?: string;
|
|
73
|
+
country_ccn3?: string;
|
|
74
|
+
country_cca3?: string;
|
|
75
|
+
country_cioc?: string;
|
|
76
|
+
country_independent?: boolean;
|
|
77
|
+
country_status?: string;
|
|
78
|
+
country_unMember?: boolean;
|
|
79
|
+
country_capital?: string[];
|
|
80
|
+
country_altSpellings?: string[];
|
|
81
|
+
country_region?: string;
|
|
82
|
+
country_subregion?: string;
|
|
83
|
+
country_latLng?: string[];
|
|
84
|
+
country_landlocked?: boolean;
|
|
85
|
+
country_borders?: string[];
|
|
86
|
+
country_area?: string;
|
|
87
|
+
country_flag?: string;
|
|
88
|
+
country_map_googleMaps?: string;
|
|
89
|
+
country_map_openStreetMaps?: string;
|
|
90
|
+
country_population?: string;
|
|
91
|
+
country_fifa?: string;
|
|
92
|
+
country_timezones?: string[];
|
|
93
|
+
country_continents?: string[];
|
|
94
|
+
country_flag_png?: string;
|
|
95
|
+
country_flag_svg?: string;
|
|
96
|
+
country_flag_alt?: string;
|
|
97
|
+
country_coatOfArms_png?: string;
|
|
98
|
+
country_coatOfArms_svg?: string;
|
|
99
|
+
country_startofWeek?: string;
|
|
100
|
+
country_postal_code_format?: string;
|
|
101
|
+
country_postal_code_regex?: string;
|
|
102
|
+
country_continent_code?: string;
|
|
103
|
+
country_tld?: string[];
|
|
104
|
+
country_currencies?: Currency[];
|
|
105
|
+
country_languages?: CountryLanguage[];
|
|
106
|
+
country_translations?: Translation[];
|
|
107
|
+
country_car_info?: CarInfo;
|
|
108
|
+
country_capital_info?: CapitalInfo[];
|
|
109
|
+
country_gini?: Gini;
|
|
110
|
+
country_demonyms?: Demonym[];
|
|
111
|
+
country_name_additional_info?: Record<string, unknown>;
|
|
112
|
+
country_idd_info?: IddInfo;
|
|
113
|
+
country_current_currency?: string;
|
|
114
|
+
country_GDP?: string;
|
|
115
|
+
country_GDP_per_capita_PPP?: string;
|
|
116
|
+
country_location?: string;
|
|
117
|
+
country_land?: string;
|
|
118
|
+
country_terrain?: string;
|
|
119
|
+
country_climate?: string;
|
|
120
|
+
country_natural_hazards?: string;
|
|
121
|
+
country_note?: string;
|
|
122
|
+
country_history?: string;
|
|
123
|
+
country_life_expectancy?: string;
|
|
124
|
+
country_median_age?: string;
|
|
125
|
+
country_birth_rate?: string;
|
|
126
|
+
country_death_rate?: string;
|
|
127
|
+
country_sex_ratio?: string;
|
|
128
|
+
country_literacy?: string;
|
|
129
|
+
country_roadways?: string;
|
|
130
|
+
country_airports?: string;
|
|
131
|
+
country_railways?: string;
|
|
132
|
+
country_waterways?: string;
|
|
133
|
+
country_heliports?: string;
|
|
134
|
+
country_airports_paved?: string;
|
|
135
|
+
country_wikipedia_url?: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* State types for Country Data API SDK
|
|
140
|
+
*/
|
|
141
|
+
interface State {
|
|
142
|
+
id: string;
|
|
143
|
+
lang: string;
|
|
144
|
+
state_name: string;
|
|
145
|
+
state_cities?: string[];
|
|
146
|
+
state_zip_codes?: string[];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* City types for Country Data API SDK
|
|
151
|
+
*/
|
|
152
|
+
interface City {
|
|
153
|
+
id: string;
|
|
154
|
+
lang: string;
|
|
155
|
+
city_name: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Zipcode types for Country Data API SDK
|
|
160
|
+
*/
|
|
161
|
+
interface Zipcode {
|
|
162
|
+
id: string;
|
|
163
|
+
lang: string;
|
|
164
|
+
zipcode: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Select types for Country Data API SDK
|
|
169
|
+
* Optimized lightweight responses for dropdowns
|
|
170
|
+
*/
|
|
171
|
+
interface SelectCountry {
|
|
172
|
+
id: string;
|
|
173
|
+
name: string;
|
|
174
|
+
code: string;
|
|
175
|
+
phone_code: string;
|
|
176
|
+
flag: string;
|
|
177
|
+
}
|
|
178
|
+
interface SelectState {
|
|
179
|
+
id: string;
|
|
180
|
+
name: string;
|
|
181
|
+
}
|
|
182
|
+
interface SelectCity {
|
|
183
|
+
id: string;
|
|
184
|
+
name: string;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* HTTP client for Country Data API SDK
|
|
189
|
+
*/
|
|
190
|
+
interface HttpClientConfig {
|
|
191
|
+
apiKey: string;
|
|
192
|
+
baseUrl: string;
|
|
193
|
+
timeout: number;
|
|
194
|
+
}
|
|
195
|
+
declare class HttpClient {
|
|
196
|
+
private readonly config;
|
|
197
|
+
constructor(config: HttpClientConfig);
|
|
198
|
+
get<T>(endpoint: string, params?: Record<string, unknown>): Promise<T>;
|
|
199
|
+
private buildUrl;
|
|
200
|
+
private handleError;
|
|
201
|
+
private handleApiError;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Countries resource for Country Data API SDK
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
interface GetCountryByNameOptions extends RequestOptions {
|
|
209
|
+
name: string;
|
|
210
|
+
}
|
|
211
|
+
interface GetCountryByCodeOptions extends RequestOptions {
|
|
212
|
+
code: string;
|
|
213
|
+
}
|
|
214
|
+
interface GetCountriesByRegionOptions extends RequestOptions {
|
|
215
|
+
region: string;
|
|
216
|
+
}
|
|
217
|
+
interface GetCountriesByCurrencyOptions extends RequestOptions {
|
|
218
|
+
currency: string;
|
|
219
|
+
}
|
|
220
|
+
interface GetCountriesByLanguageOptions extends RequestOptions {
|
|
221
|
+
language: string;
|
|
222
|
+
}
|
|
223
|
+
interface GetCountriesByTimezoneOptions extends RequestOptions {
|
|
224
|
+
timezone: string;
|
|
225
|
+
}
|
|
226
|
+
interface GetCountriesByStateOptions extends RequestOptions {
|
|
227
|
+
state: string;
|
|
228
|
+
}
|
|
229
|
+
interface GetCountriesByCityOptions extends RequestOptions {
|
|
230
|
+
city: string;
|
|
231
|
+
}
|
|
232
|
+
interface GetCountriesByZipCodeOptions extends RequestOptions {
|
|
233
|
+
zipCode: string;
|
|
234
|
+
}
|
|
235
|
+
declare class Countries {
|
|
236
|
+
private readonly http;
|
|
237
|
+
constructor(http: HttpClient);
|
|
238
|
+
/**
|
|
239
|
+
* Get all countries
|
|
240
|
+
* @example
|
|
241
|
+
* const countries = await api.countries.getAll({ lang: 'es', limit: 50 });
|
|
242
|
+
*/
|
|
243
|
+
getAll(options?: RequestOptions): Promise<ApiResponse<Country>>;
|
|
244
|
+
/**
|
|
245
|
+
* Get country by name
|
|
246
|
+
* @example
|
|
247
|
+
* const spain = await api.countries.getByName({ name: 'Spain' });
|
|
248
|
+
*/
|
|
249
|
+
getByName(options: GetCountryByNameOptions): Promise<ApiResponse<Country>>;
|
|
250
|
+
/**
|
|
251
|
+
* Get country by ISO code (alpha-2, alpha-3, numeric, or CIOC)
|
|
252
|
+
* @example
|
|
253
|
+
* const spain = await api.countries.getByCode({ code: 'ES' });
|
|
254
|
+
*/
|
|
255
|
+
getByCode(options: GetCountryByCodeOptions): Promise<ApiResponse<Country>>;
|
|
256
|
+
/**
|
|
257
|
+
* Get countries by region
|
|
258
|
+
* @example
|
|
259
|
+
* const european = await api.countries.getByRegion({ region: 'Europe' });
|
|
260
|
+
*/
|
|
261
|
+
getByRegion(options: GetCountriesByRegionOptions): Promise<ApiResponse<Country>>;
|
|
262
|
+
/**
|
|
263
|
+
* Get countries by currency code
|
|
264
|
+
* @example
|
|
265
|
+
* const euroCountries = await api.countries.getByCurrency({ currency: 'EUR' });
|
|
266
|
+
*/
|
|
267
|
+
getByCurrency(options: GetCountriesByCurrencyOptions): Promise<ApiResponse<Country>>;
|
|
268
|
+
/**
|
|
269
|
+
* Get countries by language
|
|
270
|
+
* @example
|
|
271
|
+
* const spanishSpeaking = await api.countries.getByLanguage({ language: 'spa' });
|
|
272
|
+
*/
|
|
273
|
+
getByLanguage(options: GetCountriesByLanguageOptions): Promise<ApiResponse<Country>>;
|
|
274
|
+
/**
|
|
275
|
+
* Get countries by timezone
|
|
276
|
+
* @example
|
|
277
|
+
* const utcCountries = await api.countries.getByTimezone({ timezone: 'UTC' });
|
|
278
|
+
*/
|
|
279
|
+
getByTimezone(options: GetCountriesByTimezoneOptions): Promise<ApiResponse<Country>>;
|
|
280
|
+
/**
|
|
281
|
+
* Get countries by state
|
|
282
|
+
* @example
|
|
283
|
+
* const countries = await api.countries.getByState({ state: 'California' });
|
|
284
|
+
*/
|
|
285
|
+
getByState(options: GetCountriesByStateOptions): Promise<ApiResponse<Country>>;
|
|
286
|
+
/**
|
|
287
|
+
* Get countries by city
|
|
288
|
+
* @example
|
|
289
|
+
* const countries = await api.countries.getByCity({ city: 'Madrid' });
|
|
290
|
+
*/
|
|
291
|
+
getByCity(options: GetCountriesByCityOptions): Promise<ApiResponse<Country>>;
|
|
292
|
+
/**
|
|
293
|
+
* Get countries by zip code
|
|
294
|
+
* @example
|
|
295
|
+
* const countries = await api.countries.getByZipCode({ zipCode: '28001' });
|
|
296
|
+
*/
|
|
297
|
+
getByZipCode(options: GetCountriesByZipCodeOptions): Promise<ApiResponse<Country>>;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* States resource for Country Data API SDK
|
|
302
|
+
*/
|
|
303
|
+
|
|
304
|
+
interface GetStateByNameOptions extends RequestOptions {
|
|
305
|
+
state: string;
|
|
306
|
+
}
|
|
307
|
+
interface GetStatesByCountryOptions extends RequestOptions {
|
|
308
|
+
country: string;
|
|
309
|
+
}
|
|
310
|
+
interface GetStatesByCityOptions extends RequestOptions {
|
|
311
|
+
city: string;
|
|
312
|
+
}
|
|
313
|
+
interface GetStatesByZipcodeOptions extends RequestOptions {
|
|
314
|
+
zipcode: string;
|
|
315
|
+
}
|
|
316
|
+
declare class States {
|
|
317
|
+
private readonly http;
|
|
318
|
+
constructor(http: HttpClient);
|
|
319
|
+
/**
|
|
320
|
+
* Get all states
|
|
321
|
+
* @example
|
|
322
|
+
* const states = await api.states.getAll({ lang: 'es' });
|
|
323
|
+
*/
|
|
324
|
+
getAll(options?: RequestOptions & {
|
|
325
|
+
limitStates?: number;
|
|
326
|
+
}): Promise<ApiResponse<State>>;
|
|
327
|
+
/**
|
|
328
|
+
* Get state by name
|
|
329
|
+
* @example
|
|
330
|
+
* const state = await api.states.getByName({ state: 'Madrid' });
|
|
331
|
+
*/
|
|
332
|
+
getByName(options: GetStateByNameOptions): Promise<ApiResponse<State>>;
|
|
333
|
+
/**
|
|
334
|
+
* Get states by country
|
|
335
|
+
* @example
|
|
336
|
+
* const spanishStates = await api.states.getByCountry({ country: 'Spain' });
|
|
337
|
+
*/
|
|
338
|
+
getByCountry(options: GetStatesByCountryOptions): Promise<ApiResponse<State>>;
|
|
339
|
+
/**
|
|
340
|
+
* Get states by city
|
|
341
|
+
* @example
|
|
342
|
+
* const states = await api.states.getByCity({ city: 'Madrid' });
|
|
343
|
+
*/
|
|
344
|
+
getByCity(options: GetStatesByCityOptions): Promise<ApiResponse<State>>;
|
|
345
|
+
/**
|
|
346
|
+
* Get states by zipcode
|
|
347
|
+
* @example
|
|
348
|
+
* const states = await api.states.getByZipcode({ zipcode: '28001' });
|
|
349
|
+
*/
|
|
350
|
+
getByZipcode(options: GetStatesByZipcodeOptions): Promise<ApiResponse<State>>;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Cities resource for Country Data API SDK
|
|
355
|
+
*/
|
|
356
|
+
|
|
357
|
+
interface GetCityOptions extends RequestOptions {
|
|
358
|
+
city: string;
|
|
359
|
+
}
|
|
360
|
+
interface GetCitiesByCountryOptions extends RequestOptions {
|
|
361
|
+
country: string;
|
|
362
|
+
}
|
|
363
|
+
interface GetCitiesByStateOptions extends RequestOptions {
|
|
364
|
+
state: string;
|
|
365
|
+
}
|
|
366
|
+
declare class Cities {
|
|
367
|
+
private readonly http;
|
|
368
|
+
constructor(http: HttpClient);
|
|
369
|
+
/**
|
|
370
|
+
* Get all cities
|
|
371
|
+
* @example
|
|
372
|
+
* const cities = await api.cities.getAll({ lang: 'es', limitToken: 100 });
|
|
373
|
+
*/
|
|
374
|
+
getAll(options?: RequestOptions): Promise<ApiResponse<City>>;
|
|
375
|
+
/**
|
|
376
|
+
* Get city by name or ID
|
|
377
|
+
* @example
|
|
378
|
+
* const city = await api.cities.get({ city: 'Madrid' });
|
|
379
|
+
*/
|
|
380
|
+
get(options: GetCityOptions): Promise<ApiResponse<City>>;
|
|
381
|
+
/**
|
|
382
|
+
* Get cities by country
|
|
383
|
+
* @example
|
|
384
|
+
* const cities = await api.cities.getByCountry({ country: 'Spain' });
|
|
385
|
+
*/
|
|
386
|
+
getByCountry(options: GetCitiesByCountryOptions): Promise<ApiResponse<City>>;
|
|
387
|
+
/**
|
|
388
|
+
* Get cities by state
|
|
389
|
+
* @example
|
|
390
|
+
* const cities = await api.cities.getByState({ state: 'Madrid' });
|
|
391
|
+
*/
|
|
392
|
+
getByState(options: GetCitiesByStateOptions): Promise<ApiResponse<City>>;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Zipcodes resource for Country Data API SDK
|
|
397
|
+
*/
|
|
398
|
+
|
|
399
|
+
interface GetZipcodesByStateOptions extends RequestOptions {
|
|
400
|
+
state: string;
|
|
401
|
+
}
|
|
402
|
+
interface GetZipcodesByCountryOptions extends RequestOptions {
|
|
403
|
+
country: string;
|
|
404
|
+
}
|
|
405
|
+
interface GetZipcodesByRegionOptions extends RequestOptions {
|
|
406
|
+
region: string;
|
|
407
|
+
}
|
|
408
|
+
declare class Zipcodes {
|
|
409
|
+
private readonly http;
|
|
410
|
+
constructor(http: HttpClient);
|
|
411
|
+
/**
|
|
412
|
+
* Get all zipcodes
|
|
413
|
+
* @example
|
|
414
|
+
* const zipcodes = await api.zipcodes.getAll({ limitToken: 100 });
|
|
415
|
+
*/
|
|
416
|
+
getAll(options?: RequestOptions): Promise<ApiResponse<string>>;
|
|
417
|
+
/**
|
|
418
|
+
* Get zipcodes by state
|
|
419
|
+
* @example
|
|
420
|
+
* const zipcodes = await api.zipcodes.getByState({ state: 'Madrid' });
|
|
421
|
+
*/
|
|
422
|
+
getByState(options: GetZipcodesByStateOptions): Promise<ApiResponse<string>>;
|
|
423
|
+
/**
|
|
424
|
+
* Get zipcodes by country
|
|
425
|
+
* @example
|
|
426
|
+
* const zipcodes = await api.zipcodes.getByCountry({ country: 'Spain' });
|
|
427
|
+
*/
|
|
428
|
+
getByCountry(options: GetZipcodesByCountryOptions): Promise<ApiResponse<string>>;
|
|
429
|
+
/**
|
|
430
|
+
* Get zipcodes by region
|
|
431
|
+
* @example
|
|
432
|
+
* const zipcodes = await api.zipcodes.getByRegion({ region: 'Europe' });
|
|
433
|
+
*/
|
|
434
|
+
getByRegion(options: GetZipcodesByRegionOptions): Promise<ApiResponse<string>>;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Select resource for Country Data API SDK
|
|
439
|
+
* Optimized endpoints for dropdowns (costs only 1 token)
|
|
440
|
+
*/
|
|
441
|
+
|
|
442
|
+
interface SelectCountriesOptions {
|
|
443
|
+
lang?: Language;
|
|
444
|
+
[key: string]: unknown;
|
|
445
|
+
}
|
|
446
|
+
interface SelectStatesOptions {
|
|
447
|
+
country: string;
|
|
448
|
+
lang?: Language;
|
|
449
|
+
[key: string]: unknown;
|
|
450
|
+
}
|
|
451
|
+
interface SelectCitiesOptions {
|
|
452
|
+
state: string;
|
|
453
|
+
country?: string;
|
|
454
|
+
lang?: Language;
|
|
455
|
+
[key: string]: unknown;
|
|
456
|
+
}
|
|
457
|
+
declare class Select {
|
|
458
|
+
private readonly http;
|
|
459
|
+
constructor(http: HttpClient);
|
|
460
|
+
/**
|
|
461
|
+
* Get countries optimized for select/dropdown (costs 1 token)
|
|
462
|
+
* @example
|
|
463
|
+
* const countries = await api.select.countries({ lang: 'es' });
|
|
464
|
+
*/
|
|
465
|
+
countries(options?: SelectCountriesOptions): Promise<ApiResponse<SelectCountry>>;
|
|
466
|
+
/**
|
|
467
|
+
* Get states for a country optimized for select/dropdown (costs 1 token)
|
|
468
|
+
* @example
|
|
469
|
+
* const states = await api.select.states({ country: 'ES' });
|
|
470
|
+
*/
|
|
471
|
+
states(options: SelectStatesOptions): Promise<ApiResponse<SelectState>>;
|
|
472
|
+
/**
|
|
473
|
+
* Get cities for a state optimized for select/dropdown (costs 1 token)
|
|
474
|
+
* @example
|
|
475
|
+
* const cities = await api.select.cities({ state: 'Madrid', country: 'ES' });
|
|
476
|
+
*/
|
|
477
|
+
cities(options: SelectCitiesOptions): Promise<ApiResponse<SelectCity>>;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Main client for Country Data API SDK
|
|
482
|
+
*/
|
|
483
|
+
|
|
484
|
+
interface CountryDataApiConfig {
|
|
485
|
+
/**
|
|
486
|
+
* Your API key from countrydataapi.com
|
|
487
|
+
*/
|
|
488
|
+
apiKey: string;
|
|
489
|
+
/**
|
|
490
|
+
* Base URL for the API (default: https://api.countrydataapi.com)
|
|
491
|
+
*/
|
|
492
|
+
baseUrl?: string;
|
|
493
|
+
/**
|
|
494
|
+
* Request timeout in milliseconds (default: 30000)
|
|
495
|
+
*/
|
|
496
|
+
timeout?: number;
|
|
497
|
+
/**
|
|
498
|
+
* Default language for responses (default: 'en')
|
|
499
|
+
*/
|
|
500
|
+
defaultLanguage?: Language;
|
|
501
|
+
}
|
|
502
|
+
declare class CountryDataApi {
|
|
503
|
+
private readonly http;
|
|
504
|
+
private readonly config;
|
|
505
|
+
/**
|
|
506
|
+
* Countries resource - query country data
|
|
507
|
+
*/
|
|
508
|
+
readonly countries: Countries;
|
|
509
|
+
/**
|
|
510
|
+
* States resource - query state/province data
|
|
511
|
+
*/
|
|
512
|
+
readonly states: States;
|
|
513
|
+
/**
|
|
514
|
+
* Cities resource - query city data
|
|
515
|
+
*/
|
|
516
|
+
readonly cities: Cities;
|
|
517
|
+
/**
|
|
518
|
+
* Zipcodes resource - query postal code data
|
|
519
|
+
*/
|
|
520
|
+
readonly zipcodes: Zipcodes;
|
|
521
|
+
/**
|
|
522
|
+
* Select resource - optimized endpoints for dropdowns (1 token each)
|
|
523
|
+
*/
|
|
524
|
+
readonly select: Select;
|
|
525
|
+
/**
|
|
526
|
+
* Create a new Country Data API client
|
|
527
|
+
* @example
|
|
528
|
+
* const api = new CountryDataApi({ apiKey: 'your-api-key' });
|
|
529
|
+
* const countries = await api.countries.getAll({ lang: 'es' });
|
|
530
|
+
*/
|
|
531
|
+
constructor(config: CountryDataApiConfig);
|
|
532
|
+
/**
|
|
533
|
+
* Get remaining tokens for your API key
|
|
534
|
+
* @example
|
|
535
|
+
* const status = await api.getStatus();
|
|
536
|
+
* console.log(`Remaining tokens: ${status.remainingTokens}`);
|
|
537
|
+
*/
|
|
538
|
+
getStatus(): Promise<StatusResponse>;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Error classes for Country Data API SDK
|
|
543
|
+
*/
|
|
544
|
+
declare class CountryDataApiError extends Error {
|
|
545
|
+
readonly statusCode?: number | undefined;
|
|
546
|
+
readonly response?: unknown | undefined;
|
|
547
|
+
constructor(message: string, statusCode?: number | undefined, response?: unknown | undefined);
|
|
548
|
+
}
|
|
549
|
+
declare class AuthenticationError extends CountryDataApiError {
|
|
550
|
+
constructor(message?: string);
|
|
551
|
+
}
|
|
552
|
+
declare class RateLimitError extends CountryDataApiError {
|
|
553
|
+
constructor(message?: string);
|
|
554
|
+
}
|
|
555
|
+
declare class InsufficientTokensError extends CountryDataApiError {
|
|
556
|
+
constructor(message?: string);
|
|
557
|
+
}
|
|
558
|
+
declare class ValidationError extends CountryDataApiError {
|
|
559
|
+
constructor(message: string);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
export { type ApiError, type ApiResponse, AuthenticationError, type CapitalInfo, type CarInfo, type City, type Country, CountryDataApi, type CountryDataApiConfig, CountryDataApiError, type CountryLanguage, type Currency, type Demonym, type GetCitiesByCountryOptions, type GetCitiesByStateOptions, type GetCityOptions, type GetCountriesByCurrencyOptions, type GetCountriesByLanguageOptions, type GetCountriesByRegionOptions, type GetCountriesByTimezoneOptions, type GetCountryByCodeOptions, type GetCountryByNameOptions, type GetStateByNameOptions, type GetStatesByCityOptions, type GetStatesByCountryOptions, type GetStatesByZipcodeOptions, type GetZipcodesByCountryOptions, type GetZipcodesByRegionOptions, type GetZipcodesByStateOptions, type Gini, type IddInfo, InsufficientTokensError, type Language, RateLimitError, type RequestOptions, type SelectCitiesOptions, type SelectCity, type SelectCountriesOptions, type SelectCountry, type SelectState, type SelectStatesOptions, type State, type StatusResponse, type Translation, ValidationError, type Zipcode };
|