Overview
TheNasaApiService interface defines the network calls to NASA’s APOD API using Retrofit. It provides three main endpoints for fetching astronomy images and their metadata.
Base URL:
https://api.nasa.gov/planetary/apodInterface Definition
API Methods
Get Image of the Day
Retrieves the Astronomy Picture of the Day for a specific date or today’s date.NASA API key for authentication
Date in YYYY-MM-DD format. If not provided, returns today’s image
Single NASA image response with metadata including title, URL, date, and explanation
Get Images in Range
Fetches multiple astronomy images within a date range.NASA API key for authentication
Start date in YYYY-MM-DD format
End date in YYYY-MM-DD format. If not provided, uses current date
List of NASA image responses for each day in the specified range
Get Random Images
Retrrieves a specified number of random astronomy images.NASA API key for authentication
Number of random images to retrieve (typically 1-100)
List of random NASA image responses
Configuration
This service interface is configured with Retrofit in the dependency injection module:Response Handling
All methods aresuspend functions designed for Kotlin Coroutines. They should be called from a coroutine scope or another suspend function.
Related Components
- NASA Repository - Business logic layer using this service
- Data Models - Response and domain models