Recreation Information Database
Open DataExploring the Recreation Information Database (RIDB) API
The Recreation Information Database (RIDB) API is a public API that provides information on recreational facilities and activities in public lands across the United States. This API is an excellent resource for developers who want to build innovative applications that help people find and explore public lands. In this blog post, we will be exploring the RIDB API and provide example code snippets in JavaScript.
Getting Started
Before we dive into the specifics of the RIDB API, we need to obtain an API key that we will use to authenticate our requests. To get an API key, you will need to create an account on recreation.gov and then request an API key from the RIDB.
Once you have obtained your API key, you can start exploring the RIDB Endpoints. Let's begin by looking at the search
function, which allows us to search for facilities in the database.
fetch('https://ridb.recreation.gov/api/v1/facilities', {
method: 'GET',
headers: {
'accept': 'application/json',
'apikey': 'YOUR_API_KEY'
},
qs: {
state: 'CO',
activity: 'Hiking'
}
}).then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
In this code snippet, we are using the fetch
function to make a GET request to the facilities
endpoint of the RIDB API. We are passing our API key in the headers and setting the query parameters to search for hiking facilities in Colorado.
The response from the API will return a JSON object that contains an array of matching facilities. You can parse through this data to display information about the facilities on your application.
Additional Endpoints
In addition to the facilities
endpoint, the RIDB API provides several other endpoints that you can use to obtain information on campsites, tours, and permits. Here are some example code snippets for each of these endpoints:
Campgrounds
fetch('https://ridb.recreation.gov/api/v1/campgrounds', {
method: 'GET',
headers: {
'accept': 'application/json',
'apikey': 'YOUR_API_KEY'
},
qs: {
state: 'CA',
maxPeople: 6
}
}).then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Tours
fetch('https://ridb.recreation.gov/api/v1/tours', {
method: 'GET',
headers: {
'accept': 'application/json',
'apikey': 'YOUR_API_KEY'
},
qs: {
state: 'NY',
keywords: 'scenic'
}
}).then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Permits
fetch('https://ridb.recreation.gov/api/v1/permits', {
method: 'GET',
headers: {
'accept': 'application/json',
'apikey': 'YOUR_API_KEY'
},
qs: {
latitude: '41.8781',
longitude: '-87.6298'
}
}).then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Conclusion
The Recreation Information Database (RIDB) API provides an excellent resource for developers to build innovative applications around recreational facilities and activities in public lands across the United States. In this blog post, we explored the RIDB API and provided example code in JavaScript for the search
, campgrounds
, tours
, and permits
endpoints.
With the RIDB API, developers can build apps that help people plan and explore the great outdoors. Let your imagination run wild and see what kind of applications you can build with the RIDB API!