Usage

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: https://spindex-api.spinamp.xyz/graphiql

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 IApiListQueryParams 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 GraphQL playground to discover how the params should look.

To query for artists, see the Artists API Reference.

To query for tracks, see Tracks API Reference.

Run through the API Reference section for further query examples.

NFTs

To query for tracks from a collector's collection, see Collection 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 GraphQL playground 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)

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

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

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

Last updated