Note: It is currently not boating season. We do not display flags when it is not boating season. We hope to see you again in the near future!

Public Flagging API

Pursuant to CRWA's mission to provide open access to ecological data to the greater Boston community and the world, the CRWA allows open access to its Public Flagging API, which provides JSON versions of the CRWA's data utilized in modeling, the CRWA's model outputs, and relevant metadata.

The API is built on simple REST principles; user of the Public Flagging API can utilize GET requests to retrieve the data. Additional APIs may be added to the project as development progresses. This is a volunteer driven project and we appreciate developers' and researchers' input on what would be most useful.

Click here to view our API and its documentation with Swagger.

Available Endpoints




Sample Code For API Calls

Below we provide sample code so that you can download the data directly from the Public Flagging API.

Python Code Examples

Note: Requires Pandas (pip install pandas) and Requests (pip install requests).

Predictive Model Outputs API

import pandas as pd
import requests

# Get data and parse returned JSON
url = "https://crwa-flagging.herokuapp.com/api/v1/model"
res = requests.get(url).json()
records = [
    {
        "reach": reach["reach"],
        **row
    }
    for reach in res["model_outputs"]
    for row in reach["predictions"]
]

# Turn into Pandas DataFrame
df = pd.DataFrame(records)
print(df.head())

Boathouses API

import pandas as pd
import requests

# Get data and parse returned JSON
url = "https://crwa-flagging.herokuapp.com/api/v1/boathouses"
res = requests.get(url).json()
records = res["boathouses"]

# Turn into Pandas DataFrame
df = pd.DataFrame(records)
print(df.head())

R (Tidyverse) Code Examples

Note: Requires Tidyverse (install.packages("tidyverse")) and jsonlite (install.packages("jsonlite")).

Predictive Model Outputs API

library(jsonlite)
library(tidyverse)

url <- "https://crwa-flagging.herokuapp.com/api/v1/model"
res <- fromJSON(url) %>% as_tibble
df <- res$model_outputs %>% unnest(predictions)
df

Boathouses API

library(jsonlite)
library(tidyverse)

url <- "https://crwa-flagging.herokuapp.com/api/v1/boathouses"
df <- fromJSON(url) %>% as_tibble
df