Overview
The remote API layer defines Retrofit interfaces that communicate with Mercado Libre’s REST API. These interfaces handle product search, product details, and OAuth authentication.MeliApi
Retrofit interface for interacting with the Mercado Libre product catalog.Interface Definition
data/remote/api/MeliApi.kt:11
Base URL: Configured via ApiConfig (typically https://api.mercadolibre.com/)
Endpoints
searchProducts
Searches for products based on query criteria.GET
Path: /products/search
Implementation: MeliApi.kt:20
string
default:"active"
Product status filter (e.g., “active”, “inactive”)
string
default:"MCO"
Geographic site identifier (MCO = Colombia)
string
required
Search query term provided by the user
getProductById
Retrieves detailed information for a specific product using its unique identifier.GET
Path: /products/search
Implementation: MeliApi.kt:34
string
default:"MCO"
Geographic site identifier (MCO = Colombia)
string
required
Unique product identifier (e.g., “MCO12345”)
Despite requesting a single product, the API returns a
SearchResponseDto with the product in the results array. The repository layer extracts the first result.AuthApi
Retrofit interface for OAuth 2.0 authentication flow with Mercado Libre.Interface Definition
data/remote/api/AuthApi.kt:14
Base URL: Configured via ApiConfig (typically https://api.mercadolibre.com/)
Endpoints
refreshToken
Requests a new access token using a refresh token (OAuth 2.0 refresh token grant).POST
Path: /oauth/token
Content-Type: application/x-www-form-urlencoded
Implementation: AuthApi.kt:24
OAuth grant type (always “refresh_token” for token refresh)
Application client identifier from Mercado Libre developer portal
Application client secret from Mercado Libre developer portal
Long-lived refresh token obtained during initial authentication
Response DTOs
SearchResponseDto
Root response object for product search and detail endpoints.data/remote/dto/SearchResponseDto.kt:14
Pagination metadata (total results, offset, limit)
Array of product objects matching the search criteria
ResultsDto
Individual product object in the search response.data/remote/dto/ResultsDto.kt:20
Unique product identifier (e.g., “MCO123456”)
Global catalog identifier
Product category/domain identifier (e.g., “LAPTOPS”)
Product title or name
Technical specifications (brand, model, color, etc.)
Brief product description
Product image gallery
ISO 8601 timestamp of last product update
AttributesDto
Technical attribute or specification of a product.data/remote/dto/AttributesDto.kt:15
Attribute identifier (e.g., “BRAND”, “COLOR”)
Human-readable attribute name (e.g., “Marca”, “Color”)
Human-readable attribute value (e.g., “Dell”, “Negro”)
AuthResponseDto
OAuth token response from the authentication server.data/remote/dto/AuthResponseDto.kt:15
Short-lived access token for API authorization
Token type (typically “Bearer”)
Token lifetime in seconds (typically 21600 = 6 hours)
Granted permissions (e.g., “offline_access read”)
Authenticated user’s Mercado Libre ID
Long-lived token for obtaining new access tokens
Authentication Flow
The APIs use OAuth 2.0 Bearer token authentication:Initial Token Acquisition
Obtain initial access and refresh tokens through Mercado Libre’s OAuth web flow (not implemented in app).
Error Handling
All API methods returnResponse<T> which is wrapped by the repository layer using safeApiCall. Common errors include:
Retrofit Configuration
APIs are provided through Hilt dependency injection:Related Documentation
Repositories
Repository implementations using these APIs
Mappers
DTO to domain model transformations