# USGS Earthquakes Near My Sites (`natstandridge/usgs-earthquake-asset-proximity-feed`) Actor

Match the official USGS recent-earthquake feed against a small facility list and deliver new or materially revised nearby event findings with distance and source provenance.

- **URL**: https://apify.com/natstandridge/usgs-earthquake-asset-proximity-feed.md
- **Developed by:** [Nathaniel Standridge](https://apify.com/natstandridge) (community)
- **Categories:** Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.00 / 1,000 delivered earthquake proximity findings

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 Near My Sites

Match recent USGS-reported earthquakes against a bounded list of facility coordinates. Each dataset row is one **new or materially revised event × site finding** within that site's radius. The row includes great-circle distance, reported magnitude and depth, event and revision times, an official USGS event-page URL, and the exact feed version used. A site with no match produces no paid row.

### Start with a site list

```json
{
  "assets": [{"id": "california-ops", "lat": 36.5, "lon": -121, "radiusKm": 500}],
  "monitorKey": "west-sites",
  "lookbackHours": 144,
  "minMagnitude": 2.5,
  "maxFindings": 20
}
```

Use `assets: []` for a valid zero-output run; omitting `assets` is invalid in the Actor runtime. An asset needs exactly `id`, `lat`, `lon`, and `radiusKm`. IDs and monitor keys contain only letters, digits, `_`, and `-`, start with a letter or digit, and are at most 50 characters. Provide up to 50 assets, each with radius 1–2,000 km. The maximum lookback is 144 hours; the source is the fixed official USGS M2.5+ past-week summary feed. The minimum magnitude may be 2.5–9.5. `maxFindings` caps new paid rows at 200. The source is fetched once per nonempty run, not once per asset.

### Run it repeatedly

For the next scheduled run, paste the preceding run's `OUTPUT.snapshot` into `previousSnapshot` and keep the same `monitorKey`. Unchanged asset/event pairs then produce no new rows or charges. A material change to the site's coordinates/radius or the USGS event's reported magnitude, location, depth, time, or place creates a new finding. A metadata-only `updated` timestamp does not. `OUTPUT.snapshot` contains only delivered findings plus in-scope prior signatures; a failed source request or undelivered row never advances the baseline. Snapshot capacity is 500 pairs covering current assets and events in the past seven days. If that limit, `maxFindings`, or the native charge cap prevents full delivery, `OUTPUT.complete` is false and `stopReason` identifies the limit.

Read the dataset for findings and the `OUTPUT` key-value record for coverage, counts, source provenance, errors, and the next snapshot. `RESULT_PLAN` holds the frozen planned rows for restart reconciliation. If a billable dataset write has an uncertain outcome, the Actor stops with a pending checkpoint; reconcile that same run's dataset and native charged-event count before any retry. There is one native `apify-default-dataset-item` charge for each delivered finding and no other charging path. Source errors and zero matches generate no charge.

### Source and interpretation

The only outbound destination is `https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.geojson`; user input cannot change it. Redirects are refused, response size and feature count are capped, and stale or malformed feeds fail rather than become false zero-match results. Non-earthquake event types are excluded. Each row records feed SHA-256, generation and retrieval times, HTTP Last-Modified when valid, source counts, and the official event page URL built from a validated event ID. The feed and event data can be revised; a snapshot from another monitor or stale seven-day window is not a complete history.

Distance is great-circle distance to the **reported epicenter**. Proximity does not establish shaking, exposure, damage, or an emergency declaration. USGS [describes the real-time GeoJSON feeds](https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php) and also offers [free ENS alerts](https://earthquake.usgs.gov/ens/userhome). This Actor is an integration-oriented asset matching feed, not an emergency alert service. Paid demand, customer acquisition, compute margin, and profit have not been measured.

### Local verification

`uv run --locked --no-cache python -B -m unittest discover -s tests -v` checks input, source, matching, billing/restart and release contracts. `tools/validate_cloud.py RUN_DIRECTORY examples/cloud-cases.json CASE` independently checks private `full`, `empty`, `cap`, `malformed`, and `resurrection` evidence after a cloud run. `resurrection` reuses the `full` run; it is not a second paid run. Example input and output under `examples/` are synthetic or live-source local evidence as labeled, never customer or revenue evidence.

# Actor input Schema

## `assets` (type: `array`):

Explicit list of 0–50 sites. Each site has a unique safe id, latitude, longitude and radiusKm (1–2000). An explicit empty list returns zero findings and makes no source request; omitting assets is invalid in the Actor runtime.

## `monitorKey` (type: `string`):

Stable 1–50 character watch identifier used with previousSnapshot to suppress repeat findings; letters, digits, underscores and hyphens only.

## `lookbackHours` (type: `integer`):

Include only USGS event times in the last 1–144 hours, within the fixed past-week feed.

## `minMagnitude` (type: `number`):

Reported USGS magnitude threshold from 2.5 to 9.5. The fixed feed itself contains only M2.5+ events.

## `maxFindings` (type: `integer`):

At most 1–200 delivered event-by-site findings per run. Unsent findings are reported as partial and are not charged.

## `previousSnapshot` (type: `array`):

Paste OUTPUT.snapshot from the prior run with the same monitorKey. Only delivered findings update it; up to 500 asset/event signatures.

## `maxRunSeconds` (type: `integer`):

Maximum time for the one fixed USGS feed request, matching and dataset delivery (45–180 seconds).

## `requestTimeoutSeconds` (type: `integer`):

Network timeout of 5–30 seconds for the fixed USGS HTTPS request. Source redirects are refused.

## Actor input object example

```json
{
  "assets": [
    {
      "id": "california-ops",
      "lat": 36.5,
      "lon": -121,
      "radiusKm": 500
    }
  ],
  "monitorKey": "west-sites",
  "lookbackHours": 144,
  "minMagnitude": 2.5,
  "maxFindings": 20,
  "maxRunSeconds": 120,
  "requestTimeoutSeconds": 20
}
```

# Actor output Schema

## `findings` (type: `string`):

No description

## `summary` (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 = {
    "assets": [
        {
            "id": "california-ops",
            "lat": 36.5,
            "lon": -121,
            "radiusKm": 500
        }
    ],
    "monitorKey": "west-sites",
    "lookbackHours": 144,
    "minMagnitude": 2.5,
    "maxFindings": 20,
    "maxRunSeconds": 120,
    "requestTimeoutSeconds": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("natstandridge/usgs-earthquake-asset-proximity-feed").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 = {
    "assets": [{
            "id": "california-ops",
            "lat": 36.5,
            "lon": -121,
            "radiusKm": 500,
        }],
    "monitorKey": "west-sites",
    "lookbackHours": 144,
    "minMagnitude": 2.5,
    "maxFindings": 20,
    "maxRunSeconds": 120,
    "requestTimeoutSeconds": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("natstandridge/usgs-earthquake-asset-proximity-feed").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 '{
  "assets": [
    {
      "id": "california-ops",
      "lat": 36.5,
      "lon": -121,
      "radiusKm": 500
    }
  ],
  "monitorKey": "west-sites",
  "lookbackHours": 144,
  "minMagnitude": 2.5,
  "maxFindings": 20,
  "maxRunSeconds": 120,
  "requestTimeoutSeconds": 20
}' |
apify call natstandridge/usgs-earthquake-asset-proximity-feed --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,natstandridge/usgs-earthquake-asset-proximity-feed"
        }
    }
}
```

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/3MQPtXl4ANfPk3ohs/builds/p2rmiQQl2bxRwDb0N/openapi.json
