<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Add sorting to the Web API in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Add-sorting-to-the-Web-API/m-p/6088122#M13998</link>
    <description>&lt;P&gt;&lt;STRONG&gt;My Question or Issue&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hi everyone. I have a small project which will retrieve the &lt;A href="https://developer.spotify.com/documentation/web-api/reference/get-an-artists-albums" target="_blank" rel="noopener"&gt;albums for an artist&lt;/A&gt;, and then &lt;A href="https://developer.spotify.com/documentation/web-api/reference/get-an-albums-tracks" target="_blank" rel="noopener"&gt;get the tracks for these albums&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My application only cares about the &lt;EM&gt;latest&lt;/EM&gt; new tracks and albums. But, the API doesn't provide me any option to sort by date. This means, I have to go through all albums of an artist, find the new ones, and then get the tracks for those albums.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is inefficient, and gets me rate limited.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Request: please allow us to sort the responses based on date (asc, desc), so that we do a single request, instead of potentially thousands.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 May 2024 11:28:49 GMT</pubDate>
    <dc:creator>yorickr</dc:creator>
    <dc:date>2024-05-23T11:28:49Z</dc:date>
    <item>
      <title>Add sorting to the Web API</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Add-sorting-to-the-Web-API/m-p/6088122#M13998</link>
      <description>&lt;P&gt;&lt;STRONG&gt;My Question or Issue&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hi everyone. I have a small project which will retrieve the &lt;A href="https://developer.spotify.com/documentation/web-api/reference/get-an-artists-albums" target="_blank" rel="noopener"&gt;albums for an artist&lt;/A&gt;, and then &lt;A href="https://developer.spotify.com/documentation/web-api/reference/get-an-albums-tracks" target="_blank" rel="noopener"&gt;get the tracks for these albums&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My application only cares about the &lt;EM&gt;latest&lt;/EM&gt; new tracks and albums. But, the API doesn't provide me any option to sort by date. This means, I have to go through all albums of an artist, find the new ones, and then get the tracks for those albums.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is inefficient, and gets me rate limited.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Request: please allow us to sort the responses based on date (asc, desc), so that we do a single request, instead of potentially thousands.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 11:28:49 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Add-sorting-to-the-Web-API/m-p/6088122#M13998</guid>
      <dc:creator>yorickr</dc:creator>
      <dc:date>2024-05-23T11:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Add sorting to the Web API</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Add-sorting-to-the-Web-API/m-p/6089822#M14009</link>
      <description>&lt;P&gt;I agree this would be a great feature. My app also only cares about recent releases - I have found that if you specify a single include_group (aka album type) eg single or album, the results are in descending order of release date. But this can change at any time so don't bet your life that it will stay that way.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In case you're interested:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    def get_albums_released_since(self, artist_id, released_after_date):
        time.sleep(1) # Avoid rate limiting
        albums = []
        for album_type in ['album', 'single']:
            page = self.spotify_client.artist_albums(artist_id, album_type=album_type, limit=50)
            while page:
                time.sleep(1)
                items = page["items"]
                for item in items:
                    if album_released_after_date(item, released_after_date):
                        albums.append(self._artist_album_info(item))
                    else:
                        page = {"next": None}
                        break
                page = self.spotify_client.next(page)
        return albums&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This stops paging once the albums in the response are released before the specified date, to minimize the number of requests. My app also does a boatload of time.sleep-ing to avoid rate limiting -_-&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 23:32:58 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Add-sorting-to-the-Web-API/m-p/6089822#M14009</guid>
      <dc:creator>Naianasha</dc:creator>
      <dc:date>2024-05-23T23:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Add sorting to the Web API</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Add-sorting-to-the-Web-API/m-p/6089842#M14010</link>
      <description>&lt;P&gt;Oh also another reason to do separate requests for each album type/include_group, if you don't do that then the pagination is straight up broken and you won't get the full set of albums even if you go through all the pages. Just FYI.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 23:38:19 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Add-sorting-to-the-Web-API/m-p/6089842#M14010</guid>
      <dc:creator>Naianasha</dc:creator>
      <dc:date>2024-05-23T23:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Add sorting to the Web API</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Add-sorting-to-the-Web-API/m-p/6244897#M14659</link>
      <description>&lt;P&gt;I agree I have created My playlist at random, but by sorting by Year option will definitely benefit.. please could we add this to the sorting List&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 08:40:22 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Add-sorting-to-the-Web-API/m-p/6244897#M14659</guid>
      <dc:creator>ClaytonM</dc:creator>
      <dc:date>2024-08-06T08:40:22Z</dc:date>
    </item>
  </channel>
</rss>

