Declaring a retrofit REST endpoint with constant query value
In kotlin you can specify the default parameter:
interface YoutubeApi {
@GET ("oembed")
suspend fun metaData (
@Query (QUERY_VIDEO_URL) url: String,
@Query(QUERY_FORMAT) alwaysJson: String = "json"
): Response<YoutubeMetaData>
}
Just put it right in the relative URL:
public interface YoutubeApi {
@GET("oembed?format=json")
YoutubeMetaData metaData(@Query(QUERY_VIDEO_URL) String url);
}