How to Query the USGS Earthquake API with curl
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
curl -s "https://earthquake.usgs.gov/fdsnws/event/1/<method>?<parameter>=<value>&=<value>"
| Part | What it means |
|---|---|
curl -s | Sends 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=text | The answer as JSON, or as plain text |
eventtype=earthquake | Only 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-asc | Oldest first. The default, time, puts the newest first |
| The double quotes | Keep 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
curl -s "https://earthquake.usgs.gov/fdsnws/event/1/count?format=geojson&eventtype=earthquake&starttime=2026-11-30&endtime=2026-12-01"
{"count":338,"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:
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"
{"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:
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"
#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

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:
zsh:1: no matches found: https://earthquake.usgs.gov/fdsnws/event/1/count?format=geojson
{"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
| Mistake | What happens | Do this instead |
|---|---|---|
| No quotes around the URL | zsh: no matches found; bash: the request loses everything after the first & | Put the URL in double quotes |
| Local dates where UTC is meant | The day is shifted by your time zone | Give dates in UTC, or add a time zone |
Leaving out eventtype=earthquake | The count includes other events too | Add it |
Asking query for a huge range | Over 20,000 events, the answer is 400 Bad Request | Use count first, then narrow the range |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| A number much larger than expected | The URL lost its dates (see Step 4) | Quote the URL |
| A slightly different number from mine | USGS has reviewed or added events since | Nothing to fix |
400 Bad Request from query | More than 20,000 events match | count 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
- USGS earthquake API documentation — every method and parameter.
- USGS copyrights and credits — public domain and how to credit USGS.
- curl on Windows — curl.exe and the PowerShell 5.1 alias.
Credit: U.S. Geological Survey.
