Files
2021-10-21 01:29:24 +02:00

2.8 KiB

radio-rolnik API

Backend server for radio-rolnik

Resources

Website - https://github.com/Maathias/radio-rolnik/

Player - https://github.com/Maathias/radio-rolnik-player/

.env

Enviroment variables required

Ports and domains

HTTP_PORT=3010
HTTP_DOMAIN=radio.rolniknysa.pl
WS_PORT=3020

Spotify API

SPOTIFY_CLIENT_ID=<ID>
SPOTIFY_CLIENT_SECRET=<SECRET>

Facebok API

FB_APPID=<ID>
FB_SECRET=<SECRET>

Mongo DB

DB_HOST=<IP>
DB_PORT=<PORT>
DB_NAME=<DB>
DB_AUTH=<COLL>
DB_USER=<USER>
DB_PASS=<PASSWORD>

Redis Cache

CACHE_HOST=<IP>
CACHE_PORT=6379

Other

PLAYER_SECRET=<SECRET>
TOP_TIME_VALID=<monday,date,period>
TOP_TIME_VALUE=<VALUE?>

Routes

/track

Get track metadata


GET /track/:id get track

Get track by track id

RESPONSE

{
	id: String,
	title: String,
	artists: [String...],
	album: {
		name: String,
		art: String,
		year: Number,
	},
	duration: Number,	// milliseconds
	explicit: Boolean,
	banned: Boolean,
	votes: {
		up: Number,
		down: Number,
		rank: Number,
	},
}

POST /batch get tracks

Get multiple tracks by track id

BODY

{
	tids: [TrackID...]
}

RESPONSE

[
	TrackID...
]

Search for tracks


Get a list of Track ids

QUERY

{
	query: String
}

RESPONSE

{
	tids: [TrackID...],
	total: Number
}

/vote

Get and update vote values for tracks


GET /vote/:id get stats

Get stats of a track. When access token is present, also get user's vote value

HEADERS

{
	authorization: String
}

RESPONSE

{
	up: Number,
	down: Number,
	rank: Number,
	cast: String	// user's vote value for track. Only if authorized
}

POST /vote/batch get multiple stats

Get stats of multiple tracks. When access token is present, also get user's vote value per TrackID

HEADERS

{
	authorization: String
}

BODY

{
	tids: [TrackID...]
}

RESPONSE

[
	{
		up: Number,
		down: Number,
		rank: Number,
		cast: String	// user's vote value for track. Only if authorized
	}...
]

PATCH /vote/:tid change vote value

Changes user's vote for a track

HEADERS

{
	authorization: String
}

BODY

{
	value: String // 'up', 'down', '', 'report'
}

RESPONSE

true || false

/login

Login and fetch access token


GET /login/token get stats

Exchange Facebook login code for an access token

QUERY

{
	code: String
}

RESPONSE

<body>
	Logowanie...
</body>
<script>
	window.onload = function () {
		opener.exit('<ACCESS TOKEN>')
	}
</script>