@@ -22,16 +22,26 @@ the SDK to:
2222
2323...and much more!
2424
25- ## Set Up Your Developer App
25+ ## API Plans
2626
27- 1 . [ Create an Audius account ] ( https://audius.co/signup ) if you do not have one already.
27+ Audius offers two API plans:
2828
29- 2 . Head to the [ Settings page] ( https://audius.co/settings ) and select "Manage Your Apps." Follow the
30- prompts to create a new developer app and get your Audius API Key and API Secret.
29+ | Plan | Rate Limit | Monthly Requests |
30+ | ------------- | ------------------ | ---------------------- |
31+ | ** Free** | 10 requests/second | 500,000 requests/month |
32+ | ** Unlimited** | Unlimited | Unlimited |
33+
34+ The Free plan is always free with no restrictions. For higher limits and support, contact [ api@audius.co ] ( mailto:api@audius.co ) about the Unlimited plan.
35+
36+ ## Get Your API Key and Bearer Token
37+
38+ 1 . Visit the [ Audius API Plans page] ( https://api.audius.co/plans ) and click "Create API Key" to generate your credentials.
39+
40+ 2 . You will receive an ** API Key** and a ** Bearer Token** . Save both securely — treat them like passwords.
3141
3242:::tip
3343
34- Make sure you save your API Secret somewhere safe — treat it like a password .
44+ The bearer token is the recommended way to authenticate with the Audius API .
3545
3646:::
3747
@@ -45,7 +55,7 @@ Make sure you save your API Secret somewhere safe — treat it like a password.
4555If your project is in a Node.js environment, run this in your terminal:
4656
4757``` bash
48- npm install web3 @audius/sdk
58+ npm install @audius/sdk
4959```
5060
5161[ @audius/sdk on NPM] ( https://www.npmjs.com/package/@audius/sdk )
@@ -56,16 +66,12 @@ Otherwise, include the SDK script tag in your web page. The Audius SDK will then
5666` window.audiusSdk ` .
5767
5868``` html
59- <script src =" https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js" ></script >
6069<script src =" https://cdn.jsdelivr.net/npm/@audius/sdk@latest/dist/sdk.min.js" ></script >
6170```
6271
6372## Initialize the SDK
6473
65- Initialize the SDK with your API key.
66-
67- If you plan to write data to Audius (e.g. upload a track, favorite a playlist, etc.), then pass in
68- your API secret as well.
74+ Initialize the SDK with your API key and bearer token.
6975
7076### Node.js example
7177
@@ -74,48 +80,42 @@ import { sdk } from '@audius/sdk'
7480
7581const audiusSdk = sdk ({
7682 apiKey: ' Your API Key goes here' ,
77- apiSecret : ' Your API Secret goes here' ,
83+ bearerToken : ' Your Bearer Token goes here' ,
7884})
7985```
8086
8187### HTML + JS example
8288
8389``` js title="In web page"
84- const audiusSdk = window .audiusSdk ({ apiKey: ' Your API key goes here' })
90+ const audiusSdk = window .audiusSdk ({
91+ apiKey: ' Your API Key goes here' ,
92+ })
8593```
8694
8795:::warning
8896
89- Do NOT include your API secret if you are running the SDK on the frontend, as this will expose your
90- secret.
97+ DO NOT include the bearer token if you are running the SDK in the browser or anywhere on the client.
98+ The bearer token is what allows your app to write on behalf of the users that have authorized it to
99+ do so. Keep your bearer token secure and never expose it in client-side code that could be inspected.
91100
92101:::
93102
94103## Make your first API call using the SDK!
95104
96105Once you have the initialized SDK instance, it's smooth sailing to making your first API calls.
97106
98- :::note
99-
100- If you included your API secret in the previous step, you'll be able do both reads (e.g. fetching a
101- playlist) and writes (e.g. reposting a playlist) to Audius. Otherwise, you'll be able to read data
102- only.
103-
104- :::
105-
106107``` js
107108// Fetch your first track!
108109const track = await audiusSdk .tracks .getTrack ({ trackId: ' D7KyD' })
109110console .log (track, ' Track fetched!' )
110111
111- // If you initialized the SDK with your API secret, you can write data as well.
112- // For example, to favorite the track above:
112+ // Favorite a track
113113const userId = (
114114 await audiusSdk .users .getUserByHandle ({
115115 handle: ' Your Audius handle goes here' ,
116116 })
117117).data ? .id
118- const track = await audiusSdk .tracks .favoriteTrack ({
118+ await audiusSdk .tracks .favoriteTrack ({
119119 trackId: ' D7KyD' ,
120120 userId,
121121})
@@ -128,7 +128,7 @@ import { sdk } from '@audius/sdk'
128128
129129const audiusSdk = sdk ({
130130 apiKey: ' Your API Key goes here' ,
131- apiSecret : ' Your API Secret goes here' ,
131+ bearerToken : ' Your Bearer Token goes here' ,
132132})
133133
134134const track = await audiusSdk .tracks .getTrack ({ trackId: ' D7KyD' })
@@ -140,44 +140,19 @@ const userId = (
140140 })
141141).data ? .id
142142
143- const track = await audiusSdk .tracks .favoriteTrack ({
143+ await audiusSdk .tracks .favoriteTrack ({
144144 trackId: ' D7KyD' ,
145145 userId,
146146})
147147console .log (' Track favorited!' )
148148` ` `
149149
150- :::note
151-
152- Writing data (such as uploading or favoriting a track) is only possible if you provide an apiSecret
153-
154- :::
155-
156- :::note
157-
158- If you are using the sdk in a browser environment you will need to do:
159-
160- ` ` ` js
161- import Web3 from ' web3'
162- window .Web3 = Web3
163- ` ` `
164-
165- :::
166-
167- :::note
168-
169- If your bundler doesn't automatically polyfill node libraries (like when using create-react-app v5)
170- you will need to use the ` web3` script tag instead of the ` web3` npm package.
171-
172- :::
173-
174150## Full HTML + JS example
175151
176152` ` ` html title= " index.html" showLineNumbers
177153< ! DOCTYPE html>
178154< html>
179155 < head>
180- < script src= " https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js" >< / script>
181156 < script src= " https://cdn.jsdelivr.net/npm/@audius/sdk@latest/dist/sdk.min.js" >< / script>
182157 < script>
183158 const fn = async () => {
@@ -203,3 +178,23 @@ you will need to use the `web3` script tag instead of the `web3` npm package.
203178 accounts
204179
205180- [Explore the API docs](/developers/sdk/tracks) to see what else you can do with the Audius SDK
181+
182+ ## Direct API Access
183+
184+ You can also access the Audius API directly without the SDK:
185+
186+ **REST API:**
187+
188+ ` ` ` bash
189+ curl - X GET " https://api.audius.co/v1/tracks/trending" \
190+ - H " Authorization: Bearer <YOUR-API-BEARER-TOKEN>"
191+ ` ` `
192+
193+ **gRPC:**
194+
195+ ` ` ` bash
196+ grpcurl - H " authorization: Bearer <YOUR-API-BEARER-TOKEN>" \
197+ grpc .audius .co : 443 list
198+ ` ` `
199+
200+ For more details, visit the [API documentation](https://docs.audius.co/api) or the [Swagger definition](https://api.audius.co/v1).
0 commit comments