šŸš€ Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more →
Sign In

@audius/sdk

Package Overview
Dependencies
Maintainers
12
Versions
349
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@audius/sdk

Audius SDK

Source
npmnpm
Version
2.0.3-beta.52
Version published
Weekly downloads
386
-41.52%
Maintainers
12
Weekly downloads
Ā 
Created
Source

Audius JavaScript SDK

Overview

The Audius JavaScript (TypeScript) SDK allows you to easily build on and interact with the Audius protocol.

  • āœļø Log In with Audius
  • šŸŽµ Fetch and stream tracks
  • šŸ” Search and display users, tracks, and playlists

šŸ‘·ā€ā™€ļø We're actively working on building out more SDK features and functionality - stay tuned!

Installation

  • Node.js
  • HTML + JS

Node.js

1. Install the SDK package using your preferred JS package manager

In your terminal, run:

npm install web3 @audius/sdk

2. Initialize the SDK

import { sdk } from '@audius/sdk'

const audiusSdk = sdk({ appName: 'Name of your app goes here' })

3. Make your first API call using the SDK!

const track = await audiusSdk.tracks.getTrack({ trackId: 'D7KyD' })
console.log(track, 'Track fetched!')

Full example

import Web3 from 'web3'
import { sdk } from '@audius/sdk'

// If running in a browser, set window.Web3
window.Web3 = Web3

const audiusSdk = sdk({ appName: 'My Example App' })

const track = await audiusSdk.tracks.getTrack({ trackId: 'D7KyD' })
console.log(track, 'Track fetched!')

If your bundler doesn't automatically polyfill node libraries (like when using create-react-app v5) you will need to use the web3 script tag instead of the web3 npm package

HTML + JS

1. Include the SDK script tag

<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@audius/sdk@latest/dist/sdk.min.js"></script>

The Audius SDK will then be assigned to window.audiusSdk.

2. Initialize the SDK

const audiusSdk = window.audiusSdk({ appName: 'Name of your app goes here' })

3. Make your first API call using the SDK!

const track = await audiusSdk.tracks.getTrack({ trackId: 'D7KyD' })

Full example

<!DOCTYPE html>
<html>
  <head>
    <script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@audius/sdk@latest/dist/sdk.min.js"></script>
    <script>
    	const fn = async () => {
        const audiusSdk = window.audiusSdk({
          appName: "My Example App",
        });
        const track = await audiusSdk.tracks.getTrack({ trackId: 'D7KyD' });
        console.log(track, "Track fetched!");
      }
      fn()
    </script>
  </head>
  <body>
    <h1>Example content</h1>
  </body>
</html>

FAQs

Package last updated on 20 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts