The API service provides data via a REST interface to other RadioChecker services, e.g. the frontend.
Go
Since the set of available radio stations may be changed at any time (by adding/removing stations), a mature configuration solution for the service is required. Viper is such a library that allows the API service to load config information upon startup from a config.json file (watching/re-reading the config file during runtime is not necessary at the moment).
Summarized, the main purposes of the API service's config.json are:
- holding database information/credentials
- defining the available radio stations, their (REST) URI and database table
Example config.json:
{
"service": {
"name": "rc-api-svc",
"port": 8080,
"debug": true,
"access-control-allow-origin": "*"
},
"datastore": {
"host": "hostname",
"port": 3306,
"username": "username",
"password": "password",
"schema": "radiochecker"
},
"metrics": {
"enabled": true,
"provider": {
"awsAkid": "awsAkid",
"awsSecretKey": "awsSecretKey",
"awsRegion": "awsRegion"
}
}
}
The following endpoints are provided by the API service (ordered by importance):
/api/<config.stations.station.uri>/tracks/day/2016-10-01/top
Most-played tracks (ranked) for the specified day/api/<config.stations.station.uri>/tracks/day/2016-10-01/all
Complete list of all tracks played on the specified day/api/config/stations
List of available radio stations (those specified inconfig.stations
)/api/<config.stations.station.uri>/tracks/week/52/top
Most-played tracks (ranked) for the specified week/api/query/<track name>
Number of times the track was played on every radio station (how to specify the time period - day/week/year?)/api/<config.stations.station.uri>/tracks/week/52/all
Complete list of tracks played on the specified day (not really necessary)
AWS/Bare Metal