  
npm install @mikaelchowdhury/spotifyapiA robust and type-safe npm package that allows developers to easily access the Spotify API. This package provides TypeScript typings for all Spotify API endpoints, making it easy to integrate Spotify's vast array of music data into your applications.
- Spotify API NPM Package
- Table of Contents
- Installation
- Usage
- API Endpoints
- Contributing
- License
You can install the package using npm or yarn:
``bash
npm install @mikaelchowdhury/spotifyapi
or
yarn add @mikaelchowdhury/spotifyapi
`
To use this package, you will need to have a Spotify Developer account and obtain your API credentials (Client ID and Client Secret). You can register your application and get your credentials here.
Basic Setup
`ts
import { SpotifyApiClient } from "@mikaelchowdhury/spotifyapi";
const client = new SpotifyApiClient({
clientKey: "your-client-id",
clientSecret: "your-client-secret",
});
// Fetch an access token
client.getAccessToken().then((token) => {
console.log("Access Token:", token);
});
`
This package provides typings and methods for all Spotify API endpoints. Below are some of the major endpoint categories:
- Albums
- Artists
- Audiobooks
- Categories
- Genres
- Playlists
- Tracks
- Users
- Search
Example: Get album by id
`ts`
client.album.getAlbum("album-id").then((album) => {
console.log(album.tracks.items[0].name); // Log name of first song in album
});
Example: Get an artist by their id
`ts`
client.artist.getArtist("artist id").then((artist) => {
console.log(artist.name);
});
Examples
Here are a few more examples to get you started:
Get User Profile
`ts`
client.user.getUserProfile("user-id").then((user) => {
console.log(user.display_name);
});
Get Top Tracks for an Artist
`ts``
client.artist.getArtistTopTracks("artist-id").then((tracks) => {
console.log(tracks[0].name); // Log artist's top track
});
Lmk if you wna contribute because there is probably a lot of mistakes haha
This project is licensed under the MIT License - see the LICENSE file for details.