@apiverve/earthquake 1.1.9 → 1.1.12
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 +1 -1
- package/README.md +345 -299
- package/examples/basic.js +36 -0
- package/index.d.ts +61 -0
- package/index.js +48 -14
- package/package.json +10 -7
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025 APIVerve, and EvlarSoft LLC
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
Worldwide Earthquakes API
|
|
2
|
-
============
|
|
1
|
+
# Worldwide Earthquakes API
|
|
3
2
|
|
|
4
3
|
Earthquake is a simple tool for getting earthquake data. It returns the earthquake data for the past hour.
|
|
5
4
|
|
|
@@ -7,52 +6,60 @@ Earthquake is a simple tool for getting earthquake data. It returns the earthqua
|
|
|
7
6
|

|
|
8
7
|

|
|
9
8
|
|
|
10
|
-
This is a Javascript Wrapper for the [Worldwide Earthquakes API](https://apiverve.com/marketplace/
|
|
9
|
+
This is a Javascript Wrapper for the [Worldwide Earthquakes API](https://apiverve.com/marketplace/earthquake)
|
|
11
10
|
|
|
12
11
|
---
|
|
13
12
|
|
|
14
13
|
## Installation
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
Using npm:
|
|
16
|
+
```shell
|
|
17
|
+
npm install @apiverve/earthquake
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Using yarn:
|
|
21
|
+
```shell
|
|
22
|
+
yarn add @apiverve/earthquake
|
|
23
|
+
```
|
|
16
24
|
|
|
17
25
|
---
|
|
18
26
|
|
|
19
27
|
## Configuration
|
|
20
28
|
|
|
21
|
-
Before using the
|
|
29
|
+
Before using the Worldwide Earthquakes API client, you have to setup your account and obtain your API Key.
|
|
22
30
|
You can get it by signing up at [https://apiverve.com](https://apiverve.com)
|
|
23
31
|
|
|
24
32
|
---
|
|
25
33
|
|
|
26
|
-
##
|
|
34
|
+
## Quick Start
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
[Get started with the Quick Start Guide](https://docs.apiverve.com/quickstart)
|
|
37
|
+
|
|
38
|
+
The Worldwide Earthquakes API documentation is found here: [https://docs.apiverve.com/ref/earthquake](https://docs.apiverve.com/ref/earthquake).
|
|
29
39
|
You can find parameters, example responses, and status codes documented here.
|
|
30
40
|
|
|
31
41
|
### Setup
|
|
32
42
|
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
api_key: [YOUR_API_KEY]
|
|
37
|
-
secure: true //(Optional, defaults to true)
|
|
43
|
+
```javascript
|
|
44
|
+
const earthquakeAPI = require('@apiverve/earthquake');
|
|
45
|
+
const api = new earthquakeAPI({
|
|
46
|
+
api_key: '[YOUR_API_KEY]'
|
|
38
47
|
});
|
|
39
48
|
```
|
|
40
49
|
|
|
41
50
|
---
|
|
42
51
|
|
|
52
|
+
## Usage
|
|
43
53
|
|
|
44
|
-
|
|
45
|
-
Using the API client, you can perform requests to the API.
|
|
54
|
+
---
|
|
46
55
|
|
|
47
|
-
|
|
56
|
+
### Perform Request
|
|
48
57
|
|
|
49
|
-
|
|
50
|
-
This API does not require a Query
|
|
51
|
-
```
|
|
58
|
+
Using the API is simple. All you have to do is make a request. The API will return a response with the data you requested.
|
|
52
59
|
|
|
53
|
-
|
|
60
|
+
```javascript
|
|
61
|
+
// This API does not require a Query
|
|
54
62
|
|
|
55
|
-
```
|
|
56
63
|
api.execute(function (error, data) {
|
|
57
64
|
if (error) {
|
|
58
65
|
return console.error(error);
|
|
@@ -62,286 +69,324 @@ api.execute(function (error, data) {
|
|
|
62
69
|
});
|
|
63
70
|
```
|
|
64
71
|
|
|
65
|
-
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### Using Promises
|
|
75
|
+
|
|
76
|
+
You can also use promises to make requests. The API returns a promise that you can use to handle the response.
|
|
66
77
|
|
|
78
|
+
```javascript
|
|
79
|
+
// This API does not require a Query
|
|
80
|
+
|
|
81
|
+
api.execute(query)
|
|
82
|
+
.then(data => {
|
|
83
|
+
console.log(data);
|
|
84
|
+
})
|
|
85
|
+
.catch(error => {
|
|
86
|
+
console.error(error);
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
### Using Async/Await
|
|
93
|
+
|
|
94
|
+
You can also use async/await to make requests. The API returns a promise that you can use to handle the response.
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
async function makeRequest() {
|
|
98
|
+
// This API does not require a Query
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
const data = await api.execute(query);
|
|
102
|
+
console.log(data);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error(error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
67
107
|
```
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
"
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
"
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
"
|
|
167
|
-
"
|
|
168
|
-
"
|
|
169
|
-
"
|
|
170
|
-
"
|
|
171
|
-
"
|
|
172
|
-
"
|
|
173
|
-
"
|
|
174
|
-
"
|
|
175
|
-
"
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
"
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
"
|
|
188
|
-
"
|
|
189
|
-
"
|
|
190
|
-
"
|
|
191
|
-
"
|
|
192
|
-
"
|
|
193
|
-
"
|
|
194
|
-
"
|
|
195
|
-
"
|
|
196
|
-
"
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
"
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
"
|
|
209
|
-
"
|
|
210
|
-
"
|
|
211
|
-
"
|
|
212
|
-
"
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
-
"
|
|
217
|
-
"
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
"
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
"
|
|
230
|
-
"
|
|
231
|
-
"
|
|
232
|
-
"
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
"
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
"
|
|
248
|
-
"
|
|
249
|
-
"
|
|
250
|
-
"
|
|
251
|
-
"
|
|
252
|
-
"
|
|
253
|
-
"
|
|
254
|
-
"
|
|
255
|
-
"
|
|
256
|
-
"
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
"
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
"
|
|
269
|
-
"
|
|
270
|
-
"
|
|
271
|
-
"
|
|
272
|
-
"
|
|
273
|
-
"
|
|
274
|
-
"
|
|
275
|
-
"
|
|
276
|
-
"
|
|
277
|
-
"
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
"
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
"
|
|
290
|
-
"
|
|
291
|
-
"
|
|
292
|
-
"
|
|
293
|
-
"
|
|
294
|
-
"
|
|
295
|
-
"
|
|
296
|
-
"
|
|
297
|
-
"
|
|
298
|
-
"
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
"
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
"
|
|
311
|
-
"
|
|
312
|
-
"
|
|
313
|
-
"
|
|
314
|
-
"
|
|
315
|
-
"
|
|
316
|
-
"
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
"
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
"
|
|
329
|
-
"
|
|
330
|
-
"
|
|
331
|
-
"
|
|
332
|
-
"
|
|
333
|
-
"
|
|
334
|
-
"
|
|
335
|
-
"
|
|
336
|
-
"
|
|
337
|
-
"
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Example Response
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"status": "ok",
|
|
116
|
+
"error": null,
|
|
117
|
+
"data": {
|
|
118
|
+
"earthquakes_LastUpdated": 1740085202,
|
|
119
|
+
"earthquakes_LastHour": 13,
|
|
120
|
+
"earthquakes": [
|
|
121
|
+
{
|
|
122
|
+
"mag": 1.63,
|
|
123
|
+
"place": "4 km SSW of Home Gardens, CA",
|
|
124
|
+
"time": 1740084740320,
|
|
125
|
+
"status": "automatic",
|
|
126
|
+
"tsunami": 0,
|
|
127
|
+
"sig": 41,
|
|
128
|
+
"net": "ci",
|
|
129
|
+
"types": ",nearby-cities,origin,phase-data,scitech-link,",
|
|
130
|
+
"nst": 30,
|
|
131
|
+
"dmin": 0.07665,
|
|
132
|
+
"rms": 0.16,
|
|
133
|
+
"gap": 212,
|
|
134
|
+
"magType": "ml",
|
|
135
|
+
"type": "earthquake",
|
|
136
|
+
"title": "M 1.6 - 4 km SSW of Home Gardens, CA",
|
|
137
|
+
"coordinates": [
|
|
138
|
+
-117.5313333,
|
|
139
|
+
33.8441667
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"mag": 1.53,
|
|
144
|
+
"place": "3 km of The Geysers, CA",
|
|
145
|
+
"time": 1740084398050,
|
|
146
|
+
"status": "automatic",
|
|
147
|
+
"tsunami": 0,
|
|
148
|
+
"sig": 36,
|
|
149
|
+
"net": "nc",
|
|
150
|
+
"types": ",focal-mechanism,nearby-cities,origin,phase-data,",
|
|
151
|
+
"nst": 31,
|
|
152
|
+
"dmin": 0.01013,
|
|
153
|
+
"rms": 0.04,
|
|
154
|
+
"gap": 61,
|
|
155
|
+
"magType": "md",
|
|
156
|
+
"type": "earthquake",
|
|
157
|
+
"title": "M 1.5 - 3 km of The Geysers, CA",
|
|
158
|
+
"coordinates": [
|
|
159
|
+
-122.770835876465,
|
|
160
|
+
38.8066673278809
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"mag": 1.5,
|
|
165
|
+
"place": "36 km SSW of Los Ybanez, Texas",
|
|
166
|
+
"time": 1740083760065,
|
|
167
|
+
"status": "automatic",
|
|
168
|
+
"tsunami": 0,
|
|
169
|
+
"sig": 35,
|
|
170
|
+
"net": "tx",
|
|
171
|
+
"types": ",origin,phase-data,",
|
|
172
|
+
"nst": 21,
|
|
173
|
+
"dmin": 0,
|
|
174
|
+
"rms": 0.5,
|
|
175
|
+
"gap": 98,
|
|
176
|
+
"magType": "ml",
|
|
177
|
+
"type": "earthquake",
|
|
178
|
+
"title": "M 1.5 - 36 km SSW of Los Ybanez, Texas",
|
|
179
|
+
"coordinates": [
|
|
180
|
+
-102.118,
|
|
181
|
+
32.437
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"mag": 1.28,
|
|
186
|
+
"place": "2 km NNE of Rancho San Diego, CA",
|
|
187
|
+
"time": 1740083416660,
|
|
188
|
+
"status": "automatic",
|
|
189
|
+
"tsunami": 0,
|
|
190
|
+
"sig": 25,
|
|
191
|
+
"net": "ci",
|
|
192
|
+
"types": ",nearby-cities,origin,phase-data,scitech-link,",
|
|
193
|
+
"nst": 18,
|
|
194
|
+
"dmin": 0.02613,
|
|
195
|
+
"rms": 0.18,
|
|
196
|
+
"gap": 117,
|
|
197
|
+
"magType": "ml",
|
|
198
|
+
"type": "earthquake",
|
|
199
|
+
"title": "M 1.3 - 2 km NNE of Rancho San Diego, CA",
|
|
200
|
+
"coordinates": [
|
|
201
|
+
-116.9288333,
|
|
202
|
+
32.7591667
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"mag": 1.3,
|
|
207
|
+
"place": "2 km N of The Geysers, CA",
|
|
208
|
+
"time": 1740083145550,
|
|
209
|
+
"status": "automatic",
|
|
210
|
+
"tsunami": 0,
|
|
211
|
+
"sig": 26,
|
|
212
|
+
"net": "nc",
|
|
213
|
+
"types": ",nearby-cities,origin,phase-data,",
|
|
214
|
+
"nst": 17,
|
|
215
|
+
"dmin": 0.008002,
|
|
216
|
+
"rms": 0.02,
|
|
217
|
+
"gap": 75,
|
|
218
|
+
"magType": "md",
|
|
219
|
+
"type": "earthquake",
|
|
220
|
+
"title": "M 1.3 - 2 km N of The Geysers, CA",
|
|
221
|
+
"coordinates": [
|
|
222
|
+
-122.758499145508,
|
|
223
|
+
38.792667388916
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"mag": 2.03,
|
|
228
|
+
"place": "23 km NE of San Ardo, CA",
|
|
229
|
+
"time": 1740083087170,
|
|
230
|
+
"status": "automatic",
|
|
231
|
+
"tsunami": 0,
|
|
232
|
+
"sig": 63,
|
|
233
|
+
"net": "nc",
|
|
234
|
+
"types": ",nearby-cities,origin,phase-data,",
|
|
235
|
+
"nst": 24,
|
|
236
|
+
"dmin": 0.04482,
|
|
237
|
+
"rms": 0.08,
|
|
238
|
+
"gap": 78,
|
|
239
|
+
"magType": "md",
|
|
240
|
+
"type": "earthquake",
|
|
241
|
+
"title": "M 2.0 - 23 km NE of San Ardo, CA",
|
|
242
|
+
"coordinates": [
|
|
243
|
+
-120.757835388184,
|
|
244
|
+
36.1879997253418
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"mag": 1.5,
|
|
249
|
+
"place": "18 km N of Nellis Air Force Base, Nevada",
|
|
250
|
+
"time": 1740082632669,
|
|
251
|
+
"status": "automatic",
|
|
252
|
+
"tsunami": 0,
|
|
253
|
+
"sig": 35,
|
|
254
|
+
"net": "nn",
|
|
255
|
+
"types": ",origin,phase-data,",
|
|
256
|
+
"nst": 12,
|
|
257
|
+
"dmin": 0.142,
|
|
258
|
+
"rms": 0.352,
|
|
259
|
+
"gap": 324.6699999999999,
|
|
260
|
+
"magType": "ml",
|
|
261
|
+
"type": "earthquake",
|
|
262
|
+
"title": "M 1.5 - 18 km N of Nellis Air Force Base, Nevada",
|
|
263
|
+
"coordinates": [
|
|
264
|
+
-115.0204,
|
|
265
|
+
36.4137
|
|
266
|
+
]
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"mag": 2.4,
|
|
270
|
+
"place": "42 km ENE of Susitna North, Alaska",
|
|
271
|
+
"time": 1740082487421,
|
|
272
|
+
"status": "automatic",
|
|
273
|
+
"tsunami": 0,
|
|
274
|
+
"sig": 89,
|
|
275
|
+
"net": "ak",
|
|
276
|
+
"types": ",origin,phase-data,",
|
|
277
|
+
"rms": 0.58,
|
|
278
|
+
"magType": "ml",
|
|
279
|
+
"type": "earthquake",
|
|
280
|
+
"title": "M 2.4 - 42 km ENE of Susitna North, Alaska",
|
|
281
|
+
"coordinates": [
|
|
282
|
+
-149.1448,
|
|
283
|
+
62.358
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"mag": 0.58,
|
|
288
|
+
"place": "0 km of The Geysers, CA",
|
|
289
|
+
"time": 1740082396860,
|
|
290
|
+
"status": "automatic",
|
|
291
|
+
"tsunami": 0,
|
|
292
|
+
"sig": 5,
|
|
293
|
+
"net": "nc",
|
|
294
|
+
"types": ",nearby-cities,origin,phase-data,",
|
|
295
|
+
"nst": 8,
|
|
296
|
+
"dmin": 0.01016,
|
|
297
|
+
"rms": 0.04,
|
|
298
|
+
"gap": 122,
|
|
299
|
+
"magType": "md",
|
|
300
|
+
"type": "earthquake",
|
|
301
|
+
"title": "M 0.6 - 0 km of The Geysers, CA",
|
|
302
|
+
"coordinates": [
|
|
303
|
+
-122.75666809082,
|
|
304
|
+
38.7779998779297
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"mag": 0.77,
|
|
309
|
+
"place": "4 km NNW of The Geysers, CA",
|
|
310
|
+
"time": 1740082221410,
|
|
311
|
+
"status": "automatic",
|
|
312
|
+
"tsunami": 0,
|
|
313
|
+
"sig": 9,
|
|
314
|
+
"net": "nc",
|
|
315
|
+
"types": ",nearby-cities,origin,phase-data,",
|
|
316
|
+
"nst": 7,
|
|
317
|
+
"dmin": 0.006593,
|
|
318
|
+
"rms": 0.01,
|
|
319
|
+
"gap": 141,
|
|
320
|
+
"magType": "md",
|
|
321
|
+
"type": "earthquake",
|
|
322
|
+
"title": "M 0.8 - 4 km NNW of The Geysers, CA",
|
|
323
|
+
"coordinates": [
|
|
324
|
+
-122.78116607666,
|
|
325
|
+
38.8066673278809
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"mag": 0.76,
|
|
330
|
+
"place": "9 km NW of The Geysers, CA",
|
|
331
|
+
"time": 1740082075350,
|
|
332
|
+
"status": "automatic",
|
|
333
|
+
"tsunami": 0,
|
|
334
|
+
"sig": 9,
|
|
335
|
+
"net": "nc",
|
|
336
|
+
"types": ",nearby-cities,origin,phase-data,",
|
|
337
|
+
"nst": 12,
|
|
338
|
+
"dmin": 0.005851,
|
|
339
|
+
"rms": 0.02,
|
|
340
|
+
"gap": 80,
|
|
341
|
+
"magType": "md",
|
|
342
|
+
"type": "earthquake",
|
|
343
|
+
"title": "M 0.8 - 9 km NW of The Geysers, CA",
|
|
344
|
+
"coordinates": [
|
|
345
|
+
-122.842498779297,
|
|
346
|
+
38.8226661682129
|
|
347
|
+
]
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"mag": 1.8,
|
|
351
|
+
"place": "47 km ENE of Susitna North, Alaska",
|
|
352
|
+
"time": 1740081957855,
|
|
353
|
+
"status": "automatic",
|
|
354
|
+
"tsunami": 0,
|
|
355
|
+
"sig": 50,
|
|
356
|
+
"net": "ak",
|
|
357
|
+
"types": ",origin,phase-data,",
|
|
358
|
+
"rms": 0.79,
|
|
359
|
+
"magType": "ml",
|
|
360
|
+
"type": "earthquake",
|
|
361
|
+
"title": "M 1.8 - 47 km ENE of Susitna North, Alaska",
|
|
362
|
+
"coordinates": [
|
|
363
|
+
-149.0437,
|
|
364
|
+
62.3668
|
|
365
|
+
]
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"mag": 3.14,
|
|
369
|
+
"place": "73 km N of Brenas, Puerto Rico",
|
|
370
|
+
"time": 1740081663500,
|
|
371
|
+
"status": "reviewed",
|
|
372
|
+
"tsunami": 0,
|
|
373
|
+
"sig": 152,
|
|
374
|
+
"net": "pr",
|
|
375
|
+
"types": ",origin,phase-data,",
|
|
376
|
+
"nst": 10,
|
|
377
|
+
"dmin": 0.8083,
|
|
378
|
+
"rms": 0.23,
|
|
379
|
+
"gap": 271,
|
|
380
|
+
"magType": "md",
|
|
381
|
+
"type": "earthquake",
|
|
382
|
+
"title": "M 3.1 - 73 km N of Brenas, Puerto Rico",
|
|
383
|
+
"coordinates": [
|
|
384
|
+
-66.3835,
|
|
385
|
+
19.1311666666667
|
|
386
|
+
]
|
|
387
|
+
}
|
|
388
|
+
]
|
|
389
|
+
}
|
|
345
390
|
}
|
|
346
391
|
```
|
|
347
392
|
|
|
@@ -354,6 +399,7 @@ Need any assistance? [Get in touch with Customer Support](https://apiverve.com/c
|
|
|
354
399
|
---
|
|
355
400
|
|
|
356
401
|
## Updates
|
|
402
|
+
|
|
357
403
|
Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
|
|
358
404
|
|
|
359
405
|
---
|
|
@@ -373,4 +419,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
373
419
|
|
|
374
420
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
375
421
|
|
|
376
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
422
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basic Example - Worldwide Earthquakes API
|
|
3
|
+
*
|
|
4
|
+
* This example demonstrates how to use the Worldwide Earthquakes API.
|
|
5
|
+
* Make sure to set your API key in the .env file or replace '[YOUR_API_KEY]' below.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
require('dotenv').config();
|
|
9
|
+
const earthquakeAPI = require('../index.js');
|
|
10
|
+
|
|
11
|
+
// Initialize the API client
|
|
12
|
+
const api = new earthquakeAPI({
|
|
13
|
+
api_key: process.env.API_KEY || '[YOUR_API_KEY]'
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Example query
|
|
17
|
+
// This API does not require a Query
|
|
18
|
+
|
|
19
|
+
// Make the API request using callback
|
|
20
|
+
console.log('Making request to Worldwide Earthquakes API...\n');
|
|
21
|
+
|
|
22
|
+
api.execute(function (error, data) {
|
|
23
|
+
if (error) {
|
|
24
|
+
console.error('Error occurred:');
|
|
25
|
+
if (error.error) {
|
|
26
|
+
console.error('Message:', error.error);
|
|
27
|
+
console.error('Status:', error.status);
|
|
28
|
+
} else {
|
|
29
|
+
console.error(JSON.stringify(error, null, 2));
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
console.log('Response:');
|
|
35
|
+
console.log(JSON.stringify(data, null, 2));
|
|
36
|
+
});
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
declare module '@apiverve/earthquake' {
|
|
2
|
+
export interface earthquakeOptions {
|
|
3
|
+
api_key: string;
|
|
4
|
+
secure?: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface earthquakeResponse {
|
|
8
|
+
status: string;
|
|
9
|
+
error: string | null;
|
|
10
|
+
data: WorldwideEarthquakesData;
|
|
11
|
+
code?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
interface WorldwideEarthquakesData {
|
|
16
|
+
earthquakesLastUpdated: number;
|
|
17
|
+
earthquakesLastHour: number;
|
|
18
|
+
earthquakes: Earthquake[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Earthquake {
|
|
22
|
+
mag: number;
|
|
23
|
+
place: string;
|
|
24
|
+
time: number;
|
|
25
|
+
status: Status;
|
|
26
|
+
tsunami: number;
|
|
27
|
+
sig: number;
|
|
28
|
+
net: string;
|
|
29
|
+
types: string;
|
|
30
|
+
nst?: number;
|
|
31
|
+
dmin?: number;
|
|
32
|
+
rms: number;
|
|
33
|
+
gap?: number;
|
|
34
|
+
magType: MagType;
|
|
35
|
+
type: Type;
|
|
36
|
+
title: string;
|
|
37
|
+
coordinates: number[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
enum MagType {
|
|
41
|
+
Md = "md",
|
|
42
|
+
Ml = "ml",
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
enum Status {
|
|
46
|
+
Automatic = "automatic",
|
|
47
|
+
Reviewed = "reviewed",
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
enum Type {
|
|
51
|
+
Earthquake = "earthquake",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default class earthquakeWrapper {
|
|
55
|
+
constructor(options: earthquakeOptions);
|
|
56
|
+
|
|
57
|
+
execute(callback: (error: any, data: earthquakeResponse | null) => void): Promise<earthquakeResponse>;
|
|
58
|
+
execute(query: Record<string, any>, callback: (error: any, data: earthquakeResponse | null) => void): Promise<earthquakeResponse>;
|
|
59
|
+
execute(query?: Record<string, any>): Promise<earthquakeResponse>;
|
|
60
|
+
}
|
|
61
|
+
}
|
package/index.js
CHANGED
|
@@ -4,14 +4,27 @@ class earthquakeWrapper {
|
|
|
4
4
|
|
|
5
5
|
constructor(options) {
|
|
6
6
|
if (!options || typeof options !== 'object') {
|
|
7
|
-
throw new Error('Options object must be provided.');
|
|
7
|
+
throw new Error('Options object must be provided. See documentation: https://docs.apiverve.com/ref/earthquake');
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const { api_key, secure = true } = options;
|
|
11
11
|
|
|
12
12
|
if (!api_key || typeof api_key !== 'string') {
|
|
13
|
-
throw new Error('API key must be provided as a non-empty string.');
|
|
13
|
+
throw new Error('API key must be provided as a non-empty string. Get your API key at: https://apiverve.com');
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
// Validate API key format (GUID or alphanumeric with hyphens)
|
|
17
|
+
const apiKeyPattern = /^[a-zA-Z0-9-]+$/;
|
|
18
|
+
if (!apiKeyPattern.test(api_key)) {
|
|
19
|
+
throw new Error('Invalid API key format. API key must be alphanumeric and may contain hyphens. Get your API key at: https://apiverve.com');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Check minimum length (GUIDs are typically 36 chars with hyphens, or 32 without)
|
|
23
|
+
const trimmedKey = api_key.replace(/-/g, '');
|
|
24
|
+
if (trimmedKey.length < 32) {
|
|
25
|
+
throw new Error('Invalid API key. API key appears to be too short. Get your API key at: https://apiverve.com');
|
|
26
|
+
}
|
|
27
|
+
|
|
15
28
|
if (typeof secure !== 'boolean') {
|
|
16
29
|
throw new Error('Secure parameter must be a boolean value.');
|
|
17
30
|
}
|
|
@@ -24,20 +37,32 @@ class earthquakeWrapper {
|
|
|
24
37
|
}
|
|
25
38
|
|
|
26
39
|
async execute(query, callback) {
|
|
27
|
-
|
|
40
|
+
// Handle different argument patterns
|
|
41
|
+
if(arguments.length === 0) {
|
|
42
|
+
// execute() - no args
|
|
43
|
+
query = {};
|
|
44
|
+
callback = null;
|
|
45
|
+
} else if(arguments.length === 1) {
|
|
46
|
+
if (typeof query === 'function') {
|
|
47
|
+
// execute(callback)
|
|
48
|
+
callback = query;
|
|
49
|
+
query = {};
|
|
50
|
+
} else {
|
|
51
|
+
// execute(query)
|
|
52
|
+
callback = null;
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
// execute(query, callback)
|
|
28
56
|
if (!query || typeof query !== 'object') {
|
|
29
57
|
throw new Error('Query parameters must be provided as an object.');
|
|
30
58
|
}
|
|
31
|
-
} else {
|
|
32
|
-
callback = query;
|
|
33
|
-
query = {};
|
|
34
59
|
}
|
|
35
60
|
|
|
36
61
|
var requiredParams = [];
|
|
37
62
|
if (requiredParams.length > 0) {
|
|
38
63
|
for (var i = 0; i < requiredParams.length; i++) {
|
|
39
64
|
if (!query[requiredParams[i]]) {
|
|
40
|
-
throw new Error(`Required parameter [${requiredParams[i]}] is missing
|
|
65
|
+
throw new Error(`Required parameter [${requiredParams[i]}] is missing. See documentation: https://docs.apiverve.com/ref/earthquake`);
|
|
41
66
|
}
|
|
42
67
|
}
|
|
43
68
|
}
|
|
@@ -58,16 +83,25 @@ class earthquakeWrapper {
|
|
|
58
83
|
});
|
|
59
84
|
|
|
60
85
|
const data = response.data;
|
|
61
|
-
callback(null, data);
|
|
86
|
+
if (callback) callback(null, data);
|
|
62
87
|
return data;
|
|
63
88
|
} catch (error) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
let apiError;
|
|
90
|
+
|
|
91
|
+
if (error.response && error.response.data) {
|
|
92
|
+
apiError = error.response.data;
|
|
93
|
+
} else if (error.message) {
|
|
94
|
+
apiError = { error: error.message, status: 'error' };
|
|
67
95
|
} else {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
96
|
+
apiError = { error: 'An unknown error occurred', status: 'error' };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (callback) {
|
|
100
|
+
callback(apiError, null);
|
|
101
|
+
return; // Don't throw if callback is provided
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
throw apiError;
|
|
71
105
|
}
|
|
72
106
|
}
|
|
73
107
|
|
package/package.json
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apiverve/earthquake",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "Earthquake is a simple tool for getting earthquake data. It returns the earthquake data for the past hour.",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"test": "mocha"
|
|
8
|
+
"test": "mocha",
|
|
9
|
+
"example": "node examples/basic.js"
|
|
8
10
|
},
|
|
9
11
|
"repository": {
|
|
10
12
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/apiverve/earthquake-
|
|
13
|
+
"url": "git+https://github.com/apiverve/earthquake-api.git",
|
|
14
|
+
"directory": "npm"
|
|
12
15
|
},
|
|
13
16
|
"keywords": [
|
|
14
|
-
"earthquake","earthquake api","earthquake tool","earthquake software","earthquake service"
|
|
17
|
+
"earthquake", "earthquake api", "earthquake tool", "earthquake software", "earthquake service"
|
|
15
18
|
],
|
|
16
19
|
"author": "APIVerve <hello@apiverve.com> (http://apiverve.com/)",
|
|
17
20
|
"license": "MIT",
|
|
18
21
|
"bugs": {
|
|
19
|
-
"url": "https://github.com/apiverve/earthquake-
|
|
22
|
+
"url": "https://github.com/apiverve/earthquake-api/issues"
|
|
20
23
|
},
|
|
21
|
-
"homepage": "https://apiverve.com/marketplace/
|
|
24
|
+
"homepage": "https://apiverve.com/marketplace/earthquake?utm_source=npm",
|
|
22
25
|
"devDependencies": {
|
|
23
26
|
"mocha": "^11.0.1",
|
|
24
27
|
"chai": "^5.1.2",
|
|
@@ -27,6 +30,6 @@
|
|
|
27
30
|
"dependencies": {
|
|
28
31
|
"node-fetch": "^3.3.2",
|
|
29
32
|
"promise": "^8.3.0",
|
|
30
|
-
"axios": "1.
|
|
33
|
+
"axios": "1.13.2"
|
|
31
34
|
}
|
|
32
35
|
}
|