Spotify Agent Week 1

    Spotify Agent Week 1

    Week 1 Instructions for Spotify Agent Project

    By AI Club on 9/22/2025
    0


    # Week 1: Setting Up Your Environment, APIs, and Agent


    Hey! Thanks for joining the Spotify Agent Project. This week, we'll be taking care of all of the boring but necessary stuff that will ensure you have the tools you need to build. But I'll also hope to introduce some fundamental concepts that we'll be expanding upon later on.


    ## Demo


    At the end of the semester you'll build something that looks like [this](https://www.youtube.com/watch?v=rfwHYzJKaa8&t=10s). If that seems a little basic, don't worry! At the end of the semester, you'll have a few weeks to engineer and add your own features. Actually, we'll be using the quality and utility of these unique features to determine winners for the beginner project.


    ## 1. Setting Up Your Development Environment


    ### 1.1 Installing Python


    For Windows:


    Go to https://www.python.org/downloads/


    Download Python 3.11 or later for your operating system.


    Run the installer. On Windows, make sure to check "Add Python to PATH."


    Verify the installation:


    Open a command prompt or terminal.


    Type python --version and press "Enter".


    You should see the Python version number.


    For Mac: Python is usually installed by default. Open a terminal and type python3 to confirm if it is.


    ### 1.2 Installing Git and Setting up your repo


    If you aren't familiar with Git and GitHub, don't worry. Git is what is called a "version control tool" that basically allows use to save and keep a record of our code as it evolves over time. GitHub is a website that maintains a copy of this record online.



    #### Installing Git

    Here's how to install Git on your system:


    Windows:

    1. Go to https://git-scm.com/download/win and download the installer

    2. Run the installer, accepting the default options

    3. Make sure "Git from the Command Line and also from 3rd-party software" is selected

    4. Complete the installation and open Command Prompt

    5. Type git --version to verify the installation


    macOS:

    1. Open Terminal

    2. Type xcode-select --install and follow the prompts

       (Or if you use Homebrew: brew install git)

    3. Type git --version to verify


    Linux (Ubuntu/Debian):

    1. Open Terminal

    2. Run: sudo apt update && sudo apt install git -y

    3. Type git --version to verify





    After installation, configure your identity: Run the following commands in your command line

    git config --global user.name "Your Name"

    git config --global user.email "your.email@example.com"


    #### Setting up GitHub and Authentication


    1. Create a GitHub Account:

       - Go to [github.com](https://github.com) and click "Sign up"

       - Enter your email, create a password, and choose a username

       - Verify your email address when prompted


    2. Create a Personal Access Token (PAT):

       - Click your profile picture → Settings → Developer settings → Personal access tokens → Tokens (classic)

       - Click "Generate new token (classic)"

       - Give it a name

       - Select scopes: at minimum, check "repo" and "workflow"

       - Copy the token immediately and store it somewhere safe - you won't see it again!


    3. Configure Git to remember your credentials:

    git config --global credential.helper store

    Then the first time you push to GitHub (more on that later), enter your username and use your PAT as the password. Git will remember it for future uses.



    #### Create a repository for your project

    In GitHub, make a new repository. Give it Public visibility.


    Go to that repo and click the "Code" tab, then copy the link within the "Quick setup" box


    In the IDE of your choice (I would recommend VS Code because that is what was used to make this project), clone the repo by pasting the link you copied in the previous step. If you're using VS Code, you can do this by clicking the "Clone Git Repository" button and pasting the link in the input field. Then choose a good folder for your project to be cloned to on your computer


    In the root of your new directory, create a .gitignore file, which tells our version control software (git) what not to keep track of or share publicly. We'll eventually add a ton of files to our directory that we either don't want to share or don't care enough to track. As we build our project, we'll include the addrees of such files here.


    ### 1.3 Installing UV (Python Package Manager)


    To handle package installation and dependency management, we're gonna be using a tool called UV. You may have heard of pip (a python package installation tool) and venv (a python enviorment tool). UV combines both into one unified tool for developing in python.


    #### For Windows:


    1. Open PowerShell as Administrator

    2. Run this command:

    powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

    3. Close and reopen your terminal to refresh the PATH

    4. Verify installation by typing uv --version


    #### For Mac:


    1. Open Terminal

    2. Run this command

    curl -LsSf https://astral.sh/uv/install.sh | sh

    3. Restart your terminal or run source ~/.bashrc (or source ~/.zshrc if using zsh)

    4. Verify installation by typing uv --version


    ### 1.4 Setting Up Your UV Environment


    Now that UV is installed, let's create a proper Python environment for our project:


    #### Initialize your project:


    1. Navigate to your cloned repository directory in terminal/command prompt

    2. Initialize a new UV project:

    uv init


    This creates a pyproject.toml file that will track our project configuration and dependencies. This is useful in case we want to export our project or share it with someone else (we'll have a detailed record of what dependencies exactly are needed).


    #### Create and activate a virtual environment:

    We are now going to create a virtual enviornment for our project. If you aren't aware, virtual enviornments allow us to install specific libraries for just this project without affecting our python installation globally.


    Create a virtual environment with Python 3.11+:

    uv venv --python 3.11


    Activate the environment:

    Windows:

    .venv\Scripts\activate


    Mac/Linux:

    source .venv/bin/activate



    #### Update your gitignore


    Let's go back to the .gitignore file from earlier. All of the packages and source code installed within our venv are not worth tracking and may cause git errors as our project complexity grows.


    Add the following to your gitignore


    # Virtual environment

    .venv/

    venv/

    env/


    Now push these changes from your local git repository, to the remote repository we created earlier. The easiest way to do this is with the Source Control tool in Vscode. You can also use your command line


    git add . #tracks all of the files in your directory

    git commit -m "commit message of your choice" #logs all of the changes made to those files

    git push #updates the repository hosted online on GitHub


    Btw, I recommend that you get very, very good at Git (will pay dividends in your lifetime as a developer). So check out this[website](https://learngitbranching.js.org/?locale=en_US) if you want to learn more.


    ## Signing up for APIs


    There are two main services we'll need to sign up for to build our project, Spotify and Groq.


    ### Spotify API Setup


    1. Create a Spotify Developer Account:

       - Go to [Spotify Developer Dashboard](https://developer.spotify.com/dashboard)

       - Log in with your Spotify account (create one if needed)

       - Accept the Developer Terms of Service


    2. Create a New App:

       - Click "Create App" in the dashboard

       - Fill in the app name (e.g., "My Spotify Agent")

       - Add a brief description

       - Set the Redirect URI to http://127.0.0.1:8090/callback

    • Side note: the number "127.0.0.1" is known as "localhost" and "8090" is what is known as a port number. This URI is basically telling your app to look for a server running locally (on your computer) at the specific location of "8090".


    3. Get Your Credentials:

       - After creating the app, you'll see your Client ID

       - Click "View Client Secret" to reveal your Client Secret

       - Save both these values - you'll need them later in your code

       - IMPORTANT: Never commit these credentials to Git! We'll store them in a .env file (more on that later)


    4. Configure Redirect URI:

       - The redirect URI (choose something like http://localhost:3000/callback) is crucial for OAuth flow

       - When a user authorizes your app, Spotify will redirect them to this URL

       - Your app will be listening on this URL to complete the authentication

       



    ### Groq


    You may be familiar with Grok, Elon Musk and xAI's flagship LLM that was probably trained on too much data from 4chan. Groq (spelled with a q instead of a k) is an entirely different service altogether (confusing, I know).


    Groq is a service that offers various open source LLMs hosted on the cloud that we can send requests to. It's useful for our purposes because they offer a free tier with a decent amount of free input and output usage.


    Here's how to sign up for Groq:


    1. Create an Account:

       - Go to [groq.com](https://console.groq.com/sign-up)

       - Click "Sign Up" and create an account with your email

       - Verify your email address when prompted


    2. Get Your API Key:

       - After logging in, go to the [API Keys](https://console.groq.com/keys) section

       - Click "Create API Key"

       - Give your key a name (e.g., "Spotify Agent")

       - Copy the API key immediately and store it somewhere safe- you won't see it again!

       - IMPORTANT: Like with Spotify, never commit this key to Git. We'll add it to our .env file later


    3. Check Your Usage Limits:

       - Groq offers a free tier with generous limits

       - You can view your current usage in the dashboard

       - You should have zero usage at the moment

       - The free tier should be more than enough for development



    ## Agentic Fundamentals


    Here I'll link two YouTube videos that I recommend you watch. The first is an explanation of something called MCP or Model Context Protocol, a standardized framework for how agents should communicatue with tools


    [MCP](https://www.youtube.com/watch?v=FLpS7OfD5-s)


    The Second is a basic overview of LangChain and LangGraph. We'll eventually be using LangGraph to build our project, but it's a good idea to be familiar with both


    [LangChain and LangGraph](https://www.youtube.com/watch?v=qAF1NjEVHhY)


    You should also read through this general overview provided in the LangGraph Documentation


    [LangGraph Quickstart](https://langchain-ai.github.io/langgraph/concepts/why-langgraph/)

    See you all next week!

    Comments