> ## Documentation Index
> Fetch the complete documentation index at: https://docs.terraquakeapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Last Week's Earthquakes

> Retrieve all earthquake events from the last 7 days

Fetches all earthquake events that occurred in the last 7 days, including today. This endpoint is ideal for weekly summaries and trend analysis.

## Endpoint

**Method:** GET\
**Path:** `/v1/earthquakes/last-week`\
**Authentication:** Not required

## Parameters

**page** `integer` (default: 1)

Page number for pagination. Must be a positive integer greater than 0.

**Validation:**

* Must be > 0
* Returns 400 error: "The 'page' parameter must be a positive integer (e.g., ?page=2)."

**limit** `integer` (default: 50)

Number of results per page. Must be a positive integer greater than 0.

**Validation:**

* Must be > 0
* Returns 400 error: "The 'limit' parameter must be a positive integer greater than 0. Example: ?limit=50"

**sort** `string` (default: -time)

Sort order for results. Prefix with `-` for descending order.

**Allowed values:**

* `time` or `-time` (default: descending)
* `magnitude` or `-magnitude`
* `depth` or `-depth`

**fields** `string`

Comma-separated list of fields to include in response.

**Allowed values:**

* `time`
* `magnitude`
* `depth`
* `place`
* `coordinates`

## Request Example

```bash cURL theme={null}
curl "https://api.terraquakeapi.com/v1/earthquakes/last-week?limit=200"
```

```javascript JavaScript theme={null}
const response = await fetch(
  'https://api.terraquakeapi.com/v1/earthquakes/last-week?limit=200'
);
const data = await response.json();

if (data.success) {
  console.log(`Earthquakes in last 7 days: ${data.totalEarthquakes}`);
  console.log(`Date range: ${data.message}`);
  data.payload.forEach(quake => {
    const { mag, place, time } = quake.properties;
    console.log(`${mag} - ${place} at ${time}`);
  });
}
```

```python Python theme={null}
import requests

response = requests.get(
    'https://api.terraquakeapi.com/v1/earthquakes/last-week',
    params={'limit': 200}
)
data = response.json()

if data.get('success'):
    print(f"Earthquakes in last 7 days: {data.get('totalEarthquakes')}")
    print(f"Date range: {data.get('message')}")
    for quake in data.get('payload', []):
        props = quake['properties']
        print(f"{props['mag']} - {props['place']} at {props['time']}")
```

## Response

**success** `boolean`

Indicates if the request was successful

**code** `integer`

HTTP status code (200 for success)

**status** `string`

HTTP status message ("OK" for success)

**message** `string`

Human-readable message including date range. Format: "Earthquake events from the last 7 days ({startDate} to {endDate})"

**payload** `array`

Array of GeoJSON Feature objects containing earthquake data

**meta** `object`

Request metadata containing method, path, and timestamp

**totalEarthquakes** `integer`

Total count of earthquakes in the last 7 days

**pagination** `object`

Pagination details with page, totalPages, limit, and hasMore

## Response Example

```json theme={null}
{
  "success": true,
  "code": 200,
  "status": "OK",
  "message": "Earthquake events from the last 7 days (2025-10-30 to 2025-11-06)",
  "payload": [
    {
      "type": "Feature",
      "properties": {
        "eventId": 44604942,
        "originId": 141077201,
        "time": "2025-11-05T23:31:48.030000",
        "author": "SURVEY-INGV-CT#KATALOC",
        "magType": "ML",
        "mag": 2.1,
        "magAuthor": "--",
        "type": "earthquake",
        "place": "13 km SE Maletto (CT)",
        "version": 100,
        "geojson_creationTime": "2025-11-06T00:40:00"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [14.97, 37.751, 5.5]
      }
    }
  ],
  "meta": {
    "method": "GET",
    "path": "/v1/earthquakes/last-week?limit=200",
    "timestamp": "2025-11-06T00:51:33.850Z"
  },
  "totalEarthquakes": 487,
  "pagination": {
    "page": 1,
    "totalPages": 3,
    "limit": 200,
    "hasMore": true
  }
}
```

## Error Responses

### Invalid Limit Parameter

```json theme={null}
{
  "success": false,
  "code": 400,
  "status": "Bad Request",
  "message": "The 'limit' parameter must be a positive integer greater than 0. Example: ?limit=50"
}
```

### Invalid Page Parameter

```json theme={null}
{
  "success": false,
  "code": 400,
  "status": "Bad Request",
  "message": "The 'page' parameter must be a positive integer (e.g., ?page=2)."
}
```

## Implementation Details

* **Date Calculation:** `today.getDate() - 7` to get start date
* **Date Range:** Last 7 days including today (e.g., Oct 30 to Nov 6)
* **Sorting:** Default sort is by time (most recent first: `-time`)
* **Pagination:** Manual pagination applied after fetching all events from INGV
* **Data Source:** INGV API with `orderby=time` and `format=geojson`

## Use Cases

* Weekly seismic activity reports
* Trend analysis and pattern detection
* Weekly email digests or newsletters
* Comparing recent activity to historical data

## Related Endpoints

* [Today's Earthquakes](https://docs.terraquakeapi.com/api/earthquakes/today.md) - Only today's events
* [Recent Earthquakes](https://docs.terraquakeapi.com/api/earthquakes/recent.md) - Year-to-date events
* [By Date Range](https://docs.terraquakeapi.com/api/earthquakes/by-date-range.md) - Custom date range


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.