[GH-ISSUE #97] getUserPlaylistTracks - only 100 Tracks #52

Closed
opened 2026-02-27 19:25:48 +03:00 by kerem · 2 comments
Owner

Originally created by @pscheich on GitHub (Sep 5, 2017).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/97

Hey,
the function getUserPlaylistTracks returns only the first 100 Tracks from a playlist.
The default and max value for limit is 100.
Do I have to check if there is more by myself to get all tracks from a playlist?

limit Optional. The maximum number of tracks to return. Default: 100. Minimum: 1. Maximum: 100.

Greetz
ps

Originally created by @pscheich on GitHub (Sep 5, 2017). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/97 Hey, the function getUserPlaylistTracks returns only the first 100 Tracks from a playlist. The default and max value for limit is 100. Do I have to check if there is more by myself to get all tracks from a playlist? > limit | Optional. The maximum number of tracks to return. Default: 100. Minimum: 1. Maximum: 100. -- | -- Greetz ps
kerem 2026-02-27 19:25:48 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jwilsson commented on GitHub (Sep 5, 2017):

Hi!
Yeah, you can check the next field on each response. If it isn't null there are more results.

For example:

$offset = 0;
$tracks = [];
$hasNext = true;

do {
    $response = $api->getUserPlaylistTracks('USER_ID', 'PLAYLIST_ID', [
        'offset' => $offset,
    ]);

    $offset += 100;
    $tracks = array_merge($tracks, $response->items);
    $hasNext = $response->next;
} while ($hasNext);

print_r($tracks);

Hope this helps!

<!-- gh-comment-id:327265071 --> @jwilsson commented on GitHub (Sep 5, 2017): Hi! Yeah, you can check the `next` field on each response. If it isn't `null` there are more results. For example: ```php $offset = 0; $tracks = []; $hasNext = true; do { $response = $api->getUserPlaylistTracks('USER_ID', 'PLAYLIST_ID', [ 'offset' => $offset, ]); $offset += 100; $tracks = array_merge($tracks, $response->items); $hasNext = $response->next; } while ($hasNext); print_r($tracks); ``` Hope this helps!
Author
Owner

@pscheich commented on GitHub (Sep 6, 2017):

Hey,

thanks for this fast reply, I will use your code.

Thank you.

<!-- gh-comment-id:327623849 --> @pscheich commented on GitHub (Sep 6, 2017): Hey, thanks for this fast reply, I will use your code. 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/spotify-web-api-php#52
No description provided.