<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aran Services</title>
    <description>The latest articles on DEV Community by Aran Services (@aran404).</description>
    <link>https://dev.to/aran404</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2000871%2Fd2c74e5f-6667-4f81-a4af-d3caa05e0263.png</url>
      <title>DEV Community: Aran Services</title>
      <link>https://dev.to/aran404</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aran404"/>
    <language>en</language>
    <item>
      <title>How to Export a Spotify Playlist to CSV with Python</title>
      <dc:creator>Aran Services</dc:creator>
      <pubDate>Fri, 04 Dec 2026 21:20:31 +0000</pubDate>
      <link>https://dev.to/aran404/how-to-export-a-spotify-playlist-to-csv-with-python-36k3</link>
      <guid>https://dev.to/aran404/how-to-export-a-spotify-playlist-to-csv-with-python-36k3</guid>
      <description>&lt;p&gt;Have you ever wanted to inspect your Spotify playlists in a spreadsheet, find repeated tracks, or build your own music analysis tool?&lt;/p&gt;

&lt;p&gt;You can do this with Python and SpotAPI, an open-source library I maintain.&lt;/p&gt;

&lt;p&gt;This example works with publicly accessible playlists without registering a Spotify developer application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;p&gt;Install SpotAPI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -m pip install spotapi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Download the playlist auditing example from the repository:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Aran404/SpotAPI/blob/main/examples/playlist_audit.py" rel="noopener noreferrer"&gt;https://github.com/Aran404/SpotAPI/blob/main/examples/playlist_audit.py&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Save it as &lt;code&gt;playlist_audit.py&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Export your playlist
&lt;/h2&gt;

&lt;p&gt;Copy a public Spotify playlist link and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python playlist_audit.py &lt;span class="s2"&gt;"YOUR_PLAYLIST_URL"&lt;/span&gt; --output playlist.csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also limit the number of entries scanned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python playlist_audit.py &lt;span class="s2"&gt;"YOUR_PLAYLIST_URL"&lt;/span&gt; \
    --output playlist.csv \
    --max-items 500
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The full example supports up to 10,000 playlist entries.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does the CSV contain?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Track names&lt;/li&gt;
&lt;li&gt;Artists&lt;/li&gt;
&lt;li&gt;Spotify identifiers&lt;/li&gt;
&lt;li&gt;Track durations&lt;/li&gt;
&lt;li&gt;Dates added, when available&lt;/li&gt;
&lt;li&gt;Playlist positions&lt;/li&gt;
&lt;li&gt;Repeated track identifiers&lt;/li&gt;
&lt;li&gt;Unavailable entries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can open the resulting CSV in Excel, Google Sheets or a Python data analysis tool.&lt;/p&gt;

&lt;p&gt;Duplicate detection currently identifies repeated Spotify track URIs. It doesn't assume that different releases of the same song are necessarily identical recordings.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;The script reads playlist entries through SpotAPI's asynchronous pagination interface. Rather than loading an entire large playlist into memory, it processes entries incrementally.&lt;/p&gt;

&lt;p&gt;It also preserves repeated track occurrences instead of silently discarding them.&lt;/p&gt;

&lt;p&gt;The export is read-only. Your original Spotify playlist is not modified.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I built this
&lt;/h2&gt;

&lt;p&gt;I started reverse-engineering Spotify's web player in high school because I was curious about what developers could build with it.&lt;/p&gt;

&lt;p&gt;Playlist analysis is one of the more practical applications that emerged from the project.&lt;/p&gt;

&lt;p&gt;SpotAPI uses unofficial endpoints, which may change over time. Only use it with playlists you're permitted to access.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/Aran404/SpotAPI" rel="noopener noreferrer"&gt;https://github.com/Aran404/SpotAPI&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you build an interesting playlist analysis tool with it, I'd genuinely love to see it.&lt;/p&gt;

</description>
      <category>python</category>
      <category>spotify</category>
      <category>automation</category>
      <category>datascience</category>
    </item>
    <item>
      <title>How to Use Spotify with Python Without an API Key</title>
      <dc:creator>Aran Services</dc:creator>
      <pubDate>Fri, 04 Dec 2026 21:17:44 +0000</pubDate>
      <link>https://dev.to/aran404/how-to-use-spotify-with-python-without-an-api-key-2ofm</link>
      <guid>https://dev.to/aran404/how-to-use-spotify-with-python-without-an-api-key-2ofm</guid>
      <description>&lt;p&gt;I started reverse-engineering Spotify's web player when I was 15. Almost three years later, that little experiment has become an open-source Python library called SpotAPI.&lt;/p&gt;

