Spotify
Search tracks, manage playlists, and browse your Spotify library.
On this page
Connect
Auth type: OAuth (oauth2). The connection holds the provider's OAuth tokens. They are sealed on the server and only opened when an action runs.
- From your agent: integrations {action: "connect", piece, credentials, env} stores the credentials for dev, prod or all. Answers name the fields, never the values.
- Or set the integration's project secrets with the secrets tool (SLACK_BOT_TOKEN, DISCORD_WEBHOOK_URL, TELEGRAM_BOT_TOKEN, TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN …): a call uses the connection, else those secrets. integrations {action: "catalog", piece} lists which ones work.
- Try one action now with integrations {action: "call", piece, piece_action, input}. It really sends.
Call it from a workflow
step.ctx.integrations.invoke("spotify", action, input) resolves with the provider's answer and rejects when Spotify isn't connected or refuses. Wrap it in step.run so a retry sends once. See step.ctx. Its actions run through the integration runner, which the server's operator turns on: integrations {action: "catalog", piece: "spotify"} says whether yours can call it.
// workflows/notify.ts: call Spotify when a booking is confirmed
import { on } from "@appbricx/workflows";
export const tellSpotify = on.transition("booking", "status", "confirmed", async (_event, step) => {
// Recorded once: a retry doesn't send it twice. Rejects when Spotify isn't connected.
const output = await step.run("Spotify", () =>
step.ctx.integrations.invoke("spotify", "add_playlist_items", {
"playlist_id": "<playlist_id>",
"items": []
}),
);
step.ctx.log("Spotify answered", output);
});{
"name": "integrations",
"arguments": {
"project_id": "<project-id>",
"action": "call",
"piece": "spotify",
"piece_action": "add_playlist_items",
"input": {
"playlist_id": "<playlist_id>",
"items": []
},
"env": "dev"
}
}curl -X POST "$APP_ORIGIN/__appbricx/connector-proxy/spotify/add_playlist_items" \
-H "Authorization: Bearer $APP_KEY" \
-H "content-type: application/json" \
-d '{"props":{"playlist_id":"<playlist_id>","items":[]}}'Actions
add_playlist_items
Add items to playlist. Adds tracks or episodes to the playlist
| Input | Type | Description |
|---|---|---|
playlist_idrequired | id (picked from your account) | Playlist |
itemsrequired | array | URI's of the items to add |
positionoptional | number | Position |
create_playlist
Create Playlist. Creates a new playlist for the current user
| Input | Type | Description |
|---|---|---|
namerequired | text | Name |
descriptionoptional | text | Description |
publicoptional | boolean | Public |
collaborativeoptional | boolean | Collaborative |
get_playback_state
Get Playback State. Retrieves the current playback state of the player
No input.
get_playlist_info
Get Playlist Info. Retrieves details of a playlist
| Input | Type | Description |
|---|---|---|
playlist_idrequired | id (picked from your account) | Playlist |
get_playlist_items
Get Playlist Items. Retrieves the list of items in the playlist
| Input | Type | Description |
|---|---|---|
playlist_idrequired | id (picked from your account) | Playlist |
offsetoptional | number | Offset |
limitoptional | number | Limit |
alloptional | boolean | Fetches all items in a single request |
get_playlists
Get Playlists. Retrieves the list of playlists that you created or followed
| Input | Type | Description |
|---|---|---|
offsetoptional | number | Offset |
limitoptional | number | Limit |
alloptional | boolean | Fetches all playlists in a single request |
custom_api_call
Custom API Call. Make a custom API call to a specific endpoint
| Input | Type | Description |
|---|---|---|
urlrequired | object (depends on other props) | url |
methodrequired | one of "GET" | "POST" | "PATCH" | "PUT" | "DELETE" | "HEAD" | Method |
headersrequired | object | Authorization headers are injected automatically from your connection. |
queryParamsrequired | object | Query Parameters |
body_typeoptional | one of "none" | "json" | "form_data" | "raw" | Body Type |
bodyoptional | object (depends on other props) | Body |
response_is_binaryoptional | boolean | Enable for files like PDFs, images, etc. |
failsafeoptional | boolean | No Error on Failure |
timeoutoptional | number | Timeout (in seconds) |
followRedirectsoptional | boolean | Follow redirects |
get_saved_tracks
Get Saved Tracks. Retrieves the list of saved tracks for the current user
| Input | Type | Description |
|---|---|---|
offsetoptional | number | Offset |
limitoptional | number | Limit |
alloptional | boolean | Fetches all items in a single request |
pause
Pause. Pauses the playback
| Input | Type | Description |
|---|---|---|
device_idoptional | id (picked from your account) | Device |
play
Play / Resume. Resumes or starts playback
| Input | Type | Description |
|---|---|---|
device_idoptional | id (picked from your account) | Device |
context_urioptional | text | Spotify URI of the context to play (album, artist, playlist) |
tracksoptional | array | List of spotify track uris to play |
position_msoptional | number | Position in milliseconds |
remove_playlist_items
Remove items from playlist. Removes tracks or episodes from the playlist
| Input | Type | Description |
|---|---|---|
playlist_idrequired | id (picked from your account) | Playlist |
itemsrequired | array | URI's of the items to remove |
reorder_playlist
Reorder playlist. Reorders items in the playlist
| Input | Type | Description |
|---|---|---|
playlist_idrequired | id (picked from your account) | Playlist |
from_positionrequired | number | From Position |
to_positionrequired | number | To Position |
amountoptional | number | Amount of Items |
search
Search. Searches for tracks, artists, albums, etc.
| Input | Type | Description |
|---|---|---|
search_textrequired | text | The word or phrase you are searching for |
typesrequired | list of | Object Types |
limitoptional | number | Limit |
offsetoptional | number | Offset |
set_volume
Set Volume. Sets the volume of the player
| Input | Type | Description |
|---|---|---|
volumerequired | number | Volume from 0 to 100 |
device_idoptional | id (picked from your account) | Device |
update_playlist
Update Playlist. Updates details of the playlist
| Input | Type | Description |
|---|---|---|
playlist_idrequired | id (picked from your account) | Playlist |
nameoptional | text | Name |
descriptionoptional | text | Description |
publicoptional | boolean | Public |
collaborativeoptional | boolean | Collaborative |
Details
- Id
spotify- Category
- Social media
- Tags
- music, audio, playlists, streaming
- Package
@activepieces/piece-spotify@0.4.4- Runs
- Through the integration runner