Something went wrong. Try again.
A decentralized music tracking and discovery platform built on AT Protocol 🎵 forked from rocksky.app/rocksky
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113import axios from "axios";import { API_URL } from "../consts";
export const getSongByUri = async (uri: string) => { const response = await axios.get(`${API_URL}/users/${uri}`); return { id: response.data?.id, title: response.data?.title, artist: response.data?.artist, albumArtist: response.data?.album_artist, album: response.data?.album, cover: response.data?.album_art, tags: [], artistUri: response.data?.artist_uri, albumUri: response.data?.album_uri, listeners: response.data?.listeners || 1, scrobbles: response.data?.scrobbles || 1, lyrics: response.data?.lyrics, spotifyLink: response.data?.spotify_link, composer: response.data?.composer, uri: response.data?.uri, };};
export const getArtistTracks = async ( uri: string, limit = 10,): Promise< { id: string; title: string; artist: string; album_artist: string; album_art: string; uri: string; play_count: number; album_uri?: string; artist_uri?: string; }[]> => { const response = await axios.get( `${API_URL}/users/${uri}/tracks?size=${limit}`, ); return response.data;};
export const getArtistAlbums = async ( uri: string, limit = 10,): Promise< { id: string; title: string; artist: string; album_art: string; artist_uri: string; uri: string; }[]> => { const response = await axios.get( `${API_URL}/users/${uri}/albums?size=${limit}`, ); return response.data;};
export const getArtists = async (did: string, offset = 0, limit = 30) => { const response = await axios.get( `${API_URL}/users/${did}/artists?size=${limit}&offset=${offset}`, ); // eslint-disable-next-line @typescript-eslint/no-explicit-any return response.data.map((x: any) => ({ ...x, scrobbles: x.play_count }));};
export const getAlbums = async (did: string, offset = 0, limit = 12) => { const response = await axios.get( `${API_URL}/users/${did}/albums?size=${limit}&offset=${offset}`, ); // eslint-disable-next-line @typescript-eslint/no-explicit-any return response.data.map((x: any) => ({ ...x, scrobbles: x.play_count, }));};
export const getTracks = async (did: string, offset = 0, limit = 20) => { const response = await axios.get( `${API_URL}/users/${did}/tracks?size=${limit}&offset=${offset}`, ); // eslint-disable-next-line @typescript-eslint/no-explicit-any return response.data.map((x: any) => ({ ...x, scrobbles: x.play_count }));};
export const getLovedTracks = async (did: string, offset = 0, limit = 20) => { const response = await axios.get( `${API_URL}/users/${did}/likes?size=${limit}&offset=${offset}`, ); return response.data;};
export const getAlbum = async (did: string, rkey: string) => { const response = await axios.get( `${API_URL}/users/${did}/app.rocksky.album/${rkey}`, ); return response.data;};
export const getArtist = async (did: string, rkey: string) => { const response = await axios.get( `${API_URL}/users/${did}/app.rocksky.artist/${rkey}`, ); return response.data;};