Clicky

Push 100 Songs to Spotify Playlist in Less Than 1 Minute
Bottom Banner

Push 100 Songs to Spotify Playlist
in Less Than 1 Minute



Table of Contents


Introduction

Imagine building your own Spotify playlists with just a few lines of code! By combining the power of JSON with Spotify's API, you can move beyond manual clicks and unlock a smarter, faster way to organize your music.

Step 1: Install Python & Requirements

Before touching the Spotify API, you’ll need the right tools installed:

  • Install Python 3.x from python.org.
  • Install the requests package:
    pip install requests
  • Create a free or premium Spotify account.
  • Register an app in the Spotify Developer Dashboard and grab an access token with scopes: playlist-modify-private, playlist-modify-public.
Tip: For quick tests, click "Get Token" inside the dashboard. For production, set up OAuth so your token auto-refreshes.


Spotify




Step 2: Collect Track URIs

You need Spotify track URIs before you can upload them to a playlist. Options:

  • Manual copy: Right-click a song in the Spotify app -> Share -> Copy Spotify URI.
  • Spotify History: Check your listening history, then copy URIs from tracks you’ve played. For large listings, you can either request from Spotify an Account Data Download or use the Spotify API to pull listening history.
  • Alternative Export tools: Use third-party exporters or scripts to grab URIs in bulk.

URIs look like this: spotify:track:4iV5W9uYEdYUVa79Axb7Rh.

Step 3: Build a Spreadsheet

Organize your URIs into a CSV or Excel sheet. For example:

CSV Example
track_uri
spotify:track:4iV5W9uYEdYUVa79Axb7Rh
spotify:track:1301WleyT98MSxVHPZCA6M

Later, your script can read this file and push all tracks at once.

Step 4: Create a Playlist with Python

Send a POST request to /v1/users/{user_id}/playlists. Example:

Python
import requests, json

user_id = "your_user_id"
access_token = "your_access_token"

url = f"https://api.spotify.com/v1/users/{user_id}/playlists"
headers = {"Authorization": f"Bearer {access_token}", "Content-Type": "application/json"}
payload = {"name": "My Python Playlist","description": "Created with Python","public": False}

resp = requests.post(url, headers=headers, data=json.dumps(payload))
print(resp.json())

Step 5: Upload Tracks to the Playlist

With your playlist ID and spreadsheet of URIs, send them in batches of 100.

Python
playlist_id = "your_playlist_id"
track_uris = ["spotify:track:4iV5W9uYEdYUVa79Axb7Rh","spotify:track:1301WleyT98MSxVHPZCA6M"]

url = f"https://api.spotify.com/v1/playlists/{playlist_id}/tracks"
headers = {"Authorization": f"Bearer {access_token}", "Content-Type": "application/json"}
payload = {"uris": track_uris}

resp = requests.post(url, headers=headers, data=json.dumps(payload))
print(resp.json())

Note: Spotify lets you upload max 100 URIs per request. Loop over your CSV in chunks.

Full Workflow Script

Here's a single script that creates a playlist and uploads URIs from your spreadsheet:

Python
import requests, json, csv

ACCESS_TOKEN = "your_access_token"
USER_ID = "your_user_id"

# Load URIs from CSV
with open("tracks.csv") as f:
    reader = csv.DictReader(f)
    track_uris = [row["track_uri"] for row in reader]

headers = {"Authorization": f"Bearer {ACCESS_TOKEN}","Content-Type": "application/json"}

# Create playlist
create_url = f"https://api.spotify.com/v1/users/{USER_ID}/playlists"
create_payload = {"name": "Python Playlist","description": "Imported from CSV","public": False}
playlist_id = requests.post(create_url, headers=headers, data=json.dumps(create_payload)).json()["id"]

# Add tracks in chunks of 100
add_url = f"https://api.spotify.com/v1/playlists/{playlist_id}/tracks"
for i in range(0, len(track_uris), 100):
    chunk = {"uris": track_uris[i:i+100]}
    requests.post(add_url, headers=headers, data=json.dumps(chunk))

print("Playlist created and tracks uploaded!")

Bulk Track URI for Large Sets of Track URIs

Spotify Account Data Download (Big Lists)

Spotify lets you request your account data (including listening history):

  • Go to Spotify Account > Privacy Settings.
  • Under Download your data, request a copy.
  • In a few days, Spotify emails you a ZIP with JSON files containing your play history.
  • Extract track IDs/links from that JSON.

This is the "bulk history log" method you mentioned - useful for extracting long-term listening history.

Spotify API (Developer Way)

If you're comfortable with APIs, you can pull history directly:

  • GET /v1/me/player/recently-played (requires an access token).
  • This returns track URIs and metadata directly in JSON.
Tip: For most people who just want a big chunk of links quickly, the Desktop App + Copy Links from Playlist/History is the easiest.
If you want everything you've listened to over months/years, the Account Data Download is the way.

Conclusion

Once you see how JSON can automate your Spotify experience, you'll realize it's only the beginning. Explore other cool ways to use JSON-from managing data to powering apps-and let your creativity take the lead.



*As an Amazon Associate I earn from qualifying purchases.*

Shop Amazon Now




Visit Us On Pinterest