&lt;p&gt;If you're building a music-related side project and just want to search Spotify's public catalogue, here's how to get started without registering a developer application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;You'll need Python 3.11 or newer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -m pip install spotapi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can immediately search Spotify from your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -m spotapi search &lt;span class="s2"&gt;"Daft Punk"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No developer account, client ID or client secret is required for this public search.&lt;/p&gt;

&lt;h2&gt;
  
  
  Searching Spotify with Python
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;

&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;spotapi&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Public&lt;/span&gt;


&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Daft Punk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;track&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tracks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;track&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;track&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The results are typed Python models, so you can explore their attributes using your editor's autocomplete.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fetching artist information
&lt;/h2&gt;

&lt;p&gt;If you're making multiple related requests, you can reuse a catalogue session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;

&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;spotapi&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Catalogue&lt;/span&gt;


&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nc"&gt;Catalogue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;spotify&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;spotify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Daft Punk"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;artists&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;artist&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;spotify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_artist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;artists&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;artist&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Exploring Spotify interactively
&lt;/h2&gt;

&lt;p&gt;I also built a terminal interface for exploring Spotify's public catalogue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -m pip install &lt;span class="s2"&gt;"spotapi[demo]"&lt;/span&gt;
python -m spotapi discover &lt;span class="s2"&gt;"Daft Punk"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can navigate search results and explore metadata directly from your terminal without signing in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What about playlists and playback?
&lt;/h2&gt;

&lt;p&gt;SpotAPI also supports authenticated account operations, playlist management and control of existing Spotify players. Those operations require your own Spotify session.&lt;/p&gt;

&lt;p&gt;The library does not stream or decrypt music.&lt;/p&gt;

&lt;p&gt;One important distinction: SpotAPI uses unofficial web-player endpoints, so Spotify can change their behaviour without notice. If you're building something that depends on officially supported contracts, the official Spotify Web API may be a better choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  What would you build?
&lt;/h2&gt;

&lt;p&gt;I'd love to see what other developers make with this. The project started as something I built out of curiosity in high school, and I'm still discovering interesting uses for it.&lt;/p&gt;

&lt;p&gt;Source code: &lt;a href="https://github.com/Aran404/SpotAPI" rel="noopener noreferrer"&gt;https://github.com/Aran404/SpotAPI&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Documentation: &lt;a href="https://the-open-odyssey.pages.dev/docs/spotapi/" rel="noopener noreferrer"&gt;https://the-open-odyssey.pages.dev/docs/spotapi/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SpotAPI is open source under GPL-3.0.&lt;/p&gt;

</description>
      <category>automation</category>
      <category>python</category>
      <category>spotify</category>
      <category>github</category>
    </item>
    <item>
      <title>I wrote a Python library at 16. Here are 5 things I'd fix in the async rewrite</title>
      <dc:creator>Aran Services</dc:creator>
      <pubDate>Sat, 14 Nov 2026 14:43:12 +0000</pubDate>
      <link>https://dev.to/aran404/i-wrote-a-python-library-at-16-here-are-5-things-id-fix-in-the-async-rewrite-4p62</link>
      <guid>https://dev.to/aran404/i-wrote-a-python-library-at-16-here-are-5-things-id-fix-in-the-async-rewrite-4p62</guid>
      <description>&lt;p&gt;My first Python library has nearly 500 GitHub stars. To get a track's name out of it, you wrote this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"item"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That one line explains most of what I'd do differently.&lt;/p&gt;

&lt;p&gt;I started SpotAPI when I was 16. I'd spent a long time working with Spotify's unofficial web-player API, and I had a pile of code that worked, so I bundled it into a library and put it on GitHub. Over the next two years it picked up nearly 500 stars while the code barely changed. I didn't maintain it as well as I should have, and other people sent most of the fixes that kept it alive.&lt;/p&gt;

&lt;p&gt;Version 2 is a typed, async rewrite. Here's what I changed. None of it is specific to Spotify.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Return models, not nested dicts
&lt;/h2&gt;

