spinamp-sdk
  • About
  • Installation
  • Usage
  • Reference
    • API Reference
      • Types
        • IConfig
        • IArtist
        • IArtistProfile
        • ITrack
        • ICollectionTrack
        • INft
        • ITrackNft
        • IMusicPlatformData
        • IPlaylist
        • IApiListQueryParams
        • IApiListQueryResponse
      • Tracks
      • Artists
      • Collection
      • NFTs
      • Platforms
      • Playlists
      • Utilities
Powered by GitBook
On this page

Usage

PreviousInstallationNextAPI Reference

Last updated 2 years ago

Usage

To use any function (or type) from the SDK just simply use named imports:

import {fetchTrackBySlug, ITrack} from '@spinamp/spinamp-sdk';

fetchTrackBySlug('loaded').then((track: ITrack | null) => {
    console.log(track);
});

The SDK pulls artist, track, nft and metadata from the Spindex API. You can explore this API using the GraphQL playground as well:

It's worth taking a few minutes to get familiar with this, as it help make using the SDK a lot more intuitive.

Querying for Artists , Tracks

Each list query accepts a which is used for pagination, sorting and filtering. The exact shape of the filter and orderBy params depends on the query - you can use the to discover how the params should look.

To query for artists, see the API Reference.

To query for tracks, see API Reference.

Run through the API Reference section for further query examples.

NFTs

To query for tracks from a collector's collection, see API Reference.

Queries specifically for NFTs and transfer activity are still in progress, but they're already available from the underlying API and you can explore the meanwhile to see how to query them.

Playlists

Playlists come from a separate API that is not part of the Spindexer. This is because they are not indexed on-chain - they're part of Spinamp's own stack. Playlists are created and controlled by users via their Ethereum address.

For querying playlists, see the Playlists API Reference.

APIs for updating playlists are coming soon - they'll require an ethereum signer from a connected user in order to sign their updates.

Custom Initialization (optional)

import {initialize} from '@spinamp/spinamp-sdk';

initialize({
    SPINDEX_NODE_URL: 'https://spindex-api.spinamp.xyz/graphql',
});

By default, spinamp-sdk works on predefined config values and it doesn't require initialization. However, it is possible to override specific properties of by calling initialize method before using sdk functions.

https://spindex-api.spinamp.xyz/graphiql
GraphQL playground
Artists
Tracks
Collection
GraphQL playground
IApiListQueryParams
IConfig