import type { OilPriceAPI } from "../client.js"; /** * Diesel price data for a specific state or region */ export interface DieselPrice { /** State code (e.g., "CA", "TX") */ state: string; /** Average diesel price in USD per gallon */ price: number; /** Currency code (always "USD" for diesel) */ currency: string; /** Unit of measurement (always "gallon") */ unit: string; /** Granularity level (e.g., "state", "national") */ granularity: string; /** Data source (e.g., "EIA") */ source: string; /** ISO 8601 timestamp of last update */ updated_at: string; /** Whether the response was served from cache */ cached?: boolean; } /** * Diesel station location and pricing data */ export interface DieselStation { /** Station name */ name: string; /** Full street address */ address: string; /** Geographic coordinates */ location: { /** Latitude */ lat: number; /** Longitude */ lng: number; }; /** Diesel price at this station (USD per gallon) */ diesel_price: number; /** Formatted price string (e.g., "$3.89") */ formatted_price: string; /** Currency code (always "USD") */ currency: string; /** Unit (always "gallon") */ unit: string; /** Price difference from regional average (negative = cheaper) */ price_delta?: number; /** Human-readable comparison (e.g., "$0.15 cheaper than regional average") */ price_vs_average?: string; /** Available fuel types at this station */ fuel_types?: string[]; /** ISO 8601 timestamp of last price update */ last_updated?: string; } /** * Response from diesel stations endpoint */ export interface DieselStationsResponse { /** Regional average for comparison */ regional_average: { price: number; currency: string; unit: string; region: string; granularity: string; source: string; }; /** List of nearby stations */ stations: DieselStation[]; /** Search area details */ search_area: { center: { lat: number; lng: number; }; radius_meters: number; radius_miles: number; }; /** Metadata about the response */ metadata: { total_stations: number; source: string; cached: boolean; api_cost: number; timestamp: string; cache_age_hours?: number; }; } /** * Options for getting diesel stations */ export interface GetDieselStationsOptions { /** Latitude */ lat: number; /** Longitude */ lng: number; /** Search radius in meters (default: 8047 = 5 miles) */ radius?: number; } /** * Diesel Prices resource * * Provides access to state-level diesel averages and station-level pricing. * * @example * ```typescript * // Get state average * const caPrice = await client.diesel.getPrice('CA'); * console.log(`California diesel: $${caPrice.price}/gal`); * * // Get nearby stations * const stations = await client.diesel.getStations({ * lat: 37.7749, * lng: -122.4194, * radius: 8047 // 5 miles in meters * }); * * console.log(`Found ${stations.stations.length} stations`); * stations.stations.forEach(station => { * console.log(`${station.name}: ${station.formatted_price}`); * }); * ``` */ export declare class DieselResource { private client; constructor(client: OilPriceAPI); /** * Get average diesel price for a US state * * Returns the available EIA state-level average diesel price and its source * timestamp. Current access is determined by the API. * * @param state - Two-letter US state code (e.g., "CA", "TX", "NY") * @returns State average diesel price * * @throws {NotFoundError} If state code is invalid * @throws {AuthenticationError} If API key is invalid * @throws {RateLimitError} If rate limit exceeded * * @example * ```typescript * // Get California diesel price * const caPrice = await client.diesel.getPrice('CA'); * console.log(`CA diesel: $${caPrice.price}/gal`); * console.log(`Source: ${caPrice.source}`); * console.log(`Updated: ${caPrice.updated_at}`); * ``` */ getPrice(state: string): Promise; /** * Get nearby diesel stations with current pricing * * Returns station-level diesel prices within specified radius using Google Maps data. * * Station-level access and allowances depend on the account's current * entitlement. Review https://www.oilpriceapi.com/pricing and the API's * response metadata instead of relying on an SDK-bundled allowance. * * **Caching:** Results are cached for 24 hours to minimize costs. * * @param options - Search parameters (lat, lng, radius) * @returns Nearby stations with prices and regional average * * @throws {AuthenticationError} If API key is invalid * @throws {RateLimitError} If monthly station query limit exceeded * @throws {Error} If coordinates are invalid * * @example * ```typescript * // Get stations near San Francisco * const result = await client.diesel.getStations({ * lat: 37.7749, * lng: -122.4194, * radius: 8047 // 5 miles * }); * * console.log(`Regional avg: $${result.regional_average.price}/gal`); * console.log(`Found ${result.stations.length} stations`); * * // Find cheapest station * const cheapest = result.stations.reduce((min, s) => * s.diesel_price < min.diesel_price ? s : min * ); * console.log(`Cheapest: ${cheapest.name} at ${cheapest.formatted_price}`); * ``` */ getStations(options: GetDieselStationsOptions): Promise; }