Overview
TheArticlesApiClient is a Retrofit interface that defines HTTP endpoints for fetching space flight news articles from the Space Flight News API v4.
Package: com.bsvillarraga.spaceflightnews.data.remote.articles
Base URL: https://api.spaceflightnewsapi.net/v4/
Interface
Endpoints
GET /v4/articles
Retrieves a paginated list of articles with optional filtering and sorting.Parameters
Optional search query to filter articles by title, summary, or content
Pagination offset - number of articles to skip. Used for loading more results.
Maximum number of articles to return per request. Default is 10.
Sort order for results. Use
-published_at for newest first (descending) or published_at for oldest first (ascending).Response
Retrofit Response containing a PaginationDto with:
count- Total number of articles availablenext- URL for the next page (null if last page)previous- URL for the previous pagearticles- Array of ArticleDto objects
Example Request
cURL Example
GET /v4/articles/
Retrieves detailed information for a specific article by its ID.Parameters
The unique identifier of the article to retrieve
Response
Retrofit Response containing an ArticleDto with complete article details including:
- Basic information (id, title, summary)
- Authors and their social media
- Publication metadata (publishedAt, updatedAt)
- Related launches and events
- Media (imageUrl, url to original article)
Example Request
cURL Example
Configuration
The API client is configured in the Hilt dependency injection module:Error Handling
The API client returns RetrofitResponse<T> objects. The repository layer wraps these in Resource<T> for consistent error handling:
Common Error Codes
- 404 - Article not found (when fetching by ID)
- 400 - Invalid query parameters
- 500 - Server error
- 503 - Service unavailable
Related
- ArticleRepository - Repository that uses this client
- Data Models - Response DTOs (PaginationDto, ArticleDto)
- Network Helper - Network connectivity checker