The Felt REST API allows you to programmatically interact with the Felt platform, enabling you to integrate Felt's powerful mapping capabilities into your own workflows and pipelines.
You are able to create and manipulate Maps, Layers, Annotations, Sources, Projects and more.
All Felt API endpoints are hosted at the following base URL:
https://felt.com/api/v2
Create an API token
All calls to the Felt API must be authenticated. The easiest way to authenticate your API calls is by creating a API token and providing it as a Bearer token in the request header.
The easiest way to interact with the Felt API is by using our felt-python SDK. You can install it with the following command:
Example: Creating a new map
Creating a new map is as simple as making a POST request to the maps endpoint.
Notice in the response the "id" property. Every map has a unique ID, which is also a part of the map's URL. Let's take note of it for future API calls.
Also part of the response is a "url" property, which is the URL to your newly-created map. Feel free to open it! For now, it should just show a blank map.
Example: Uploading a layer from a URL
Now that we've created a new map, let's add some data to it. We'll need the map_id included in the previous call's response.
Like maps, layers also have unique identifiers. Let's take note of this one (also called "id" in the response) so we can style it in the next call.
You can see the uploaded result in your map:
Since we imported a live data feed, the points on your layer may look different.
Example: Styling a layer
Layer styles are defined in the Felt Style Language, a JSON-based specification that allows customizing a layer's style, legend, label and popups.
Layers can be styled at upload time or afterwards. Let's change the style of our newly-created earthquakes layer so that points are bigger and in green color:
Go to your map to see how your new layer looks:
Since we imported a live data feed, the points on your layer may look different.
Example: Refreshing a live data layer
A layer must have finished uploading successfully before it can be refreshed
Similar to a URL upload, refreshing an existing URL layer is just a matter of making a single POST request:
Now go to your map and see if any new earthquakes have occured!
# Your API token should look like this:
# FELT_API_TOKEN="felt_pat_ABCDEFUDQPAGGNBmX40YNhkCRvvLI3f8/BCwD/g8"
FELT_API_TOKEN="<YOUR_API_TOKEN>"
curl -L \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${FELT_API_TOKEN}" \
"https://felt.com/api/v2/maps" \
-d '{"title": "My newly created map"}'
import requests
# This looks like:
# api_token = "felt_pat_ABCDEFUDQPAGGNBmX40YNhkCRvvLI3f8/BCwD/g8"
api_token = "<YOUR_API_TOKEN>"
r = requests.post(
"http://felt.com/api/v2/maps",
json={"title": "My newly created map"},
headers={"Authorization": f"Bearer {api_token}"}
)
assert r.ok
map_id = r.json()["id"]
print(r.json())
import os
from felt_python import create_map
# Setting your API token as an env variable can save
# you from repeating it in every function call
os.environ["FELT_API_TOKEN"] = "<YOUR_API_TOKEN>"
response = create_map(
title="My newly created map",
lat=40,
lon=-3,
public_access="private",
)
map_id = response["id"]
# Store the map ID from the previous call:
# MAP_ID="CjU1CMJPTAGofjOK3ICf1D"
MAP_ID="<YOUR_MAP_ID>"
curl -L \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${FELT_API_TOKEN}" \
"https://felt.com/api/v2/maps/${MAP_ID}/upload" \
-d '{"import_url":"https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.geojson", "name": "USGS Earthquakes"}'