美国联邦政府开放数据源(api.data.gov / NLR)
数据官方

美国联邦政府开放数据源(api.data.gov / NLR)

Use when the user asks for US federal government open data via the api.data.gov gateway — e.g. NLR/NREL alternative-fuel stations (EV charging stations), solar/wind resource data, electricity utility rates, building energy data, and other US federal datasets behind developer.nlr.gov (keywords:美国政府数据、美国联邦、US federal、开放数据、充电站、加油站、新能源、太阳能、风能、电价、data.gov、NLR、NREL). Provides access to US federal agency APIs only. Do NOT use for non-US-government or non-federal data.

interstellar
interstellar
浏览411
使用1

Skill 文件

SKILL.md
name
data-gov-datasource
title
美国联邦政府开放数据源(api.data.gov / NLR)
description
Use when the user asks for US federal government open data via the api.data.gov gateway — e.g. NLR/NREL alternative-fuel stations (EV charging stations), solar/wind resource data, electricity utility rates, building energy data, and other US federal datasets behind developer.nlr.gov (keywords:美国政府数据、美国联邦、US federal、开放数据、充电站、加油站、新能源、太阳能、风能、电价、data.gov、NLR、NREL). Provides access to US federal agency APIs only. Do NOT use for non-US-government or non-federal data.
tools
curl
credentials
DATA_GOV_KEY
credential_help
DATA_GOV_KEY: "在 https://api.data.gov/signup/ 免费注册获取 API Key"

美国联邦政府开放数据源(api.data.gov / NLR)

通过 curl tool 调用 api.data.gov 网关下的美国联邦政府开放数据接口(实际请求 host 为 developer.nlr.gov,原 developer.nrel.gov 已于 2026-05-29 退役)。所有数据均来自美国联邦政府机构(如 DOE / NREL),仅覆盖美国境内数据。

鉴权

请求 developer.nlr.gov 时,在 URL 的 query string 里附带 api_key 参数:

api_key={{secrets.DATA_GOV_KEY}}

占位符由后端在 curl 运行期替换为真实 key,你无需也无法看到明文,按下面接口示例把它拼进 URL 即可。

通用约定

  • Base URL:https://developer.nlr.gov(原 NREL 开发者网关,2026-03 起迁移至 nlr.gov)
  • 所有接口都是 GET,参数通过 query string 传递,返回 JSON。
  • 每个请求都要在 query 里带上 api_key={{secrets.DATA_GOV_KEY}}
  • 数据范围:仅覆盖美国,用户询问其他国家的数据时,应明确告知此数据源不支持。
  • 限流:命中速率限制时返回 429,告知用户稍后再试,不要重试风暴。

常用接口


一、交通 / 替代燃料(Transportation)

1. 替代燃料站列表(按地点查询)

GET https://developer.nlr.gov/api/alt-fuel-stations/v1.json?api_key={{secrets.DATA_GOV_KEY}}&fuel_type=ELEC&state=CA&limit=10

关键参数:

  • fuel_typeELEC(电动)/ E85 / LPG / CNG / LNG / BD(生物柴油)/ HY(氢)/ RD(可再生柴油),可逗号分隔多选
  • state:两字母州代码
  • zip:邮编
  • city:城市名
  • limit:返回数量(默认全部)
  • statusE(开放)/ P(计划中)/ T(临时关闭)
  • ev_network:充电网络名,如 ChargePoint NetworkTesla
  • ev_connector_typeJ1772CHADEMOTESLACCS
  • ev_charging_level1(Level 1)/ 2(Level 2)/ dc_fast

关键返回字段:total_resultsfuel_stations[].station_namefuel_stations[].street_addressfuel_stations[].cityfuel_stations[].statefuel_stations[].zipfuel_stations[].fuel_type_codefuel_stations[].ev_networkfuel_stations[].ev_connector_typesfuel_stations[].latitudefuel_stations[].longitudefuel_stations[].access_days_time

2. 最近的替代燃料站(按距离排序)

