Earthquake Data API
Earthquake Data provided by USGS.gov is very neat and complete. You can arrange your query based on parameters like coordinates, dates, alert level, tsunami causing or not, duration and others.
If you are interested in earthquake data, this is certainly an API you should check out.
Here is a simple example about how you can make use of USGS.gov‘s earthquake API.
import requests
import json
def earthquake(f):
paramss = {"format": "geojson", "starttime": "2018-
01-01", "endtime": "2019-12-31", "alertlevel":
"orange"}
data = requests.get(f, params = paramss)
data = json.loads(data.text)
return data
f = r"https://earthquake.usgs.gov/fdsnws/event/1/query?"
a = earthquake(f)
for i in (a["features"]):
print(i["properties"]["time"], i["properties"]["place"],
i["properties"]["cdi"], i["properties"]["tsunami"])
time | place | country | magnitude | tsunami |
1574736852594 | 16km WSW of Mamurras, | Albania | 9.1 | 0 |
1573166825428 | 57km NE of Hashtrud, | Iran | 7.9 | 0 |
1569322914969 | 8km SSE of New Mirpur | Pakistan | 7.1 | 0 |
1561213796148 | 11km SE of Xunchang, | China | 5.8 | 0 |
1558856475073 | 78km SE of Lagunas, | Peru | 8.9 | 1 |
1547947972480 | 10km SSW of Coquimbo, | Chile | 7.8 | 1 |
1543598969330 | 14km NNW of Anchorage, | Alaska | 7.6 | 1 |
1536170879150 | 27km ENE of Tomakomai, | Japan | 8.1 | 1 |
1533469598630 | 0km SW of Loloan, | Indonesia | 8.1 | 1 |
If you need a refresher on user defined functions lesson in Python here is a link to our Defining Functions Lesson.
Source of API: Earthquake USGS
Source: The Seattle Times