{"connections":[{"id":"spotify-web-api-node","title":"spotify-web-api-node (TypeScript)","kind":"sdk","language":"typescript","description":"Point the Spotify SDK's account and API base hosts at the emulator instance.","template":"import SpotifyWebApi from \"spotify-web-api-node\";\n\nconst spotify = new SpotifyWebApi({\n  clientId: \"{{clientId}}\",\n  clientSecret: \"{{clientSecret}}\",\n});\n\n// Route both the accounts (token) and API hosts at the emulator.\nconst base = \"{{baseUrl}}\";\n\n// Client credentials grant against the emulator token endpoint.\nconst auth = Buffer.from(\"{{clientId}}:{{clientSecret}}\").toString(\"base64\");\nconst res = await fetch(`${base}/api/token`, {\n  method: \"POST\",\n  headers: {\n    authorization: `Basic ${auth}`,\n    \"content-type\": \"application/x-www-form-urlencoded\",\n  },\n  body: new URLSearchParams({ grant_type: \"client_credentials\" }),\n});\nconst { access_token } = await res.json();\nspotify.setAccessToken(access_token);\n\nconst results = await fetch(`${base}/v1/search?q=daft&type=artist`, {\n  headers: { authorization: `Bearer ${access_token}` },\n}).then((r) => r.json());","body":"import SpotifyWebApi from \"spotify-web-api-node\";\n\nconst spotify = new SpotifyWebApi({\n  clientId: \"<client_id>\",\n  clientSecret: \"<client_secret>\",\n});\n\n// Route both the accounts (token) and API hosts at the emulator.\nconst base = \"https://spotify.your-instance.emulators.dev\";\n\n// Client credentials grant against the emulator token endpoint.\nconst auth = Buffer.from(\"<client_id>:<client_secret>\").toString(\"base64\");\nconst res = await fetch(`${base}/api/token`, {\n  method: \"POST\",\n  headers: {\n    authorization: `Basic ${auth}`,\n    \"content-type\": \"application/x-www-form-urlencoded\",\n  },\n  body: new URLSearchParams({ grant_type: \"client_credentials\" }),\n});\nconst { access_token } = await res.json();\nspotify.setAccessToken(access_token);\n\nconst results = await fetch(`${base}/v1/search?q=daft&type=artist`, {\n  headers: { authorization: `Bearer ${access_token}` },\n}).then((r) => r.json());"},{"id":"spotify-env","title":"Spotify base URL (env)","kind":"env","language":"bash","description":"Point your app at the emulator instead of the real Spotify accounts and API hosts.","template":"SPOTIFY_BASE_URL={{baseUrl}}\nSPOTIFY_TOKEN_URL={{baseUrl}}/api/token\nSPOTIFY_CLIENT_ID={{clientId}}\nSPOTIFY_CLIENT_SECRET={{clientSecret}}","body":"SPOTIFY_BASE_URL=https://spotify.your-instance.emulators.dev\nSPOTIFY_TOKEN_URL=https://spotify.your-instance.emulators.dev/api/token\nSPOTIFY_CLIENT_ID=<client_id>\nSPOTIFY_CLIENT_SECRET=<client_secret>"},{"id":"curl-token","title":"curl (client credentials)","kind":"curl","language":"bash","description":"Exchange client credentials for an app token, then call the catalog.","template":"curl -s -X POST {{baseUrl}}/api/token \\\n  -u \"{{clientId}}:{{clientSecret}}\" \\\n  -d grant_type=client_credentials","body":"curl -s -X POST https://spotify.your-instance.emulators.dev/api/token \\\n  -u \"<client_id>:<client_secret>\" \\\n  -d grant_type=client_credentials"},{"id":"curl-search","title":"curl (search)","kind":"curl","language":"bash","description":"Call the catalog directly with an app token.","template":"curl -s \"{{baseUrl}}/v1/search?q=daft&type=artist\" -H \"authorization: Bearer {{token}}\"","body":"curl -s \"https://spotify.your-instance.emulators.dev/v1/search?q=daft&type=artist\" -H \"authorization: Bearer <token>\""},{"id":"base-url","title":"Base URL (env)","kind":"env","language":"bash","description":"Point your SDK or app at the emulator instead of the real provider.","template":"{{SERVICE_UPPER}}_BASE_URL={{baseUrl}}","body":"SPOTIFY_BASE_URL=https://spotify.your-instance.emulators.dev"},{"id":"create-credential","title":"Create a credential","kind":"curl","language":"bash","description":"Mint a working credential for this instance.","template":"curl -s -X POST {{controlBaseUrl}}/credentials \\\n  -H \"content-type: application/json\" \\\n  -d '{\"type\":\"{{defaultAuthType}}\"}'","body":"curl -s -X POST https://spotify.your-instance.emulators.dev/_emulate/credentials \\\n  -H \"content-type: application/json\" \\\n  -d '{\"type\":\"oauth-client-credentials\"}'"},{"id":"inspect-ledger","title":"Inspect requests","kind":"curl","language":"bash","description":"Read the request ledger to validate how your app called the service.","template":"curl -s {{controlBaseUrl}}/ledger","body":"curl -s https://spotify.your-instance.emulators.dev/_emulate/ledger"}]}