@ip2geo/sdk 0.0.1

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/index.d.ts ADDED
@@ -0,0 +1,304 @@
1
+ declare const IP_TYPES: {
2
+ IPV4: string;
3
+ IPV6: string;
4
+ };
5
+
6
+ type IpTypes = (typeof IP_TYPES)[keyof typeof IP_TYPES];
7
+ type Expand<T> = T extends infer O ? O extends object ? O extends Array<infer U> ? Array<Expand<U>> : O extends Function ? O : {
8
+ [K in keyof O]: Expand<O[K]>;
9
+ } : O : never;
10
+ interface Ip {
11
+ ip: string | null;
12
+ type: IpTypes | null;
13
+ is_eu: boolean | null;
14
+ continent: {
15
+ name: string | null;
16
+ code: string | null;
17
+ country: {
18
+ name: string | null;
19
+ code: string | null;
20
+ phone_code: string | null;
21
+ capital: string | null;
22
+ tld: string | null;
23
+ city: {
24
+ name: string | null;
25
+ latitude: number | null;
26
+ longitude: number | null;
27
+ postal_code: string | null;
28
+ timezone: {
29
+ name: string | null;
30
+ time_now: string | null;
31
+ };
32
+ };
33
+ flag: {
34
+ img: string | null;
35
+ emoji: string | null;
36
+ emoji_unicode: string | null;
37
+ };
38
+ currency: {
39
+ name: string | null;
40
+ code: string | null;
41
+ symbol: string | null;
42
+ };
43
+ };
44
+ };
45
+ asn: {
46
+ number: number | null;
47
+ name: string | null;
48
+ };
49
+ completion_time: {
50
+ miliseconds: number | null;
51
+ seconds: number | null;
52
+ };
53
+ }
54
+ interface SingleConvertResponseInterface$2 {
55
+ success: boolean;
56
+ message: string;
57
+ code: number;
58
+ data: Ip | null;
59
+ _req: {
60
+ reqId: string | null;
61
+ resTime: number;
62
+ };
63
+ }
64
+ interface InitOptions$1 {
65
+ clientRuntimeMessage?: boolean;
66
+ versionUpdateMessage?: boolean;
67
+ }
68
+ interface MultipleConvertResponseInterface$1 {
69
+ success: boolean;
70
+ message: string;
71
+ code: number;
72
+ data: Array<{
73
+ ip: string;
74
+ conversion: Ip | null;
75
+ }>;
76
+ _req: {
77
+ reqId: string | null;
78
+ resTime: number;
79
+ };
80
+ }
81
+ type ConvertIPProps$1 = {
82
+ ip: string;
83
+ };
84
+ type ConvertIPsProps$1 = {
85
+ ips: Array<string>;
86
+ };
87
+
88
+ /**
89
+ * Get geo information from an IP address.
90
+ *
91
+ * The function fetches detailed geographical and connection-related information
92
+ * for a given IP address. The returned data includes properties such as continent,
93
+ * country, city, timezone, ASN details, and completion time.
94
+ *
95
+ * @param props - The properties object containing the IP address.
96
+ * @param props.ip - The IP address to retrieve geo information for.
97
+ * @returns {Promise<SingleConvertResponseInterface | null>} A Promise resolving to a {@link SingleConvertResponseInterface} containing the response wrapper with geo and connection details, or `null` if the request fails or no response is received.
98
+ */
99
+ type ConvertIPProps = Expand<ConvertIPProps$1>;
100
+ type SingleConvertResponseInterface$1 = Expand<SingleConvertResponseInterface$2>;
101
+ declare const ConvertIP: (options: ConvertIPProps) => Promise<SingleConvertResponseInterface$1 | null>;
102
+
103
+ /**
104
+ * Get geo information from multiple IP addresses.
105
+ *
106
+ * The function fetches detailed geographical and connection-related information
107
+ * for an array of IP addresses. The returned data includes an array of conversions,
108
+ * each containing the IP and its geo data (continent, country, city, timezone, ASN details, etc).
109
+ *
110
+ * @param props - The properties object containing the IP addresses.
111
+ * @param props.ips - An array of IP addresses to retrieve geo information for.
112
+ * @returns {Promise<MultipleConvertResponseInterface | null>} A Promise resolving to a {@link MultipleConvertResponseInterface} containing the response wrapper with an array of geo conversions, or `null` if the request fails or no response is received.
113
+ */
114
+ type ConvertIPsProps = Expand<ConvertIPsProps$1>;
115
+ type MultipleConvertResponseInterface = Expand<MultipleConvertResponseInterface$1>;
116
+ type SingleConvertResponseInterface = Expand<SingleConvertResponseInterface$2>;
117
+ declare const ConvertIPs: (props: ConvertIPsProps) => Promise<MultipleConvertResponseInterface | SingleConvertResponseInterface | null>;
118
+
119
+ /**
120
+ * Initializes the SDK with the given API key.
121
+ *
122
+ * @param {string} key - The API key used to authenticate with the Ip2Geo.
123
+ * @param {InitOptions} [options] - The options for the initialization (optional).
124
+ * @param {boolean} [options.clientRuntimeMessage=true] - Whether to display client runtime messages.
125
+ * @param {boolean} [options.versionUpdateMessage=true] - Whether to display version update messages.
126
+ * @returns {boolean} - A boolean that indicates if the initialization was successful.
127
+ */
128
+ type InitOptions = Expand<InitOptions$1>;
129
+ declare const Init: (key: string, options?: InitOptions) => Promise<boolean>;
130
+
131
+ declare const Ip2Geo: {
132
+ ConvertIPs: (props: {
133
+ ips: string[];
134
+ }) => Promise<{
135
+ success: boolean;
136
+ message: string;
137
+ code: number;
138
+ data: {
139
+ ip: string;
140
+ conversion: {
141
+ ip: string | null;
142
+ type: IpTypes | null;
143
+ is_eu: boolean | null;
144
+ continent: {
145
+ name: string | null;
146
+ code: string | null;
147
+ country: {
148
+ name: string | null;
149
+ code: string | null;
150
+ phone_code: string | null;
151
+ capital: string | null;
152
+ tld: string | null;
153
+ city: {
154
+ name: string | null;
155
+ latitude: number | null;
156
+ longitude: number | null;
157
+ postal_code: string | null;
158
+ timezone: {
159
+ name: string | null;
160
+ time_now: string | null;
161
+ };
162
+ };
163
+ flag: {
164
+ img: string | null;
165
+ emoji: string | null;
166
+ emoji_unicode: string | null;
167
+ };
168
+ currency: {
169
+ name: string | null;
170
+ code: string | null;
171
+ symbol: string | null;
172
+ };
173
+ };
174
+ };
175
+ asn: {
176
+ number: number | null;
177
+ name: string | null;
178
+ };
179
+ completion_time: {
180
+ miliseconds: number | null;
181
+ seconds: number | null;
182
+ };
183
+ } | null;
184
+ }[];
185
+ _req: {
186
+ reqId: string | null;
187
+ resTime: number;
188
+ };
189
+ } | {
190
+ success: boolean;
191
+ message: string;
192
+ code: number;
193
+ data: {
194
+ ip: string | null;
195
+ type: IpTypes | null;
196
+ is_eu: boolean | null;
197
+ continent: {
198
+ name: string | null;
199
+ code: string | null;
200
+ country: {
201
+ name: string | null;
202
+ code: string | null;
203
+ phone_code: string | null;
204
+ capital: string | null;
205
+ tld: string | null;
206
+ city: {
207
+ name: string | null;
208
+ latitude: number | null;
209
+ longitude: number | null;
210
+ postal_code: string | null;
211
+ timezone: {
212
+ name: string | null;
213
+ time_now: string | null;
214
+ };
215
+ };
216
+ flag: {
217
+ img: string | null;
218
+ emoji: string | null;
219
+ emoji_unicode: string | null;
220
+ };
221
+ currency: {
222
+ name: string | null;
223
+ code: string | null;
224
+ symbol: string | null;
225
+ };
226
+ };
227
+ };
228
+ asn: {
229
+ number: number | null;
230
+ name: string | null;
231
+ };
232
+ completion_time: {
233
+ miliseconds: number | null;
234
+ seconds: number | null;
235
+ };
236
+ } | null;
237
+ _req: {
238
+ reqId: string | null;
239
+ resTime: number;
240
+ };
241
+ } | null>;
242
+ ConvertIP: (options: {
243
+ ip: string;
244
+ }) => Promise<{
245
+ success: boolean;
246
+ message: string;
247
+ code: number;
248
+ data: {
249
+ ip: string | null;
250
+ type: IpTypes | null;
251
+ is_eu: boolean | null;
252
+ continent: {
253
+ name: string | null;
254
+ code: string | null;
255
+ country: {
256
+ name: string | null;
257
+ code: string | null;
258
+ phone_code: string | null;
259
+ capital: string | null;
260
+ tld: string | null;
261
+ city: {
262
+ name: string | null;
263
+ latitude: number | null;
264
+ longitude: number | null;
265
+ postal_code: string | null;
266
+ timezone: {
267
+ name: string | null;
268
+ time_now: string | null;
269
+ };
270
+ };
271
+ flag: {
272
+ img: string | null;
273
+ emoji: string | null;
274
+ emoji_unicode: string | null;
275
+ };
276
+ currency: {
277
+ name: string | null;
278
+ code: string | null;
279
+ symbol: string | null;
280
+ };
281
+ };
282
+ };
283
+ asn: {
284
+ number: number | null;
285
+ name: string | null;
286
+ };
287
+ completion_time: {
288
+ miliseconds: number | null;
289
+ seconds: number | null;
290
+ };
291
+ } | null;
292
+ _req: {
293
+ reqId: string | null;
294
+ resTime: number;
295
+ };
296
+ } | null>;
297
+ Init: (key: string, options?: {
298
+ clientRuntimeMessage?: boolean | undefined;
299
+ versionUpdateMessage?: boolean | undefined;
300
+ }) => Promise<boolean>;
301
+ };
302
+
303
+ export { ConvertIP, ConvertIPs, Init, Ip2Geo as default };
304
+ export type { ConvertIPProps$1 as ConvertIPProps, ConvertIPsProps$1 as ConvertIPsProps, InitOptions$1 as InitOptions, Ip, MultipleConvertResponseInterface$1 as MultipleConvertResponseInterface, SingleConvertResponseInterface$2 as SingleConvertResponseInterface };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@ip2geo/sdk",
3
+ "version": "0.0.1",
4
+ "author": "Ip2Geo",
5
+ "description": "Programmatically convert IP's into GEO location data.",
6
+ "type": "module",
7
+ "main": "/cjs/index.cjs",
8
+ "module": "/esm/index.js",
9
+ "types": "./index.d.ts",
10
+ "keywords": [
11
+ "geo ip",
12
+ "ip geolocation",
13
+ "ip to location",
14
+ "ip location",
15
+ "ip geo",
16
+ "geolocation lookup",
17
+ "ip tracker",
18
+ "client ip geolocation",
19
+ "server ip geolocation",
20
+ "geoip api",
21
+ "ip data",
22
+ "geolocation api",
23
+ "ip info",
24
+ "ip location api",
25
+ "ip lookup",
26
+ "geo location",
27
+ "ip mapping",
28
+ "ip coordinates",
29
+ "location from ip",
30
+ "lightweight geolocation",
31
+ "tiny geoip",
32
+ "type safe geo",
33
+ "ip to country",
34
+ "geoip client side",
35
+ "geoip server side",
36
+ "online ip lookup",
37
+ "javascript geoip",
38
+ "bun geoip",
39
+ "nodejs ip geolocation",
40
+ "ip2geo"
41
+ ],
42
+ "exports": {
43
+ ".": {
44
+ "import": "./esm/index.js",
45
+ "require": "./cjs/index.cjs",
46
+ "types": "./index.d.ts"
47
+ }
48
+ }
49
+ }