Spotify

Search tracks, manage playlists, and browse your Spotify library.

Social mediaOAuth15 actionsAll integrations

On this page
  1. Connect
  2. Call it from a workflow
  3. Actions (15)
  4. add_playlist_items
  5. create_playlist
  6. get_playback_state
  7. get_playlist_info
  8. get_playlist_items
  9. get_playlists
  10. custom_api_call
  11. get_saved_tracks
  12. pause
  13. play
  14. remove_playlist_items
  15. reorder_playlist
  16. search
  17. set_volume
  18. update_playlist
  19. Details

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.

Workflow
// 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);
});
Try it from your agent
{
  "name": "integrations",
  "arguments": {
    "project_id": "<project-id>",
    "action": "call",
    "piece": "spotify",
    "piece_action": "add_playlist_items",
    "input": {
      "playlist_id": "<playlist_id>",
      "items": []
    },
    "env": "dev"
  }
}
From another backend (connector proxy)
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

InputTypeDescription
playlist_idrequiredid (picked from your account)Playlist
itemsrequiredarrayURI's of the items to add
positionoptionalnumberPosition

create_playlist

Create Playlist. Creates a new playlist for the current user

InputTypeDescription
namerequiredtextName
descriptionoptionaltextDescription
publicoptionalbooleanPublic
collaborativeoptionalbooleanCollaborative

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

InputTypeDescription
playlist_idrequiredid (picked from your account)Playlist

get_playlist_items

Get Playlist Items. Retrieves the list of items in the playlist

InputTypeDescription
playlist_idrequiredid (picked from your account)Playlist
offsetoptionalnumberOffset
limitoptionalnumberLimit
alloptionalbooleanFetches all items in a single request

get_playlists

Get Playlists. Retrieves the list of playlists that you created or followed

InputTypeDescription
offsetoptionalnumberOffset
limitoptionalnumberLimit
alloptionalbooleanFetches all playlists in a single request

custom_api_call

Custom API Call. Make a custom API call to a specific endpoint

InputTypeDescription
urlrequiredobject (depends on other props)url
methodrequiredone of "GET" | "POST" | "PATCH" | "PUT" | "DELETE" | "HEAD"Method
headersrequiredobjectAuthorization headers are injected automatically from your connection.
queryParamsrequiredobjectQuery Parameters
body_typeoptionalone of "none" | "json" | "form_data" | "raw"Body Type
bodyoptionalobject (depends on other props)Body
response_is_binaryoptionalbooleanEnable for files like PDFs, images, etc.
failsafeoptionalbooleanNo Error on Failure
timeoutoptionalnumberTimeout (in seconds)
followRedirectsoptionalbooleanFollow redirects

get_saved_tracks

Get Saved Tracks. Retrieves the list of saved tracks for the current user

InputTypeDescription
offsetoptionalnumberOffset
limitoptionalnumberLimit
alloptionalbooleanFetches all items in a single request

pause

Pause. Pauses the playback

InputTypeDescription
device_idoptionalid (picked from your account)Device

play

Play / Resume. Resumes or starts playback

InputTypeDescription
device_idoptionalid (picked from your account)Device
context_urioptionaltextSpotify URI of the context to play (album, artist, playlist)
tracksoptionalarrayList of spotify track uris to play
position_msoptionalnumberPosition in milliseconds

remove_playlist_items

Remove items from playlist. Removes tracks or episodes from the playlist

InputTypeDescription
playlist_idrequiredid (picked from your account)Playlist
itemsrequiredarrayURI's of the items to remove

reorder_playlist

Reorder playlist. Reorders items in the playlist

InputTypeDescription
playlist_idrequiredid (picked from your account)Playlist
from_positionrequirednumberFrom Position
to_positionrequirednumberTo Position
amountoptionalnumberAmount of Items

search

Search. Searches for tracks, artists, albums, etc.

InputTypeDescription
search_textrequiredtextThe word or phrase you are searching for
typesrequiredlist ofObject Types
limitoptionalnumberLimit
offsetoptionalnumberOffset

set_volume

Set Volume. Sets the volume of the player

InputTypeDescription
volumerequirednumberVolume from 0 to 100
device_idoptionalid (picked from your account)Device

update_playlist

Update Playlist. Updates details of the playlist

InputTypeDescription
playlist_idrequiredid (picked from your account)Playlist
nameoptionaltextName
descriptionoptionaltextDescription
publicoptionalbooleanPublic
collaborativeoptionalbooleanCollaborative

Details

Id
spotify
Category
Social media
Tags
music, audio, playlists, streaming
Package
@activepieces/piece-spotify@0.4.4
Runs
Through the integration runner