Envirofacts Data Service API (V1)
Envirofacts provides a single point of access to U.S. EPA environmental data contained in U.S. EPA databases. Interested parties from State and local governments, EPA or other Federal agencies, or individuals can search for information about environmental activities that may affect air, water, and land anywhere in the United States.
Envirofacts makes it easy to find information using geographic information (i.e., by address, ZIP Code, city, county, water body, or other geographic designation) from all sources or within specific environmental subject areas (e.g., Waste, Water, Toxics, Air, Radiation, and Land). Experienced users can use more sophisticated capabilities, such as maps or customized reporting.
Envirofacts gathers and aggregates data based on activities that impact the environment from a wide variety of sources. These sources are ICIS-AIR, Biennial Reporting (BR), Superfund Enterprise Management System (SEMS), Enforcement and Compliance History Online (ECHO/IDEA), Cleanups in My Community, Next Generation Grants System (NGGS), RadNet database, Resource Conservation and Recovery Act Information (RCRAInfo), Safe Drinking Water Information System (SDWIS), Toxics Release Inventory (TRI), and UV Index.
Envirofacts also provides access to data registries, including the Facility Registry Service (FRS), the Locational Reference Tables database (LRT), and the Substance Registry Services (SRS).
To help users visualize this information and link it to geographical features and landmarks, Envirofacts uses geospatial datasets from a variety of sources, including EPA, the U.S. Census Bureau, and the U.S. Geological Survey (USGS).
With access to nearly 20 EPA data sources, a wide range of search and reporting tools, web widgets, geographic integration and analysis tools, and extensive online documentation of the source data sets, Envirofacts helps EPA meet its Open Government Initiative objectives. In providing as much access as possible to EPA data systems, Envirofacts provides a data service API for custom searches for many of these databases.
EF Data Service API (v1)
Envirofacts developed a RESTful data service API to all its internal data holdings. This functionality provides a user of Envirofacts with the ability to query any table using a URL. The default output is in XML, which can be utilized in other applications, as well as tools such as Microsoft Excel or Access. Output options of CSV and Excel can be requested in the URL. The entire Envirofacts database metadata is available online, so that all tables and columns within Envirofacts are documented. Having the table structures available in this manner makes most of Envirofacts data easily available through the service.
Strengths and Limitations of the Envirofacts RESTful Service
This is a simple to use, well-documented way to access multiple data sources without the need of user database connections. The resulting output can be easily used with desktop applications such as Excel or Access, or used in creating Web mashups.
The service currently limits requests to being completed in under 15 minutes. If more data is needed than this, users can page through the data, requesting the next set of records in the table.
Constructing a Search
To build a search, users create a URL with a specific set of parameters. This is done by creating a string using the following format:
- Table Name – At least one table name is required. Up to three table names can be entered. When inserting multiple tables into the URL, they must share an ID or common column, so that the tables can be joined or linked. To retrieve an accurate output, it is best to use tables that share an ID column. For example, within the tables that make up the TRI Facility Information, they each share an ID column known as tri_facility_id. This can be visually seen within the Envirofacts model pages for various subject areas like TRI Facility Information. Please refer to the Envirofacts database metadata to locate tables that can be joined via ID columns within the RESTful data service.
- Column Name – This is an optional entry. Enter a column name and value to limit the results. Multiple columns may be used within the URL to limit the data from a table or tables. The column name is not case sensitive.
- Operator – This is an optional entry. This parameter allows users to pass in an operator with the query. Default output is "=" and does not require an operator, but users can enter "<", ">", "!=", "BEGINNING", "CONTAINING", operators as well via the URL. The "BEGINNING" operator will return rows where the start of a column value is equal to the search value, while the "CONTAINING" will return rows where the search value is contained within the column value.
OPERATOR USAGE = The database will only return rows where the column value is equal to the search value. != The database will only return rows where the column value is NOT equal to the search value. < The database will only return rows where the column value is less than the search value. > The database will only return rows where the column value is greater than the search value. BEGINNING The database will only return rows where the start of column value is equal to the search value. A comparison is done, character by character, up to the last character entered for the search value. CONTAINING For Character fields only. The database will only return rows where the search value is contained within the column value. As an example if the search value entered is "ABC" and the column value is "CCABCDD" then the row will be accepted. Using the same search value of "ABC" if the column value was "AABBCC" then the row will be rejected. - Column Value – This is an optional entry (except when using #2 - Column Name). The column value is queried against the database without modification, so this value is case-sensitive. Use the program system model and queries within Envirofacts to double check the case for the value.
- Rows – This is an optional entry. Specify the rows to display by entering 'rows/<first_row>:<last_row>'. Results numbering starts at 0. So, to get the first five hundred rows, enter rows/0:499 If rows are not specified, the default is the first 10,000 rows.
- Output Format – This is an optional entry. The default output is in XML; however, output options of JSON, CSV or Excel can be requested in the URL. The output format is not case sensitive.
- Count -This is an optional entry and is shown as #7 in the above URL image. Count shows the total number of records that will be returned for this search once the Count option is removed. When Count is used, Excel, CSV, or XML cannot be specified. The column name is not case sensitive.
For example:
- https://data.epa.gov/efservice/tri_facility/state_abbr/VA/rows/499:504
returns result set records 500 to 505 from the tri_facility table where state_abbr = "VA". - https://data.epa.gov/efservice/envirofacts_site/fk_ref_state_code/FL
returns records from envirofacts_site table where the fk_ref_state_code = "FL". - https://data.epa.gov/efservice/t_safer_choice_and_design_for_the_environment/rows/0:19/JSON
returns the first 20 records from t_safer_choice_and_design_for_the_environment table as a JSON output. - https://data.epa.gov/efservice/tri_facility/state_abbr/HI/tri_reporting_form
returns results from the tri_facility and tri_reporting_form tables where state_abbr = "HI" in the tri_facility table. - https://data.epa.gov/efservice/tri_facility/state_abbr/VA/tri_reporting_form/tri_chem_info/EXCEL
returns results from the tri_facility, tri_reporting_form and tri_chem_info tables where state_abbr = "VA" in the tri_facility table in Excel format. - https://data.epa.gov/efservice/tri_facility/zip_code/BEGINNING/600/JSON
returns results from the tri_facility table where zip_code "Begins With" 600 in a JSON format. - https://data.epa.gov/efservice/tri_facility/state_abbr/VA/CSV
returns results from the tri_facility table where state_abbr = "VA" in a CSV format. - https://data.epa.gov/efservice/tri_facility/state_abbr/HI/county_name/Honolulu
returns results from the tri_facility table where state_abbr = "HI" and county_name = "Honolulu". - https://data.epa.gov/efservice/tri_facility/state_abbr/VA/tri_reporting_form/reporting_year/2010/EXCEL
returns results from the tri_facility table where state_abbr = "VA" and results from the tri_reporting_form table where reporting_year = 2010. - https://data.epa.gov/efservice/tri_facility/COUNT
returns results showing the total number of records in the tri_facility table. - https://data.epa.gov/efservice/tri_facility/state_abbr/HI/COUNT
returns results showing the total number of records in the tri_facility table where state_abbr = "HI".
Using Envirofacts Metadata to Construct a Search
The tables and columns within a program can be seen on the Envirofacts model page, which will model the relationships between tables within a program. Tables and columns searched on the Envirofacts Data Element Search can also be examined to see what tables and columns are available to query.
Working with the Output
The result set is XML that can be ported into an application or used as part of a Web mash-up. This is an example of what the output looks like with a return of two records from a search of the table tri_facility:
<?xml version="1.0" encoding="utf-8"?> <tri_facilityList> <tri_facility> <tri_facility_ID>00602BXTRF111CO</tri_facility_ID> <FACILITY_NAME>BAXTER HEALTHCARE CORP, FENWAL DIV</FACILITY_NAME> <STREET_ADDRESS>111 COLON ST</STREET_ADDRESS> <CITY_NAME>AGUADA</CITY_NAME> <COUNTY_NAME>AGUADA MUNICIPIO</COUNTY_NAME> <STATE_COUNTY_FIPS_CODE>72003</STATE_COUNTY_FIPS_CODE> <STATE_ABBR>PR</STATE_ABBR> <ZIP_CODE>00602</ZIP_CODE> <REGION>2</REGION> <FAC_CLOSED_IND>1</FAC_CLOSED_IND> <MAIL_NAME>BAXTER HEALTHCARE CORP, FENWAL DIV</MAIL_NAME> <MAIL_STREET_ADDRESS>111 COLON ST</MAIL_STREET_ADDRESS> <MAIL_CITY>AGUADA</MAIL_CITY> <MAIL_STATE_ABBR>PR</MAIL_STATE_ABBR> <MAIL_PROVINCE>None</MAIL_PROVINCE> <MAIL_COUNTRY>None</MAIL_COUNTRY> <MAIL_ZIP_CODE>00602</MAIL_ZIP_CODE> <ASGN_FEDERAL_IND>C</ASGN_FEDERAL_IND> <ASGN_AGENCY>None</ASGN_AGENCY> <FRS_ID>None</FRS_ID> <PARENT_CO_DB_NUM>080532250</PARENT_CO_DB_NUM> <PARENT_CO_NAME>BAXTER SALES CORP</PARENT_CO_NAME> <FAC_LATITUDE>182848</FAC_LATITUDE> <FAC_LONGITUDE>671106</FAC_LONGITUDE> <PREF_LATITUDE>18.480000</PREF_LATITUDE> <PREF_LONGITUDE>67.185000</PREF_LONGITUDE> <PREF_ACCURACY>11000.00</PREF_ACCURACY> <PREF_COLLECT_METH>UN</PREF_COLLECT_METH> <PREF_DESC_CATEGORY>UN</PREF_DESC_CATEGORY> <PREF_HORIZONTAL_DATUM>1</PREF_HORIZONTAL_DATUM> <PREF_SOURCE_SCALE>U</PREF_SOURCE_SCALE> <PREF_QA_CODE>0100</PREF_QA_CODE> <ASGN_PARTIAL_IND>0</ASGN_PARTIAL_IND> <ASGN_PUBLIC_CONTACT>MARIO LUCENA</ASGN_PUBLIC_CONTACT> <ASGN_PUBLIC_PHONE>8098383000</ASGN_PUBLIC_PHONE> <ASGN_PUBLIC_CONTACT_EMAIL>None</ASGN_PUBLIC_CONTACT_EMAIL> <BIA_CODE>None</BIA_CODE> <STANDARDIZED_PARENT_COMPANY>None</STANDARDIZED_PARENT_COMPANY> <ASGN_PUBLIC_PHONE_EXT>None</ASGN_PUBLIC_PHONE_EXT> <EPA_REGISTRY_ID>110002085207</EPA_REGISTRY_ID> <ASGN_TECHNICAL_CONTACT>None</ASGN_TECHNICAL_CONTACT> <ASGN_TECHNICAL_PHONE>None</ASGN_TECHNICAL_PHONE> <ASGN_TECHNICAL_PHONE_EXT>None</ASGN_TECHNICAL_PHONE_EXT> <MAIL>None</MAIL> <ASGN_TECHNICAL_CONTACT_EMAIL>None</ASGN_TECHNICAL_CONTACT_EMAIL> <FOREIGN_PARENT_CO_NAME>None</FOREIGN_PARENT_CO_NAME> <FOREIGN_PARENT_CO_DB_NUM>None</FOREIGN_PARENT_CO_DB_NUM> <STANDARDIZED_FOREIGN_PARENT_COMPANY>None</STANDARDIZED_FOREIGN_PARENT_COMPANY> </tri_facility> <tri_facility> <tri_facility_ID>00602BXTRHRD115</tri_facility_ID> <FACILITY_NAME>DADE DIAGNOSTICS OF PR INC</FACILITY_NAME> <STREET_ADDRESS>RD 115 KM 226</STREET_ADDRESS> <CITY_NAME>AGUADA</CITY_NAME> <COUNTY_NAME>AGUADA MUNICIPIO</COUNTY_NAME> <STATE_COUNTY_FIPS_CODE>72003</STATE_COUNTY_FIPS_CODE> <STATE_ABBR>PR</STATE_ABBR> <ZIP_CODE>00602</ZIP_CODE> <REGION>2</REGION> <FAC_CLOSED_IND>0</FAC_CLOSED_IND> <MAIL_NAME>DADE DIAGNOSTICS OF PR INC.</MAIL_NAME> <MAIL_STREET_ADDRESS>P.O. BOX 865</MAIL_STREET_ADDRESS> <MAIL_CITY>AGUADA</MAIL_CITY> <MAIL_STATE_ABBR>PR</MAIL_STATE_ABBR> <MAIL_PROVINCE>None</MAIL_PROVINCE> <MAIL_COUNTRY>None</MAIL_COUNTRY> <MAIL_ZIP_CODE>00602</MAIL_ZIP_CODE> <ASGN_FEDERAL_IND>C</ASGN_FEDERAL_IND> <ASGN_AGENCY>None</ASGN_AGENCY> <FRS_ID>None</FRS_ID> <PARENT_CO_DB_NUM>626532535</PARENT_CO_DB_NUM> <PARENT_CO_NAME>DADE INTERNATIONAL INC</PARENT_CO_NAME> <FAC_LATITUDE>182230</FAC_LATITUDE> <FAC_LONGITUDE>671230</FAC_LONGITUDE> <PREF_LATITUDE>18.391667</PREF_LATITUDE> <PREF_LONGITUDE>67.191667</PREF_LONGITUDE> <PREF_ACCURACY>11000.00</PREF_ACCURACY> <PREF_COLLECT_METH>UN</PREF_COLLECT_METH> <PREF_DESC_CATEGORY>UN</PREF_DESC_CATEGORY> <PREF_HORIZONTAL_DATUM>1</PREF_HORIZONTAL_DATUM> <PREF_SOURCE_SCALE>U</PREF_SOURCE_SCALE> <PREF_QA_CODE>0100</PREF_QA_CODE> <ASGN_PARTIAL_IND>0</ASGN_PARTIAL_IND> <ASGN_PUBLIC_CONTACT>ALEIDA HERNANDEZ</ASGN_PUBLIC_CONTACT> <ASGN_PUBLIC_PHONE>7878685500</ASGN_PUBLIC_PHONE> <ASGN_PUBLIC_CONTACT_EMAIL>None</ASGN_PUBLIC_CONTACT_EMAIL> <BIA_CODE>None</BIA_CODE> <STANDARDIZED_PARENT_COMPANY>None</STANDARDIZED_PARENT_COMPANY> <ASGN_PUBLIC_PHONE_EXT>None</ASGN_PUBLIC_PHONE_EXT> <EPA_REGISTRY_ID>110007807258</EPA_REGISTRY_ID> <ASGN_TECHNICAL_CONTACT>None</ASGN_TECHNICAL_CONTACT> <ASGN_TECHNICAL_PHONE>None</ASGN_TECHNICAL_PHONE> <ASGN_TECHNICAL_PHONE_EXT>None</ASGN_TECHNICAL_PHONE_EXT> <MAIL>None</MAIL> <ASGN_TECHNICAL_CONTACT_EMAIL>None</ASGN_TECHNICAL_CONTACT_EMAIL> <FOREIGN_PARENT_CO_NAME>None</FOREIGN_PARENT_CO_NAME> <FOREIGN_PARENT_CO_DB_NUM>None</FOREIGN_PARENT_CO_DB_NUM> <STANDARDIZED_FOREIGN_PARENT_COMPANY>None</STANDARDIZED_FOREIGN_PARENT_COMPANY> </tri_facility> </tri_facilityList>
After saving this as an XML file, it can be opened in Excel as an XML List, or in MS Access using the "Get External Data/Import" tool to create a table.
User Comments/Feedback Requests
For Envirofacts Data Service API usage questions or suggestions, please contact the Envirofacts team.