[GH-ISSUE #218] Question about Country Code and Episode Search #153

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

Originally created by @ghost on GitHub (Jan 24, 2021).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/218

Hi Jonathan,

I notice that when I run a search for an episode, that records are returned where the language of that record is de for example.

This is my sample code:

// @@@@@@@@@@@@@@@ CALL THE API @@@@@@@@@@@@@@@

$options = ['return_assoc' => true];
$api = new SpotifyWebAPI\SpotifyWebAPI($options);	
$api->setAccessToken($accessToken);

// @@@@@@@@@@@@@@@ search @@@@@@@@@@@@@@@

try {
    $search_options = ['offset' => 0,'limit' => $limit,'market' => 'from_token', 'include_external' => 'audio'];
    $search = $api->search("saturday live","episode",$search_options);
} catch (SpotifyWebAPI\SpotifyWebAPIException $e) {
	header('Location:index.php');
	exit;
}

I have reviewed the Spotify Docs which says:

market

An ISO 3166-1 alpha-2 country code or the string from_token.

If a country code is specified, only content that is playable in that market is returned.

Note:

- Playlist results are not affected by the market parameter.
- If market is set to from_token, and a valid access token is specified in the request header, only content playable in the country associated with the user account, is returned.
- Users can view the country that is associated with their account in the account settings. A user must grant access to the user-read-private scope prior to when the access token is issued.

My country is set to GB, so I have tested having search options as:

$search_options = ['offset' => 0,'limit' => $limit,'market' => 'from_token', 'include_external' => 'audio'];

And also:

$search_options = ['offset' => 0,'limit' => $limit,'market' => 'GB', 'include_external' => 'audio'];

However, when e.g. searching for saturday live the top results are episodes with language values of de

e.g. first result has audio_preview_url of https://p.scdn.co/mp3-preview/fe5cf4286b8e67065b41546424c6dcb463cf0c09
and description of "Wir sind zurück! Und besprechen die dinge die uns wirklich am herzen liegen wie zu Beispiel reich sein und Dampfduschen!", and language of "de".

The Docs says Playlist results are not affected by the market parameter. but doesn't mention episodes not being affected by the market parameter.

Do you think this an issue with this library, or the wider API?

Thanks

Jim

Originally created by @ghost on GitHub (Jan 24, 2021). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/218 Hi Jonathan, I notice that when I run a search for an episode, that records are returned where the language of that record is `de` for example. This is my sample code: ``` // @@@@@@@@@@@@@@@ CALL THE API @@@@@@@@@@@@@@@ $options = ['return_assoc' => true]; $api = new SpotifyWebAPI\SpotifyWebAPI($options); $api->setAccessToken($accessToken); // @@@@@@@@@@@@@@@ search @@@@@@@@@@@@@@@ try { $search_options = ['offset' => 0,'limit' => $limit,'market' => 'from_token', 'include_external' => 'audio']; $search = $api->search("saturday live","episode",$search_options); } catch (SpotifyWebAPI\SpotifyWebAPIException $e) { header('Location:index.php'); exit; } ``` I have reviewed [the Spotify Docs](https://developer.spotify.com/documentation/web-api/reference/#category-search) which says: ``` market An ISO 3166-1 alpha-2 country code or the string from_token. If a country code is specified, only content that is playable in that market is returned. Note: - Playlist results are not affected by the market parameter. - If market is set to from_token, and a valid access token is specified in the request header, only content playable in the country associated with the user account, is returned. - Users can view the country that is associated with their account in the account settings. A user must grant access to the user-read-private scope prior to when the access token is issued. ``` My country is set to GB, so I have tested having search options as: `$search_options = ['offset' => 0,'limit' => $limit,'market' => 'from_token', 'include_external' => 'audio'];` And also: `$search_options = ['offset' => 0,'limit' => $limit,'market' => 'GB', 'include_external' => 'audio'];` However, when e.g. searching for `saturday live` the top results are episodes with language values of `de` e.g. first result has `audio_preview_url` of https://p.scdn.co/mp3-preview/fe5cf4286b8e67065b41546424c6dcb463cf0c09 and `description` of "Wir sind zurück! Und besprechen die dinge die uns wirklich am herzen liegen wie zu Beispiel reich sein und Dampfduschen!", and `language` of "de". The Docs says `Playlist results are not affected by the market parameter.` but doesn't mention episodes not being affected by the market parameter. Do you think this an issue with this library, or the wider API? Thanks Jim
kerem 2026-02-27 19:26:20 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jwilsson commented on GitHub (Jan 24, 2021):

Hi Jim!
I don't think the market parameter will actually control the language of the results returned (I'm in Sweden and I'm getting a mix of English and German results too) but only limit the results to items actually playable in that country.

What we'd really want is a locale parameter like the featured playlists endpoint. I'd post a suggestion for it on their developer forum and hope they implement something like it.

Cheers,
Jonathan

<!-- gh-comment-id:766408429 --> @jwilsson commented on GitHub (Jan 24, 2021): Hi Jim! I don't think the `market` parameter will actually control the language of the results returned (I'm in Sweden and I'm getting a mix of English and German results too) but only limit the results to items actually playable in that country. What we'd really want is a `locale` parameter like the [featured playlists](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-featured-playlists) endpoint. I'd post a suggestion for it on [their developer forum](https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer) and hope they implement something like it. Cheers, Jonathan
Author
Owner

@ghost commented on GitHub (Jan 24, 2021):

As ever, thank you Jonathan, you are a big help.

Jim

<!-- gh-comment-id:766410061 --> @ghost commented on GitHub (Jan 24, 2021): As ever, thank you Jonathan, you are a big help. Jim
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#153
No description provided.