Spotify Web API Wrapper
let client: Client = await Client.create_client({
client_id: "...",
client_secret: "...",
redirect_uri: "...",
});
let album = await client.albums.get_album("");
if (album.result) {
let details = {
name: album.result.name,
artists: album.result.artists.map((artist) => artist.name),
release_date: album.result.release_date,
};
}
let tracks = await client.tracks.get_several_tracks([""]);
if (tracks.result) {
console.log(tracks.result.tracks.map((track) => track.id));
console.log(tracks.result.tracks.map((track) => track.name));
console.log(tracks.result.tracks.map((track) => track.album.name));
}
This allows endpoints that require user permissions to be hit.
Currently all user authentication must be handled separately, there are no methods to help handle this.
let ClientInfo = z.object({
access_token: z.string().optional(),
token_type: z.string().optional(),
expires_in: z.number().optional(),
refresh_token: z.string().optional(),
scope: z.string().optional(),
});
let user_credentials: ClientInfo = {
access_token: "...",
refresh_token: "...",
};
client.add_user_info(user_credentials);
let user_profile = await client.users.get_current_users_profile();
if (user_profile.result) {
console.log(user_profile.result.id);
console.log(user_profile.result.display_name);
}
-
Implement request_user_authorization util
-
Improve error handling and return missing scopes
-
Clean up request util functions
-
Test util functions
-
Test client methods