&lt;p&gt;Version 1 handed back whatever the server sent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# v1&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;song&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;paginate_songs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"weezer"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"item"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With an undocumented API, that couples every user's script to a response shape nobody promised to keep. Now results are typed models:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# v2&lt;/span&gt;
&lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"weezer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;track&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tracks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;track&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;track&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get autocomplete and type checking, and when Spotify changes a response, the fix lives in the library instead of in every script that depends on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Reading an attribute should never make a network call
&lt;/h2&gt;

&lt;p&gt;In v2, reading a model never triggers a hidden HTTP request. If Spotify didn't send a field, it stays optional and you decide whether to go and fetch it.&lt;/p&gt;

&lt;p&gt;Lazy-loading attributes feel convenient until you hit the N+1 problem in a loop. In async code it's worse, because a property can't &lt;code&gt;await&lt;/code&gt;. Network access should look like network access.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Offer a one-shot call and a context manager
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# One call: cleans up after itself&lt;/span&gt;
&lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Daft Punk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Many calls: share one session&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nc"&gt;Catalogue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;spotify&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;spotify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Daft Punk"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;artist&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;spotify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_artist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;artists&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;artist&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The one-shot covers the common case without leaking connections. The context manager makes ownership explicit when you're making several calls. Resource lifetime is where async libraries tend to go wrong, so I wanted both paths to be hard to misuse.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. A row is not the thing it points to
&lt;/h2&gt;

&lt;p&gt;A playlist can contain the same track twice. If your API says &lt;code&gt;remove(track_uri)&lt;/code&gt;, which copy goes?&lt;/p&gt;

&lt;p&gt;SpotAPI models each &lt;em&gt;occurrence&lt;/em&gt; of a track in a playlist, with its own ID. &lt;code&gt;Playlist.items()&lt;/code&gt; returns occurrences, and &lt;code&gt;remove_occurrences()&lt;/code&gt; and &lt;code&gt;move_occurrences()&lt;/code&gt; act on them, so you can edit one copy without touching its twin.&lt;/p&gt;

&lt;p&gt;The same bug shows up in shopping carts, queues and to-do lists. Model what the user is actually pointing at, not the entity it refers to.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. If you wrap something unofficial, plan for it to break
&lt;/h2&gt;

&lt;p&gt;SpotAPI uses the same web-player endpoints as open.spotify.com, and Spotify can change them without telling anyone. Here's how I design around that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Discover at runtime, cache by build.&lt;/strong&gt; The first request finds Spotify's current web-player queries, and later runs reuse them for the same Spotify build. The tradeoff is a slower first run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One exception to catch.&lt;/strong&gt; Library failures are &lt;code&gt;SpotAPIError&lt;/code&gt;, so your code can tell "the library broke" from "my code broke".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Opt-in live tests.&lt;/strong&gt; The default test run (441 passing) doesn't depend on a third party's uptime.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Written-down boundaries.&lt;/strong&gt; The docs list what I verified and what I didn't.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I got wrong the first time
&lt;/h2&gt;

&lt;p&gt;Stars aren't maintenance. I was slow to answer issues and cut releases, and people sometimes had to ask me to update the PyPI package.&lt;/p&gt;

&lt;p&gt;Releases now go out from GitHub Actions with PyPI attestations, so you can verify where a package came from.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it in 30 seconds
&lt;/h2&gt;