GET https://developer.nlr.gov/api/alt-fuel-stations/v1/nearest.json?api_key={{secrets.DATA_GOV_KEY}}&fuel_type=ELEC&latitude=37.7749&longitude=-122.4194&radius=10&limit=5

额外参数:latitudelongitude(必填)、radius(英里,默认 5)。 返回字段同上,额外含 fuel_stations[].distance(距离,英里)。

3. 单个站点详情

GET https://developer.nlr.gov/api/alt-fuel-stations/v1/{id}.json?api_key={{secrets.DATA_GOV_KEY}}

id 查询单个站点完整信息,返回 alt_fuel_station 对象。

4. 充电网络列表

GET https://developer.nlr.gov/api/alt-fuel-stations/v1/electric-networks.json?api_key={{secrets.DATA_GOV_KEY}}

返回所有电动汽车充电网络名称列表,用于构建 ev_network 参数的合法值。

5. 数据最后更新时间

GET https://developer.nlr.gov/api/alt-fuel-stations/v1/last-updated.json?api_key={{secrets.DATA_GOV_KEY}}

返回 last_updatedalt_fuel_stations_count(站点总数)。

6. 替代燃料车辆列表

GET https://developer.nlr.gov/api/vehicles/v1/light-duty-automobiles.json?api_key={{secrets.DATA_GOV_KEY}}&fuel_type=ELEC&year=2025&limit=10

关键参数:fuel_typeyear(车型年份)、manufacturerlimit。 关键返回字段:result[].manufacturerresult[].modelresult[].yearresult[].fuel_typeresult[].engine_sizeresult[].electric_range

7. 交通法律法规与激励政策

GET https://developer.nlr.gov/api/transportation-incentives-laws/v1.json?api_key={{secrets.DATA_GOV_KEY}}&jurisdiction=US&technology=ELEC&limit=10

