[GH-ISSUE #181] Current approach to iterate over a page #63

Closed
opened 2026-02-27 20:22:53 +03:00 by kerem · 2 comments
Owner

Originally created by @JojiiOfficial on GitHub (Jan 31, 2021).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/181

I'm currently at a point, where I need all "FullTrack" items of any playlist, by its id. A page gives information about the next one (if available) through a URL. I haven't seen any function in the documentation, which lets me retrieve the next page using this URL. I've seen #166 and I'm hoping to see this feature in rspotify in the future. But what is the best approach for now? Crawling the URL manually with reqwest?

Originally created by @JojiiOfficial on GitHub (Jan 31, 2021). Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/181 I'm currently at a point, where I need all "FullTrack" items of any playlist, by its id. A page gives information about the next one (if available) through a URL. I haven't seen any function in the documentation, which lets me retrieve the next page using this URL. I've seen #166 and I'm hoping to see this feature in rspotify in the future. But what is the best approach for now? Crawling the URL manually with `reqwest`?
kerem 2026-02-27 20:22:53 +03:00
Author
Owner

@ramsayleung commented on GitHub (Feb 7, 2021):

Suppose that you are using the playlist_tracks endpoint to get full details of the tracks of a playlist:

    pub async fn playlist_tracks<L: Into<Option<u32>>, O: Into<Option<u32>>>(
        &self,
        playlist_id: &str,
        fields: Option<&str>,
        limit: L,
        offset: O,
        market: Option<Country>,
    ) -> ClientResult<Page<PlaylistItem>> {

And the page gives information about the next one though a URL like this:

{
  "next": "https://api.spotify.com/v1/albums/6akEvsycLGftJxYudPjmqK/tracks?offset=2&limit=2",
}

For now, you have to parse the url and extract limit and offset parameters, and recall the playlist_tracks endpoint with setting limit to 2 and offset to 2.

I know it's a pity that it's not an elegant and ergonomic solution, probably this could solve the problem you meet :(

<!-- gh-comment-id:774571540 --> @ramsayleung commented on GitHub (Feb 7, 2021): Suppose that you are using the `playlist_tracks` endpoint to get full details of the tracks of a playlist: ```rust pub async fn playlist_tracks<L: Into<Option<u32>>, O: Into<Option<u32>>>( &self, playlist_id: &str, fields: Option<&str>, limit: L, offset: O, market: Option<Country>, ) -> ClientResult<Page<PlaylistItem>> { ``` And the page gives information about the next one though a URL like this: ```json { "next": "https://api.spotify.com/v1/albums/6akEvsycLGftJxYudPjmqK/tracks?offset=2&limit=2", } ``` For now, you have to parse the url and extract `limit` and `offset` parameters, and recall the `playlist_tracks` endpoint with setting `limit` to 2 and `offset` to 2. I know it's a pity that it's not an elegant and ergonomic solution, probably this could solve the problem you meet :(
Author
Owner

@JojiiOfficial commented on GitHub (Feb 7, 2021):

This sure helps for now, I'm really looking forward to #166 getting finished and merged. Thank you.

<!-- gh-comment-id:774675525 --> @JojiiOfficial commented on GitHub (Feb 7, 2021): This sure helps for now, I'm really looking forward to #166 getting finished and merged. Thank you.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/rspotify#63
No description provided.