UNPKG

rocketdata

Version:

**Rocketdata** is a modern, lightweight Node.js wrapper for [NASA's public APIs](). Easily fetch data from the Astronomy Picture of the Day (APOD), Mars Rover imagery, and more — all with clean, promise-based functions.

160 lines (159 loc) 5.96 kB
/** * @interface CameraInfo * @version 2.1.2 * @description CameraInfo is the format for a camera. * @property {string} abbreviation - The abbreviation of the camera. * @property {string} fullName - The full name of the camera. * @property {Array<string>} supportedRovers - The rovers that support the camera. */ export interface CameraInfo { abbreviation: CameraAbbreviation; fullName: string; supportedRovers: Rover[]; } export type CameraAbbreviation = 'FHAZ' | 'RHAZ' | 'MAST' | 'CHEMCAM' | 'MAHLI' | 'MARDI' | 'NAVCAM' | 'PANCAM' | 'MINITES'; export type Rover = 'curiosity' | 'opportunity' | 'spirit'; export declare const CAMERAS: CameraInfo[]; interface RoverQueryParams { sol?: number; earth_date?: string; camera?: CameraAbbreviation; page?: number; api_key: string; } /** * @interface SolQueryParams * @version 2.2.2 * @description Parameters to fetch Mars rover photos by sol (Martian day). * @property {number} sol - The Martian sol (e.g., 1000). * @property {CameraAbbreviation} [camera] - Abbreviation of the camera. * @property {number} [page] - Optional, defaults to 1. 25 items per page returned. * @property {string} api_key - NASA API key. */ export type SolQueryParams = Pick<RoverQueryParams, 'sol' | 'camera' | 'page' | 'api_key'>; /** * @interface EarthDateQueryParams * @version 2.2.2 * @description Parameters to fetch Mars rover photos by earth date. * @property {string} earth_date - The earth date of the rover (e.g., '2023-06-25'). * @property {CameraAbbreviation} [camera] - Abbreviation of the camera. * @property {number} [page] -Optional, defaults to 1. 25 items per page returned. * @property {string} api_key - NASA API key. */ export type EarthDateQueryParams = Pick<RoverQueryParams, 'earth_date' | 'camera' | 'page' | 'api_key'>; /** * @interface RoverInfo * @version 2.1.2 * @description RoverInfo is the format for a rover. * @property {number} id - The id of the rover. * @property {Rover} name - The name of the rover. * @property {string} landing_date - The landing date of the rover. * @property {string} launch_date - The launch date of the rover. * @property {string} status - The status of the rover. */ export interface RoverInfo { id: number; name: Rover; landing_date: string; launch_date: string; status: 'active' | 'complete'; } /** * @interface MarsPhoto * @version 2.1.2 * @description MarsPhoto is the format for a Mars rover photo. * @property {number} id - The id of the Mars rover photo. * @property {number} sol - The mars day. * @property {CameraInfo} camera - The camera of the rover. * @property {string} img_src - The image source of the Mars rover photo. * @property {string} earth_date - The earth date of the Mars rover photo. * @property {RoverInfo} rover - The rover of the Mars rover photo. */ export interface MarsPhoto { id: number; sol: number; camera: CameraInfo; img_src: string; earth_date: string; rover: RoverInfo; } /** * @interface MarsPhotoResponse * @version 2.1.2 * @description MarsPhotoResponse is the response object for querying by Martian sol. * @property {Array<MarsPhoto>} photos - The list of Mars rover photos. */ export interface MarsPhotoResponse { photos: MarsPhoto[]; } /** * @interface RoverManifest * @description The rover manifest object type returned from getMissionManifest. * @version 2.3.5 * @property {string} name - The name of the rover. * @property {string} landing_date - The landing date of the rover. * @property {string} launch_date - The launch date of the rover. * @property {string} status - The status of the rover. * @property {string} max_sol - The most recent Martian sol from which photos exist. * @property {string} max_date - The most recent Earth date from which photos exist. * @property {string} total_photos - The total number of photos taken by the rover. */ export interface RoverManifest { name: string; landing_date: string; launch_date: string; status: string; max_sol: number; max_date: string; total_photos: number; } /** * @function getMarsRoverPhotosByMartianSol * @description Get Mars rover photos by Martian sol. * @async * @version 2.1.2 * @param {SolQueryParams} params - The request parameters. * @returns {Promise<MarsPhotoResponse>} * @fulfill {MarsPhotoResponse} - The Mars rover photos. * @reject {Error} - The error object. * @example * const result = await getMarsRoverPhotosByMartianSol({ * sol: 1000, * camera: 'FHAZ', * page: 1, * api_key: 'DEMO_KEY', * }); */ export declare const getMarsRoverPhotosByMartianSol: (params: SolQueryParams) => Promise<MarsPhotoResponse>; /** * @function getMarsRoverPhotosByEarthDate * @description Get Mars rover photos by earth date. * @async * @version 2.2.2 * @param {EarthDateQueryParams} params - The request parameters. * @returns {Promise<MarsPhotoResponse>} * @fulfill {MarsPhotoResponse} - The Mars rover photos. * @reject {Error} - The error object. * @example * const result = await getMarsRoverPhotosByEarthDate({ * earth_date: '2023-06-25', * camera: 'FHAZ', * page: 1, * api_key: 'DEMO_KEY', * }); */ export declare const getMarsRoverPhotosByEarthDate: (params: EarthDateQueryParams) => Promise<MarsPhotoResponse>; /** * @function getMissionManifest * @description A mission manifest is available for each Rover. This manifest will list details of the Rover's mission to help narrow down photo queries to the API. * @async * @version 2.3.5 * @param {Rover} rover - The name of the rover. Curiosity, Opportunity or Spirit. * @returns {Promise<RoverManifest>} * @fulfill {RoverManifest} - The rover manifest. * @reject {Error} - The error object. * @example * const result = await getMissionManifest('curiosity', 'DEMO_KEY); */ export declare const getRoverMissionManifest: (rover: Rover, api_key: string) => Promise<RoverManifest>; export {};