&lt;p&gt;You don't need to care about Spotify to see what a typed async client feels like. You need Python 3.11+:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install spotapi
spotapi search &lt;span class="s2"&gt;"Ca$h YP"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's no API key, login or config. The first run is slower while it discovers queries. For something nicer to look at, there's a terminal UI with artwork:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install &lt;span class="s2"&gt;"spotapi[demo]"&lt;/span&gt;
spotapi discover &lt;span class="s2"&gt;"Ca$h YP"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0rjsu81mvpw8pycdsxup.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0rjsu81mvpw8pycdsxup.gif" alt="SpotAPI Discover in the terminal" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd like feedback on
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Layering:&lt;/strong&gt; Is &lt;code&gt;Public&lt;/code&gt; vs &lt;code&gt;Catalogue&lt;/code&gt; (one-shot vs shared session) clear, or did I over-split it?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hidden I/O:&lt;/strong&gt; Do you agree that models shouldn't do hidden I/O, or have you found a case where lazy loading was worth it?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unofficial APIs:&lt;/strong&gt; How do you keep a client for an unofficial API maintainable?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;SpotAPI uses unofficial endpoints, may conflict with Spotify's terms, and doesn't stream or download audio. See the legal notice before using it. It's GPL-3.0.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repo: &lt;a href="https://github.com/Aran404/SpotAPI" rel="noopener noreferrer"&gt;https://github.com/Aran404/SpotAPI&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Docs: &lt;a href="https://spotapi.readthedocs.io/" rel="noopener noreferrer"&gt;https://spotapi.readthedocs.io/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>opensource</category>
      <category>asyncio</category>
      <category>showdev</category>
    </item>
    <item>
      <title>🚀 Introducing SpotAPI: A Python Library for Effortless Spotify Integration 🚀</title>
      <dc:creator>Aran Services</dc:creator>
      <pubDate>Fri, 30 Aug 2024 03:00:22 +0000</pubDate>
      <link>https://dev.to/aran404/introducing-spotapi-a-python-library-for-effortless-spotify-integration-1g29</link>
      <guid>https://dev.to/aran404/introducing-spotapi-a-python-library-for-effortless-spotify-integration-1g29</guid>
      <description>&lt;p&gt;Hey DEV Community! 👋&lt;/p&gt;

&lt;p&gt;I'm excited to introduce &lt;strong&gt;&lt;a href="https://github.com/Aran404/SpotAPI" rel="noopener noreferrer"&gt;SpotAPI&lt;/a&gt;&lt;/strong&gt;, a powerful and easy-to-use Python library designed to simplify your interactions with Spotify's private and public APIs. Whether you're building a music app or just experimenting with Spotify data, SpotAPI offers a seamless way to access Spotify's rich features programmatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is SpotAPI? 🎵
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/Aran404/SpotAPI" rel="noopener noreferrer"&gt;SpotAPI&lt;/a&gt;&lt;/strong&gt; is a Python library that emulates the requests made through a web browser to interact with Spotify's APIs. It provides an intuitive interface to work with both public and private Spotify data, making it easier to integrate Spotify features into your applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features ✨
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No Premium Required&lt;/strong&gt;: Access Spotify’s features without needing a Premium account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public API Access&lt;/strong&gt;: Retrieve and manage public Spotify data like playlists, albums, and tracks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Private API Access&lt;/strong&gt;: Explore private endpoints for tailored application needs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy Integration&lt;/strong&gt;: Start using &lt;strong&gt;&lt;a href="https://github.com/Aran404/SpotAPI" rel="noopener noreferrer"&gt;SpotAPI&lt;/a&gt;&lt;/strong&gt; with minimal setup—no API key required!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Browser-like Requests&lt;/strong&gt;: Replicate Spotify's web requests for a true-to-web experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Quick Start Guide 🚀
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Without User Authentication:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;spotapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Song&lt;/span&gt;

&lt;span class="n"&gt;song&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Song&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;gen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;song&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;paginate_songs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;weezer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;gen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;item&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;data&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Import Cookies 🛠️
&lt;/h3&gt;

&lt;p&gt;Prefer not to use a CAPTCHA solver? You can import cookies to manage your session. Simply follow the &lt;a href="https://github.com/Aran404/SpotAPI#import-cookies" rel="noopener noreferrer"&gt;steps in our documentation&lt;/a&gt; to use &lt;strong&gt;&lt;a href="https://github.com/Aran404/SpotAPI" rel="noopener noreferrer"&gt;SpotAPI&lt;/a&gt;&lt;/strong&gt; with a fully functional session.&lt;/p&gt;




&lt;h3&gt;
  
  
  License 📝
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/Aran404/SpotAPI" rel="noopener noreferrer"&gt;SpotAPI&lt;/a&gt;&lt;/strong&gt; is licensed under the &lt;strong&gt;GPL 3.0&lt;/strong&gt; License. &lt;a href="https://choosealicense.com/licenses/gpl-3.0/" rel="noopener noreferrer"&gt;Learn more about the license&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Feel free to check out the &lt;a href="https://github.com/Aran404/SpotAPI" rel="noopener noreferrer"&gt;SpotAPI GitHub repository&lt;/a&gt; for more details and to get started. Let me know if you have any questions or feedback!&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>python</category>
      <category>spotify</category>
      <category>api</category>
    </item>
  </channel>
</rss>
