Skip to main content

How to Query the USGS Earthquake API with curl

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

The U.S. Geological Survey (USGS) publishes every earthquake it records worldwide through a free web API, with no account and no key. Ask it how many earthquakes happened on a day, or for a list of the strong ones, and it answers in a second. This guide asks it with curl in the terminal, and shows the one quoting rule that makes or breaks these commands.

Syntax​

Syntax
curl -s "https://earthquake.usgs.gov/fdsnws/event/1/<method>?<parameter>=<value>&=<value>"
PartWhat it means
curl -sSends the request and prints the answer, without the progress meter
<method>count for a number, query for the earthquakes themselves
? and &? starts the parameters; & separates them
format=geojson or format=textThe answer as JSON, or as plain text
eventtype=earthquakeOnly earthquakes. The documentation notes that it "will filter non-earthquake events"
starttime=<date>, endtime=<date>The time range, in UTC unless you give a time zone
minmagnitude=<number>Only events at least this strong
orderby=time-ascOldest first. The default, time, puts the newest first
The double quotesKeep the shell from reading ? and & itself

The USGS documentation describes the service as an implementation of the FDSN Event Web Service Specification that "allows custom searches for earthquake information". count "uses the same parameters as the query method".

Step 1: Count One Day's Earthquakes​

Terminal
curl -s "https://earthquake.usgs.gov/fdsnws/event/1/count?format=geojson&eventtype=earthquake&starttime=2026-11-30&endtime=2026-12-01"
Output
{"count":338,"maxAllowed":20000}

The terminal: curl to the USGS count method for 2026-11-30 returns count 338 and maxAllowed 20000.

338 earthquakes were recorded on November 30, 2026, from midnight to midnight UTC: a date without a time means the start of that day. maxAllowed is the most events one query may return; the documentation says a request over 20,000 gets "400 Bad Request".

USGS keeps reviewing and adding events, so counts change. I ran this at 03:53 UTC on December 1; two hours later the same command returned 339.

Step 2: Count Only the Stronger Ones​

Add minmagnitude:

Terminal
curl -s "https://earthquake.usgs.gov/fdsnws/event/1/count?format=geojson&eventtype=earthquake&starttime=2026-11-30&endtime=2026-12-01&minmagnitude=4.5"
Output
{"count":36,"maxAllowed":20000}

36 of them were magnitude 4.5 or more.

Step 3: List the Strongest Ones​

Switch to query, ask for magnitude 6 or more, as plain text, oldest first:

Terminal
curl -s "https://earthquake.usgs.gov/fdsnws/event/1/query?format=text&eventtype=earthquake&starttime=2026-11-30&endtime=2026-12-01&minmagnitude=6&orderby=time-asc"
Output
#EventID|Time|Latitude|Longitude|Depth/km|Author|Catalog|Contributor|ContributorID|MagType|Magnitude|MagAuthor|EventLocationName
us6000uee5|2026-11-30T03:07:41.480|51.7693|177.1494|10|us|us|us|us6000uee5|mww|7.4|us|295 km ESE of Attu Station, Alaska
us6000uee7|2026-11-30T03:12:50.907|51.9239|177.1265|10|us|us|us|us6000uee7|mb|6|us|287 km ESE of Attu Station, Alaska
us6000uei4|2026-11-30T13:36:01.024|16.475|-93.598|138.61|us|us|us|us6000uei4|mww|6.8|us|4 km ESE of Nueva Palestina, Mexico

The terminal: the USGS query in text format lists three earthquakes of magnitude 6 or more on 2026-11-30: a magnitude 7.4 and a 6 near Attu Station, Alaska, and a 6.8 near Nueva Palestina, Mexico.

Three, one per line, with | between the fields. The first line names the columns: an ID, the time in UTC, the position and depth, the magnitude and its type, and the nearest place. A magnitude 7.4 earthquake struck 295 km east-southeast of Attu Station, Alaska, followed five minutes later by a magnitude 6 nearby.

The second one has a magnitude of exactly 6. The documentation describes minmagnitude as "larger than" the minimum, but events at the minimum are included.

Step 4: Keep the URL in Quotes​

The same kind of URL without quotes fails, differently in each shell:

Output in zsh
zsh:1: no matches found: https://earthquake.usgs.gov/fdsnws/event/1/count?format=geojson
Output in bash
{"count":9686,"maxAllowed":20000}

zsh treats ? as a wildcard for file names and stops. bash runs, but cuts the command at the first &: it sends only ?format=geojson, with no type and no dates, so USGS counted every event of the last 30 days, its default range. Both go away with double quotes around the URL.

In PowerShell​

The commands work unchanged in PowerShell 7, where curl is the real curl program. In Windows PowerShell 5.1, curl is an alias of Invoke-WebRequest, which takes different options: type curl.exe there, as Microsoft's documentation advises.

Common Mistakes​

MistakeWhat happensDo this instead
No quotes around the URLzsh: no matches found; bash: the request loses everything after the first &Put the URL in double quotes
Local dates where UTC is meantThe day is shifted by your time zoneGive dates in UTC, or add a time zone
Leaving out eventtype=earthquakeThe count includes other events tooAdd it
Asking query for a huge rangeOver 20,000 events, the answer is 400 Bad RequestUse count first, then narrow the range

Troubleshooting​

SymptomLikely causeFix
A number much larger than expectedThe URL lost its dates (see Step 4)Quote the URL
A slightly different number from mineUSGS has reviewed or added events sinceNothing to fix
400 Bad Request from queryMore than 20,000 events matchcount the same request, then narrow the range

FAQ​

Does the USGS API need a key?​

No. It's free and open.

Can I use the data on my website?​

USGS data is in the U.S. public domain. USGS asks that you credit it as "Credit: U.S. Geological Survey". For live displays, it recommends its real-time GeoJSON feeds over this search API.

Which time zone are the times in?​

UTC, unless your request specifies a time zone.

Conclusion​

count returned 338 earthquakes for November 30, 2026, and 36 of magnitude 4.5 or more; query with format=text listed the three of magnitude 6 or more, headed by a 7.4 near Attu Station, Alaska. Quoting the URL is what keeps ? and & away from the shell.

Additional Resources​

Credit: U.S. Geological Survey.