File size: 911 Bytes
f86a0c7
 
beb0a45
 
 
cdcdaac
 
f86a0c7
31e917d
cdcdaac
 
 
3025e93
beb0a45
 
cdcdaac
31e917d
f86a0c7
cdcdaac
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
import pandas as pd
import os


# Set your NREL API key here or use environment variables
NREL_API_KEY = "L0l8YMg3shJjkOS9kBAUCsbDglzJ0uYd8wMCNBdT"  # Replace with your actual API key

def get_hydrogen_data():
    """
    Fetch hydrogen station data from the NREL API.
    """
    url = f"https://developer.nrel.gov/api/alt-fuel-stations/v1.json?limit=10&api_key={NREL_API_KEY}"

    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an error for HTTP status codes 4xx or 5xx

        data = response.json()
        
        if "fuel_stations" in data and len(data["fuel_stations"]) > 0:
            return data["fuel_stations"]
        else:
            print("⚠️ No hydrogen data available from NREL API.")
            return None

    except requests.exceptions.RequestException as e:
        print(f"❌ API Request Failed: {e}")
        return None