@parseapi/sdk 0.1.1 → 0.1.3
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 +11 -0
- package/dist/index.cjs +59 -13
- package/dist/index.d.cts +357 -40
- package/dist/index.d.ts +357 -40
- package/dist/index.js +59 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,13 @@ One method per endpoint, named after the route.
|
|
|
23
23
|
await parse.ip('8.8.8.8');
|
|
24
24
|
await parse.ip.self();
|
|
25
25
|
await parse.email('hello@gmail.com');
|
|
26
|
+
await parse.vat('DE136695976');
|
|
27
|
+
await parse.iban('DE89370400440532013000');
|
|
26
28
|
await parse.phone('+14155552671');
|
|
29
|
+
await parse.carrier('+14155552671');
|
|
30
|
+
await parse.caller('+14155552671');
|
|
31
|
+
await parse.hlr('+14155552671');
|
|
32
|
+
await parse.postal('SW1A 1AA');
|
|
27
33
|
await parse.postal('28202', { country: 'US' });
|
|
28
34
|
await parse.postal.nearby('28202', { country: 'US', radius: 40 });
|
|
29
35
|
await parse.postal.distance('28202', '10001', { country: 'US' });
|
|
@@ -31,17 +37,22 @@ await parse.city('charlotte', { country: 'US' });
|
|
|
31
37
|
await parse.city.id('city_mb8mbqrkz8zb');
|
|
32
38
|
await parse.city.search('char', { country: 'US', limit: 10 });
|
|
33
39
|
await parse.city.nearest(35.2271, -80.8431);
|
|
40
|
+
await parse.city.nearby('denver', { radius: 8, unit: 'mi' });
|
|
34
41
|
await parse.country('US');
|
|
35
42
|
await parse.country.states('US');
|
|
43
|
+
await parse.state('colorado');
|
|
36
44
|
await parse.state('NC', { country: 'US' });
|
|
37
45
|
await parse.state.districts('NC', { country: 'US' });
|
|
38
46
|
await parse.district('37081');
|
|
47
|
+
await parse.district('guilford county');
|
|
39
48
|
await parse.continent('NA');
|
|
40
49
|
await parse.continent.countries('NA');
|
|
41
50
|
await parse.currency('USD');
|
|
42
51
|
await parse.currency.rate('USD', 'EUR');
|
|
43
52
|
await parse.language('en');
|
|
53
|
+
await parse.name('BILLY OSHALL');
|
|
44
54
|
await parse.timezone('America/New_York');
|
|
55
|
+
await parse.timezone(40.7128, -74.006);
|
|
45
56
|
await parse.holiday('US', { year: 2026 });
|
|
46
57
|
await parse.holiday.date('US', '2026-12-25');
|
|
47
58
|
await parse.elevation(35.2271, -80.8431);
|
package/dist/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ __export(index_exports, {
|
|
|
24
24
|
parseAPI: () => parseAPI
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
var VERSION = "0.1.
|
|
27
|
+
var VERSION = "0.1.3";
|
|
28
28
|
var DEFAULT_BASE_URL = "https://api.parseapi.com";
|
|
29
29
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
30
30
|
var DEFAULT_RETRIES = 2;
|
|
@@ -118,6 +118,20 @@ function parseAPI(apiKey, options = {}) {
|
|
|
118
118
|
}
|
|
119
119
|
const enc = encodeURIComponent;
|
|
120
120
|
const deepQuery = (opts) => opts?.deep ? { deep: true } : {};
|
|
121
|
+
function timezone(idOrLat, lonOrOpts, opts) {
|
|
122
|
+
if (typeof idOrLat === "number") {
|
|
123
|
+
return request("/timezone", {
|
|
124
|
+
lat: idOrLat,
|
|
125
|
+
lon: typeof lonOrOpts === "number" ? lonOrOpts : void 0,
|
|
126
|
+
at: opts?.at
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const idOpts = lonOrOpts && typeof lonOrOpts === "object" ? lonOrOpts : void 0;
|
|
130
|
+
return request(`/timezone/${enc(idOrLat)}`, {
|
|
131
|
+
at: idOpts?.at,
|
|
132
|
+
to: idOpts?.to
|
|
133
|
+
});
|
|
134
|
+
}
|
|
121
135
|
return {
|
|
122
136
|
ip: Object.assign(
|
|
123
137
|
(ip, opts) => request(`/ip/${enc(ip)}`, deepQuery(opts)),
|
|
@@ -131,6 +145,12 @@ function parseAPI(apiKey, options = {}) {
|
|
|
131
145
|
countries: (code) => request(`/continent/${enc(code)}/countries`)
|
|
132
146
|
}
|
|
133
147
|
),
|
|
148
|
+
bloc: Object.assign(
|
|
149
|
+
(code) => request(`/bloc/${enc(code)}`),
|
|
150
|
+
{
|
|
151
|
+
countries: (code) => request(`/bloc/${enc(code)}/countries`)
|
|
152
|
+
}
|
|
153
|
+
),
|
|
134
154
|
country: Object.assign(
|
|
135
155
|
(code) => request(`/country/${enc(code)}`),
|
|
136
156
|
{
|
|
@@ -138,44 +158,70 @@ function parseAPI(apiKey, options = {}) {
|
|
|
138
158
|
}
|
|
139
159
|
),
|
|
140
160
|
state: Object.assign(
|
|
141
|
-
(code, opts) => request(`/state/${enc(code)}`, { country: opts
|
|
161
|
+
(code, opts) => request(`/state/${enc(code)}`, { country: opts?.country }),
|
|
142
162
|
{
|
|
143
|
-
districts: (code, opts) => request(`/state/${enc(code)}/districts`, { country: opts
|
|
163
|
+
districts: (code, opts) => request(`/state/${enc(code)}/districts`, { country: opts?.country })
|
|
144
164
|
}
|
|
145
165
|
),
|
|
146
|
-
district: (code, opts) => request(`/district/${enc(code)}`, { country: opts?.country }),
|
|
166
|
+
district: (code, opts) => request(`/district/${enc(code)}`, { country: opts?.country, state: opts?.state }),
|
|
147
167
|
city: Object.assign(
|
|
148
168
|
(name, opts) => request(`/city/${enc(name)}`, { country: opts?.country, state: opts?.state }),
|
|
149
169
|
{
|
|
150
170
|
id: (id) => request(`/city/id/${enc(id)}`),
|
|
151
171
|
search: (q, opts) => request("/city", { q, country: opts?.country, state: opts?.state, limit: opts?.limit }),
|
|
152
|
-
nearest: (lat, lon) => request("/city", { lat, lon })
|
|
172
|
+
nearest: (lat, lon) => request("/city", { lat, lon }),
|
|
173
|
+
nearby: (name, opts) => request(`/city/${enc(name)}/nearby`, {
|
|
174
|
+
radius: opts?.radius,
|
|
175
|
+
unit: opts?.unit,
|
|
176
|
+
country: opts?.country,
|
|
177
|
+
state: opts?.state,
|
|
178
|
+
limit: opts?.limit
|
|
179
|
+
})
|
|
153
180
|
}
|
|
154
181
|
),
|
|
155
182
|
postal: Object.assign(
|
|
156
|
-
(code, opts) => request(`/postal/${enc(code)}`, { country: opts
|
|
183
|
+
(code, opts) => request(`/postal/${enc(code)}`, { country: opts?.country }),
|
|
157
184
|
{
|
|
158
185
|
nearby: (code, opts) => request(`/postal/${enc(code)}/nearby`, {
|
|
159
|
-
country: opts
|
|
160
|
-
radius: opts
|
|
161
|
-
unit: opts
|
|
186
|
+
country: opts?.country,
|
|
187
|
+
radius: opts?.radius,
|
|
188
|
+
unit: opts?.unit
|
|
162
189
|
}),
|
|
163
|
-
distance: (from, to, opts) => request(`/postal/${enc(from)}/distance/${enc(to)}`, { country: opts
|
|
190
|
+
distance: (from, to, opts) => request(`/postal/${enc(from)}/distance/${enc(to)}`, { country: opts?.country })
|
|
164
191
|
}
|
|
165
192
|
),
|
|
166
193
|
email: (email, opts) => request(`/email/${enc(email)}`, deepQuery(opts)),
|
|
194
|
+
vat: (number, opts) => request(`/vat/${enc(number)}`, {
|
|
195
|
+
country: opts?.country,
|
|
196
|
+
from: opts?.from,
|
|
197
|
+
...deepQuery(opts)
|
|
198
|
+
}),
|
|
199
|
+
iban: (iban, opts) => request(`/iban/${enc(iban)}`, { country: opts?.country }),
|
|
167
200
|
phone: (number, opts) => request(`/phone/${enc(number)}`, { country: opts?.country, ...deepQuery(opts) }),
|
|
201
|
+
carrier: (number, opts) => request(`/carrier/${enc(number)}`, { country: opts?.country }),
|
|
202
|
+
caller: (number, opts) => request(`/caller/${enc(number)}`, { country: opts?.country }),
|
|
203
|
+
hlr: (number, opts) => request(`/hlr/${enc(number)}`, { country: opts?.country }),
|
|
168
204
|
domain: (domain, opts) => request(`/domain/${enc(domain)}`, deepQuery(opts)),
|
|
169
205
|
mx: (domain) => request(`/mx/${enc(domain)}`),
|
|
170
206
|
useragent: (ua, opts) => request("/useragent", deepQuery(opts), { "User-Agent": ua }),
|
|
171
207
|
currency: Object.assign(
|
|
172
208
|
(code) => request(`/currency/${enc(code)}`),
|
|
173
209
|
{
|
|
174
|
-
rate: (base, quote) => request(`/currency/${enc(base)}/${enc(quote)}
|
|
210
|
+
rate: (base, quote, opts) => request(`/currency/${enc(base)}/${enc(quote)}`, {
|
|
211
|
+
date: opts?.date,
|
|
212
|
+
amount: opts?.amount
|
|
213
|
+
})
|
|
175
214
|
}
|
|
176
215
|
),
|
|
177
216
|
language: (code) => request(`/language/${enc(code)}`),
|
|
178
|
-
|
|
217
|
+
name: (name) => request(`/name/${enc(name)}`),
|
|
218
|
+
timezone,
|
|
219
|
+
date: Object.assign(
|
|
220
|
+
(date, opts) => request(`/date/${enc(date)}`, { format: opts?.format, to: opts?.to }),
|
|
221
|
+
{
|
|
222
|
+
today: (opts) => request("/date", { to: opts?.to })
|
|
223
|
+
}
|
|
224
|
+
),
|
|
179
225
|
holiday: Object.assign(
|
|
180
226
|
(country, opts) => request(`/holiday/${enc(country)}`, { year: opts?.year }),
|
|
181
227
|
{
|
|
@@ -184,7 +230,7 @@ function parseAPI(apiKey, options = {}) {
|
|
|
184
230
|
),
|
|
185
231
|
elevation: (lat, lon) => request("/elevation", { lat, lon }),
|
|
186
232
|
point: (lat, lon, opts) => request("/point", { lat, lon, ...deepQuery(opts) }),
|
|
187
|
-
weather: (lat, lon, opts) => request("/weather", { lat, lon, ...deepQuery(opts) }),
|
|
233
|
+
weather: (lat, lon, opts) => request("/weather", { lat, lon, date: opts?.date, ...deepQuery(opts) }),
|
|
188
234
|
emoji: Object.assign(
|
|
189
235
|
(emoji) => request(`/emoji/${enc(emoji)}`),
|
|
190
236
|
{
|