Quickstart
Learn how to use the Features4 API to get spatial features for you locations:
To get your first feature (the number of bars within 500m Munich's city center) follow these steps:
- Sign up for a free Features4 account and follow the instructions you receive by email.
- Log into your dashboard. You will immediately see your private API key there.
- Copy and paste the code below to make your first request. Please replace
API_TEST_KEY
with your private API key.
- cURL
- Python
- R
curl https://api.features4.com/v1/number \
-u API_TEST_KEY: \
-H "Content-Type: application/json" \
-d '{"location": {"lat": 48.137, "lng": 11.576}, "element": "bar", "radius": 500}'
import requests
url = "https://api.features4.com/v1/number"
auth = ("API_TEST_KEY", "")
json = {
"location": {
"lat": 48.137,
"lng": 11.576
},
"element": "bar",
"radius": 500
}
r = requests.post(
url=url,
json=json,
auth=auth
)
r.json()
library(httr)
library(jsonlite)
url <- "https://api.features4.com/v1/number"
json <- '{
"location": {
"lat": 48.137,
"lng": 11.576
},
"element": "bar",
"radius": 500
}'
body <- fromJSON(
json,
simplifyDataFrame = FALSE
)
r <- POST(
url = url,
body = body,
encode = "json",
authenticate("API_TEST_KEY", "")
)
content(r)
Great, you already got your first feature:
{
"name": "number_bar_radius_500m",
"value": 24
}
You can see that there are 24 bars within 500m of the center of Munich.
Feel free to play around with other locations or elements.
Where to go from here?
- Check out other features you can access.
- Learn more in our user guide.
- Have a look at our API Reference.