# USGS earthquakes monitor (`keepable_injera/usgs-earthquakes-monitor`) Actor

Monitor USGS earthquakes by time, magnitude, region, and alert level.

- **URL**: https://apify.com/keepable_injera/usgs-earthquakes-monitor.md
- **Developed by:** [Chee Chiaw Lim](https://apify.com/keepable_injera) (community)
- **Categories:** News, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## USGS earthquakes monitor

This Apify Actor returns earthquakes from the USGS FDSN event web service. Empty input selects events from the last 24 hours with magnitude at least 2.5, worldwide, up to 100 source events.

### Coverage and source

The Actor queries the [USGS event service](https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson). It supports time, magnitude, region, and alert filters. Use it to collect recent events into an Apify dataset and skip event IDs emitted by an earlier run.

The time window uses the event origin time. USGS can revise event data after publication. The output includes both `time` and `updated`.

### Input

| Field | Default | Meaning |
| --- | --- | --- |
| `sinceHours` | 24 | Integer hours before the run start, from 1 to 8760. |
| `endtime` | empty | Optional ISO timestamp. Must be at or after the calculated start time. |
| `minMagnitude` | "2.5" | Minimum magnitude as a numeric string. |
| `maxMagnitude` | empty | Optional maximum magnitude as a numeric string. |
| `region` | {} | Empty selects worldwide. Use a complete box or circle. |
| `alertLevel` | empty | Optional green, yellow, orange, or red alert filter. |
| `onlyNew` | false | Skip event IDs previously emitted to the state store. |
| `maxItems` | 100 | Maximum source events examined, from 1 to 10000, before duplicate filtering. |
| `stateStoreName` | usgs-earthquakes-monitor-state | Named KV store for cross-run deduplication. |

A box requires `minLatitude`, `maxLatitude`, `minLongitude`, and `maxLongitude` inside `region`. A circle requires `latitude`, `longitude`, and `maxRadiusKm`. All region values are numeric strings. Box and circle filters are mutually exclusive. Latitude ranges from -90 to 90 and longitude from -180 to 180. A box with minimum longitude greater than maximum longitude crosses the date line.

Example circle input:

```json
{
  "sinceHours": 48,
  "minMagnitude": "3.0",
  "region": { "latitude": "35", "longitude": "-118", "maxRadiusKm": "300" },
  "maxItems": 100,
  "onlyNew": true
}
```

Requests use `orderby=time`, a page size of `min(maxItems, 20000)`, and 1-based offsets. Collection stops at `maxItems` source events or a short page. Duplicate and seen events can reduce the number emitted.

### Output

Each record includes event identifiers, magnitude, coordinates, depth in kilometres, status, impact fields, timestamps, event links, and attribution. Missing source values are null. `types` is an array of product type names. `tsunami` converts the source flag to a boolean; it is not a warning or forecast.

Example from the supplied USGS fixture:

```json
{
  "eventId": "us7000tu7b",
  "magnitude": 4.6,
  "magType": "mb",
  "place": "64 km SSW of Shikotan, Russia",
  "time": "2026-10-30T08:45:49.982Z",
  "updated": "2026-10-30T09:01:05.040Z",
  "latitude": 43.2605,
  "longitude": 146.4242,
  "depthKm": 43.625,
  "status": "reviewed",
  "tsunami": false,
  "alert": null,
  "felt": null,
  "cdi": null,
  "mmi": null,
  "sig": 326,
  "network": "us",
  "types": [
    "origin",
    "phase-data"
  ],
  "title": "M 4.6 - 64 km SSW of Shikotan, Russia",
  "url": "https://earthquake.usgs.gov/earthquakes/eventpage/us7000tu7b",
  "detailUrl": "https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=us7000tu7b&format=geojson",
  "source": "U.S. Geological Survey Earthquake Hazards Program",
  "sourceUrl": "https://earthquake.usgs.gov/earthquakes/eventpage/us7000tu7b",
  "licence": "U.S. Public Domain (https://www.usgs.gov/information-policies-and-instructions/copyrights-and-credits)",
  "credit": "U.S. Geological Survey",
  "generatedId": "USGS:us7000tu7b",
  "changeType": "new",
  "scrapedAt": "2026-10-30T09:29:06.757Z"
}
```

The state store contains event IDs under `SEEN_EVENT_IDS`. An absent ID gets `changeType` of `new`; a stored ID gets `seen`. Only successful pushes enter the set. With `onlyNew` false, previously emitted events appear again. With `onlyNew` true, revisions to seen events are skipped even when `updated` changes. Use separate state stores for independent monitors. A named-store permission failure falls back to the default store and disables `onlyNew` for that run.

`RUN_SUMMARY` records fetched, eligible, and pushed counts, effective `onlyNew`, charge-limit status, and any run error.

### Pricing

$0.001 per result, no start fee. Each emitted record uses the `result` billing event. Skipped records do not incur a result charge. The Actor stops at the available charge limit. Platform compute and storage charges may apply separately.

### Licence and credit

Source and credit belong to the U.S. Geological Survey. Records carry the source name, event page URL, and `U.S. Public Domain (https://www.usgs.gov/information-policies-and-instructions/copyrights-and-credits)`.

The Actor maps the source GeoJSON into dataset records. It does not require API keys or proxies.

### Limits

USGS can add, revise, or remove events. Offset pages can shift while the source changes. Results are a snapshot, and this Actor does not detect revisions through `onlyNew`. It is not an emergency alert system.

The Actor waits at least one second between HTTP request starts per host and retries HTTP 429 and 5xx responses up to three times. Network failures stop the run and appear in `RUN_SUMMARY`. The User-Agent is `keepable_injera-apify-monitor (cheechiawbot@mail.grokbot.com)`.

### Local verification

Run `npm test` for offline tests. Use a fresh storage directory for a fixture-backed local run:

```sh
CRAWLEE_STORAGE_DIR=/tmp/usgs-check APIFY_LOCAL_STORAGE_DIR=/tmp/usgs-check APIFY_TOKEN='' APIFY_IS_AT_HOME='' NODE_OPTIONS="--import ./scripts/offline-fixture.js" npm start
node scripts/verify-output.js /tmp/usgs-check
```

The preload serves the supplied USGS fixture and blocks network requests. It simulates paging but does not apply source filters. The verifier reads saved dataset records and `RUN_SUMMARY`.

# Actor input Schema

## `sinceHours` (type: `integer`):

Hours back.

## `endtime` (type: `string`):

Optional end timestamp. Empty uses the service current time.

## `minMagnitude` (type: `string`):

Minimum magnitude.

## `maxMagnitude` (type: `string`):

Maximum magnitude.

## `region` (type: `object`):

Complete box or circle. Empty selects worldwide.

## `alertLevel` (type: `string`):

Empty selects all alert levels.

## `onlyNew` (type: `boolean`):

Skip event IDs already emitted. Updates to seen events are skipped too.

## `maxItems` (type: `integer`):

Maximum source events examined before deduplication and onlyNew filtering.

## `stateStoreName` (type: `string`):

State store name.

## Actor input object example

```json
{
  "sinceHours": 24,
  "endtime": "",
  "minMagnitude": "2.5",
  "maxMagnitude": "",
  "region": {},
  "alertLevel": "",
  "onlyNew": false,
  "maxItems": 100,
  "stateStoreName": "usgs-earthquakes-monitor-state"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `runSummary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "sinceHours": 24,
    "endtime": "",
    "minMagnitude": "2.5",
    "maxMagnitude": "",
    "region": {},
    "alertLevel": "",
    "onlyNew": false,
    "maxItems": 100,
    "stateStoreName": "usgs-earthquakes-monitor-state"
};

// Run the Actor and wait for it to finish
const run = await client.actor("keepable_injera/usgs-earthquakes-monitor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "sinceHours": 24,
    "endtime": "",
    "minMagnitude": "2.5",
    "maxMagnitude": "",
    "region": {},
    "alertLevel": "",
    "onlyNew": False,
    "maxItems": 100,
    "stateStoreName": "usgs-earthquakes-monitor-state",
}

# Run the Actor and wait for it to finish
run = client.actor("keepable_injera/usgs-earthquakes-monitor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "sinceHours": 24,
  "endtime": "",
  "minMagnitude": "2.5",
  "maxMagnitude": "",
  "region": {},
  "alertLevel": "",
  "onlyNew": false,
  "maxItems": 100,
  "stateStoreName": "usgs-earthquakes-monitor-state"
}' |
apify call keepable_injera/usgs-earthquakes-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,keepable_injera/usgs-earthquakes-monitor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ZIKSsgbgd5Uo0j6fc/builds/0Xg8f6cgspfBFdgI2/openapi.json