关键参数:

  • jurisdictionUS(联邦)或两字母州代码(如 CANYDC
  • technologyELECHEVPHEVHYNGETHLPG
  • keyword:关键词搜索
  • ⚠️ type 参数已废弃(2026),不要传此参数,否则返回 422

关键返回字段:result[].titleresult[].stateresult[].types[].title(分类名,如 "Laws and Regulations" / "Incentive")、result[].text(HTML 正文)、result[].plaintext(纯文本正文)、result[].enacted_dateresult[].categories[]


二、太阳能(Solar)

8. 太阳能资源数据(按经纬度)

GET https://developer.nlr.gov/api/solar/solar_resource/v1.json?api_key={{secrets.DATA_GOV_KEY}}&lat=40&lon=-105

关键返回字段:outputs.avg_dni(直接法向辐照 kWh/m²/day)、outputs.avg_ghi(水平面总辐照)、outputs.avg_lat_tilt(最佳倾角辐照)、outputs.monthly(各月数据)。

9. PVWatts V8(光伏发电量估算)

GET https://developer.nlr.gov/api/pvwatts/v8.json?api_key={{secrets.DATA_GOV_KEY}}&system_capacity=4&module_type=0&losses=14&array_type=1&tilt=20&azimuth=180&lat=40&lon=-105

必填参数:

  • system_capacity:系统容量(kW,0.05–500000)
  • module_type0(标准)/ 1(高效)/ 2(薄膜)
  • losses:系统损耗(%,-5 到 99)
  • array_type0(固定开放式)/ 1(固定屋顶式)/ 2(单轴跟踪)/ 3(单轴回溯)/ 4(双轴跟踪)
  • tilt:倾角(度)
  • azimuth:方位角(度,180=正南)
  • lat / lon:经纬度

可选参数:address(可替代 lat/lon)、dc_ac_ratioinv_eff(逆变器效率)、gcr(地面覆盖率)、bifaciality(双面率)。

关键返回字段:outputs.ac_annual(年交流发电量 kWh)、outputs.solrad_annual(年日照量 kWh/m²/day)、outputs.capacity_factor(容量因子)、outputs.ac_monthly[](月度发电量)、outputs.solrad_monthly[]

10. 太阳能数据集查询

GET https://developer.nlr.gov/api/solar/data-query/v2.json?api_key={{secrets.DATA_GOV_KEY}}&lat=40&lon=-105

返回指定位置可用的太阳能数据集(如 TMY、NSRDB 等),可用于判断后续 API 调用使用哪个数据源。


三、电力(Electricity)

11. 电力公司费率(按经纬度)

GET https://developer.nlr.gov/api/utility_rates/v3.json?api_key={{secrets.DATA_GOV_KEY}}&lat=37.7749&lon=-122.4194

关键返回字段:outputs.utility_name(电力公司名称)、outputs.utility_info[].utility_nameoutputs.residential(居民电价 $/kWh)、outputs.commercial(商业电价)、outputs.industrial(工业电价)。

12. 电力公司费率(按地址)

GET https://developer.nlr.gov/api/utility_rates/v3.json?api_key={{secrets.DATA_GOV_KEY}}&address=1600+Pennsylvania+Ave+NW,+Washington,+DC

参数与经纬度查询相同,可用 address 替代 lat/lon


四、气候与建筑

13. 建筑物能耗数据(DOE 标准参考建筑)

GET https://developer.nlr.gov/api/building-case-studies/v1.json?api_key={{secrets.DATA_GOV_KEY}}&state=CA&building_type=Office&limit=10

关键参数:statebuilding_type(Office / Retail / Hotel / Hospital 等)、limit。 关键返回字段:result[].project_nameresult[].stateresult[].building_typeresult[].energy_savings_percent


五、风能(Wind)

14. 风能数据集查询

GET https://developer.nlr.gov/api/wind/wind-toolkit/v2/wind-data.json?api_key={{secrets.DATA_GOV_KEY}}&lat=40&lon=-105&year=2014&interval=60&attributes=wind_speed,wind_direction,power

关键参数:latlonyear(2007–2014)、interval(分钟:5/15/30/60)、attributes(需要的数据字段)。 返回 CSV 或 JSON 格式的时序风能数据。


调用示例

示例 1:查「加州有多少电动充电站」

curl(url = "https://developer.nlr.gov/api/alt-fuel-stations/v1.json?api_key={{secrets.DATA_GOV_KEY}}&fuel_type=ELEC&state=CA&limit=1")

返回 JSON 后读取 total_results 字段回答用户。

示例 2:查「旧金山附近最近的 5 个特斯拉超充站」

curl(url = "https://developer.nlr.gov/api/alt-fuel-stations/v1/nearest.json?api_key={{secrets.DATA_GOV_KEY}}&fuel_type=ELEC&latitude=37.7749&longitude=-122.4194&ev_network=Tesla&ev_charging_level=dc_fast&limit=5")

示例 3:查「在洛杉矶安装 4kW 屋顶太阳能板一年能发多少电」

curl(url = "https://developer.nlr.gov/api/pvwatts/v8.json?api_key={{secrets.DATA_GOV_KEY}}&system_capacity=4&module_type=0&losses=14&array_type=1&tilt=20&azimuth=180&lat=34.0522&lon=-118.2437")

读取 outputs.ac_annual 即年发电量(kWh)。

示例 4:查「纽约的居民电价是多少」

curl(url = "https://developer.nlr.gov/api/utility_rates/v3.json?api_key={{secrets.DATA_GOV_KEY}}&address=New+York,+NY")

读取 outputs.residential 即居民电价($/kWh)。

示例 5:查「联邦有哪些电动车相关政策」

curl(url = "https://developer.nlr.gov/api/transportation-incentives-laws/v1.json?api_key={{secrets.DATA_GOV_KEY}}&jurisdiction=US&technology=ELEC&limit=5")

读取 result[].titleresult[].plaintext 展示政策概要,通过 result[].types[].title 区分是法律法规还是激励政策。

错误处理

  • 403 且含 API_KEY:平台 key 未配置或无效,提示用户「该数据源平台凭证未就绪」,不要重试。
  • 429:触发限流,告知用户稍后再试。
  • 404:接口路径或参数有误,核对 URL。
  • 其他非 2xx:把 status 与响应体摘要反馈给用户。
Ln 1, Col 1MarkdownSpaces: 2
No errors