OpenFEMA API Documentation

As part of the OpenFEMA initiative, FEMA is providing read-only API based access to data sets (Entities). The data is exposed using a RESTful interface that uses query string parameters to manage the query. This document provides information on how to use the API including command examples. The examples shown are HTTP requests. Other methods such as CURL or accessing with a programming language can also be used. See the Developer Resources page for additional information.

A full list of Entities/endpoints supported by the API can be found at Data Sets.

Major and minor version features (including the addition or deprecation of datasets) can be found on the Changelog page.

Basics

The base path for the API endpoints is https://www.fema.gov/api/open.

To use the API, you will need to build a query string path in the following format:

[base path]/[version]/[entity]

  • version:  To support future enhancements we are using a versioning system for the APIs. To use the APIs you must indicate which version you need. The API version format is v1, v2, v3, etc.
  • entity: This corresponds to the name of the entity set you are requesting. The entity names can be found in the list of released data sets.

Example: https://www.fema.gov/api/open/v2/DisasterDeclarationsSummaries

alert - info

Query strings including the data set/endpoint name are case sensitive.

Query strings including the data set/endpoint name are case sensitive.

A successful response will include a both a metadata object (described below) and an array of entity objects (records). By default, only 1,000 records are returned. See the URI commands below for information on how to page through all found records. Working examples can be found on the Developer Resources page.

URI Quick Reference

CommandDescriptionDefault
$callbackTo specify the call back function name for retrieving data in JSONP format. 
$filenameTo specify the download filename. 
$filterTo filter or limit the results returned.All records up to $top returned
$formatTo specify the format of the returned data.JSON
$inlinecountOption to specify if a total entity count should be returned with the query.none (the count is not returned)
$metadataControls the presence of the metadata object in data set returns.on (metadata is returned)
$orderbySort the returned data. 
$selectTo specify the fields to return.All fields returned
$skipNumber of records to skip from the dataset.0
$topLimit the number of records returned.1,000

URI Commands Reference

A Uniform Resource Identifier (URI) is a string of characters identifying an abstract or physical resource on the web. This can be a URL to a website; it can also be identify a specific resource as well as a location. The following URI commands can be used to alter your request of OpenFEMA endpoint data – filtering the result, specifying a return type, or including additional metadata.

Search

Performs a search of the entity using specified query string parameters.

Query String Parameters

$callback

DEPRECATED. Allows you to specify the call back function name for retrieving data in JSONP format.

Example

$filename

Allows for the specification of a download filename. The data downloaded will be limited to fields specified using $select (all fields if none specified), will contain records limited by $filter, and will be sorted according to the $orderby parameter. Note, all of the $filter, $orderby, and $select parameters will work with $filename. The filename should not be surrounded by quotation marks even if the filename contains spaces. If no $format parameter is specified, JSON will be the result.

Example

$filter

Used to "filter" the results returned. The API provides a number of operations that can be used to build your request. The API provides as subset of the available options in the OData specification. Please note that dates should be represented in an ISO-8601 format.

alert - info

The query parser is very strict. Ensure your spacing, quoting, and capitalization are correct.

Spaces are required between logical operators.

Strings must be single quoted.

URL encoding (e.g., %20, %24, %27, etc.) may be used.

Any string containing a quote (e.g., bob's burgers) must have the quote doubled to have an effect (e.g., bob''s burgers).

Logical Operators:

OperatorDescriptionExample
eqEqual/DisasterDeclarationsSummaries?$filter=state eq 'VA'
neNot equal/DisasterDeclarationsSummaries?$filter=state ne 'VA'
gtGreater than/DisasterDeclarationsSummaries?$filter=declarationDate gt '1969-04-18T04:00:00.000z'
geGreater than or equal/DisasterDeclarationsSummaries?$filter=disasterNumber ge 4000
ltLess than/DisasterDeclarationsSummaries?$filter=declarationDate lt '2013-01-01'
leLess than or equal/DisasterDeclarationsSummaries?$filter=disasterNumber le 100
andLogical and/DisasterDeclarationsSummaries?$filter=declarationDate ge '2010-01-01T04:00:00.000z' and state eq 'VA'
orLogical or/DisasterDeclarationsSummaries?$filter=state eq 'VA' or state eq 'NY'
notLogical negation/DisasterDeclarationsSummaries?$filter=not substringof(declarationTitle,'OO')

Grouping Operators:

This represents logical operator grouping, not data aggregation.

OperatorDescriptionExample
( )Precedence grouping/DisasterDeclarationsSummaries?$filter=(state eq 'VA' and designatedArea eq 'Alleghany (County)') or disasterNumber eq 1570

String Functions:

To enable filtering on partial strings.

FunctionExample
bool substringof(string searchString, string searchInString)/DisasterDeclarationsSummaries?$filter=substringof('OO',declarationTitle)
bool endswith(string string, string suffixString)/DisasterDeclarationsSummaries?$filter=endswith(declarationTitle ,'ING')
bool startswith(string string, string prefixString)/DisasterDeclarationsSummaries?$filter=startswith(declarationTitle ,'FLO')

Special Functions:

To permit searching within objects, including geospatial operations.

unctionExample
containsOnly applies to searchable objects and arrays. Use the string functions for identifying fields that contain a string being sought.
Object example:
/IpawsArchivedAlerts?$filter=contains(infos/eventCode/value,%20%27ADR%27)&$top=1

Array examples (note the appropriate brackets and quotes):
/IpawsArchivedAlerts?$filter=contains(code, ["IPAWSv1.0"])&$top=1

/DataSets?$filter=contains(keyword,[%22HousingAssistance%22])
geo.intersectsPermits querying against a geospatial enabled dataset. The entity/field/object to be searched is passed along with a bounding polygon or a point. The syntax for the polygon must be in the format of the examples. Note, there is no space between "geography" and the geometry type. Replace the coordinates with your own polygon coordinates in WKT (Well Known Text) format. Examples:
https://www.fema.gov/api/open/v1/IpawsArchivedAlerts?$filter=geo.intersects(searchGeometry, geography'POLYGON((-171.791110603 71.3577635769,-66.96466 71.3577635769,-66.96466 18.91619,-171.791110603 18.91619,-171.791110603 71.3577635769))')&$top=100

/FemaRegions?$filter=geo.intersects(regionGeometry,geography%27POINT(-71.054649%2042.354478)%27)

$format

Controls the format of the returned data.

Supported values include:

  • json - Returns data in the JavaScript Object Notation format (default)
  • jsona - Returns data as a JavaScript Object Notation array format (no top-level object)
  • csv - Returns data in a Comma-Separated Value format * Metadata is not returned when using CSV format

Example

$inlinecount

Query options that controls if a total count of all entities matching the request MUST be returned as part of the result.  Note, if the $inlinecount parameter is not supplied, no count will be returned; it will appear as “0”.

alert - info

If retrieving large amounts of data or using complex $filter criteria through a "paging" technique, avoid specifying "allpages" in each call. This will result in faster queries.

Valid values are:

  • allpages - Returns the count
  • none - Does not return the count (default)

Example

$metadata

Controls the presence of the data set metadata object with a returned data set. Note, only applies if the format is JSON. If the format is CSV, no metadata is returned.

Supported values include:

  • on – Returns the metadata object for data returned in a JSON format (default)
  • off – Suppresses the metadata object for data returned in a JSON format

Example

$orderby

Allows for the sorting of data on the server. By providing a comma separated list of fields and a sort direction you can control the order that data is returned. Available sort directions are “asc” and “desc” for ascending or descending respectively. If no direction is provided, ascending is the default.

Example

$select

Used to specify which fields you would like returned in your dataset. Providing a comma separated list of case sensitive field names will return just those fields. If no value is specified, all of the fields are returned.

Example

$skip

Number of records to skip from the dataset. Used in conjunction with $top to allow you to page through the dataset. See the Developer Resources page for working examples of iterating through a result set to capture all the data matching the specified criteria. If no value is specified, $skip defaults to 0 and starts at the beginning of the results set.

Example

$top

Limits the number of records returned. Currently the default and maximum value is 1,000 records. See the Developer Resources page for working examples of iterating through a result set to capture all the data matching the specified criteria.

Example

Get By ID

Retrieves a specific record identified by its ID field (id).

Query string format is:

/api/open/[version]/[entity]/[_id]

  • version:  To support future enhancements we are using a versioning system for the APIs. To use the APIs you must indicate which version you need. The API version format is v1, v2, v3, etc.
  • entity: This corresponds to the name of the entity set you are requesting. The entity names can be found in the list of released data sets.
  • _id - This is a _id value of a previously identified record in an entity.

Example:

Query String Parameters

$callback

DEPRECATED. Allows you to specify the callback function name for retrieving data in JSONP format.

Example

$format

Controls the format of the returned data.

Supported values include

  • json - Returns data in the JavaScript Object Notation format (default)
  • csv - Returns data in a Comma-Separated Value format

Example

Metadata

A successful response will include a metadata object along with the array of entity objects. Most of the metadata corresponds to the URI commands and parameters specified above. The metadata object can be suppressed by using the $metadata parameter.

MetadataDescription
skipNumber of records skipped as specified by the $skip parameter. If the $skip parameter was not used, this value will be 0.
topMax number of records returned as specified by the $top parameter. If the $top parameter was not used, this value will be 1,000.
countCount of all possible records found matching any provided criteria. If the $inlinecount parameter was not used, or “none” was specified, this value will be 0. If the count returned is greater than 1,000, you will need to implement a paging strategy to return all the records that match the criteria specified.
filterFilter values applied as specified by the $filter parameter.
formatFormat of the data as specified by the $format parameter. If none specified, the format will default to JSON.
metadataIndicates if the metadata object suppression parameter has been specified.
orderbySort order for the data as specified by the $orderby parameter.
selectFields specified for return as specified by the $select parameter.
entitynameName of the entity or endpoint for which data was queried.
versionThe API endpoint version used to return the data.
urlThe fully composed URL used to return the data.
rundateThe date and time when the API call was executed.
DeprecationInformation(optional) An object containing the following 4 metadata items. Only appears when the dataset has been deprecated.
depDate(optional) Only appears when the data set has been deprecated. Indicates that the data set has been deprecated and will be removed by this date.
depApiMessage(optional) Only appears when the data set has been deprecated. Provides additional information about the deprecation of the data set.
depNewURL(optional) Only appears when the data set has been deprecated. Provides a link to an API endpoint that will supersede this dataset (if one exists).
depWebMessage (optional) Only appears when the data set has been deprecated. Provides additional information about the deprecation of the data set as it appears on the dataset webpage.

Special Dataset Fields

As a matter of policy, the OpenFEMA API does not enrich data from source systems. However, up to four fields are added by OpenFEMA either for internal purposes or to aid users in refreshing data. While the fields are briefly described in each dataset data dictionary, confusion about these fields has necessitated a more thorough description.

Datasets internally are classified as RELOAD or UPDATE.  RELOAD datasets follow a drop and reload process while UPDATE datasets add new records or update existing records that have changes. Existing records without a change are left unmodified in OpenFEMA. Reloads and updates occur according to the dataset refresh frequency/schedule. Those that are fully reloaded will not contain a hash or lastRefresh value.

id

This is not a unique identifier from the source system. It is an OpenFEMA generated unique identifier assigned to the record that does not persist between dataset refreshes. It can be used as a unique id within the immediate set of downloaded records, however, following the next data refresh there is no guarantee that the id will remain the same for the for the same record.

Why not use source system identifiers? Some datasets are aggregated, thereby negating the use of a source system id. Some combine data from multiple sources and no, one identifier can be used. Some datasets have no available unique identifier. Some source systems consider their identifiers as “sensitive” and are not made available to OpenFEMA.

If you require some kind of source system unique identifier, query the OpenFEMA DataSetFields metadata API and review the primaryKey element to identify those fields contributing to a records uniqueness. All the fields that have this flag set to true must be used to uniquely identify the record. If none of the dataset fields has the primaryKey value set, the record has no source system identifier available within this dataset. For example, the following query against the Disaster Declarations Summaries dataset will indicate that the declarationNumber in combination with the placeCode will uniquely identify a record: https://www.fema.gov/api/open/v1/DataSetFields?$filter=openFemaDataSet%20eq%20%27DisasterDeclarationsSummaries%27%20and%20datasetVersion%20eq%202%20and%20primaryKey%20eq%20%27true%27

lastRefresh

Date/time the record was last refreshed from the FEMA source system in the API data store and OpenFEMA detected a change in the data record. Note that this value does not indicate when the source system was updated, only when the OpenFEMA record was updated. It is possible to use this information to query recent data rather than performing a full dataset download. See OpenFEMA Guide to Working with Large Data Sets | FEMA.gov for a more thorough discussion of using this field to perform updates.

Whether you are refreshing the entire dataset or just trying to add/update changed records since the last update, your refresh interval should not be more frequent than the dataset refresh interval. Further, it would be prudent to check the dataset update status prior to executing your own refresh. There may be situations when the OpenFEMA data store is unable to refresh from the source data.

hash

An SHA1 hash of the field values of the record. If anything in a record changes—even capitalization, spacing, or punctuation—the SHA1 value will change. OpenFEMA uses this internally to identify changes to records to aid in updates. We have exposed this to the users because someone might find it useful. It should not be used as a record identifier.

lastDataSetRefresh in DataSets

Date/time the dataset was last refreshed from the FEMA source system in the API data. Note that this value does not indicate if the actual data has been modified, just that the OpenFEMA data store has been refreshed. It is possible to use this information to query only recently refreshed datasets rather than performing frequent blind downloads.


See Also

Last updated August 8, 2022