Skip to content

Commit

Permalink
Add more complete docs on the various catalog info methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilsson committed Mar 28, 2020
1 parent faf8712 commit e69175c
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 107 deletions.
5 changes: 4 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ First, start by checking out the [Getting started guide](/docs/getting-started.m
* [Obtaining an access token using the Client Credentials Flow](/docs/examples/access-token-with-client-credentials-flow.md)
* [Working with scopes](/docs/examples/working-with-scopes.md)
* **Fetching data**
* [Fetching catalog information](/docs/examples/fetching-catalog-information.md)
* [Fetching information about artists](/docs/examples/fetching-artist-information.md)
* [Fetching information about albums](/docs/examples/fetching-album-information.md)
* [Fetching information about tracks](/docs/examples/fetching-track-information.md)
* [Fetching information about podcasts](/docs/examples/fetching-podcast-information.md)
* [Fetching Spotify featured content](/docs/examples/fetching-spotify-featured-content.md)
* [Searching the Spotify catalog](/docs/examples/searching-the-spotify-catalog.md)
* **Managing users**
Expand Down
36 changes: 36 additions & 0 deletions docs/examples/fetching-album-information.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Fetching Information About Albums

There are a few methods for retrieving information about one or more albums from the Spotify catalog. For example, info about a albums's artist or all the tracks on an album.

## Getting info about a single album

```php
$album = $api->getAlbum('ALBUM_ID');

echo '<b>' . $album->name . '</b>';
```

## Getting info about multiple albums

```php
$albums = $api->getAlbums([
'ALBUM_ID',
'ALBUM_ID',
]);

foreach ($albums->albums as $album) {
echo '<b>' . $album->name . '</b> <br>';
}
```

## Getting all tracks on an album

```php
$tracks = $api->getAlbumTracks('ALBUM_ID');

foreach ($tracks->items as $track) {
echo '<b>' . $track->name . '</b> <br>';
}
```

Please see the [method reference](/docs/method-reference/SpotifyWebAPI.md) for more available options for each method.
72 changes: 72 additions & 0 deletions docs/examples/fetching-artist-information.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Fetching Information About Artists

There are a few methods for retrieving information about one or more albums from the Spotify catalog. For example, info about a single artist or an artist's top tracks in a country.

## Getting info about a single artist

```php
$artist = $api->getArtist('ARTIST_ID');

echo '<b>' . $artist->name . '</b>';
```

## Getting info about multiple artists

```php
$artists = $api->getArtists([
'ARTIST_ID',
'ARTIST_ID',
]);

foreach ($artists->artists as $artist) {
echo '<b>' . $artist->name . '</b> <br>';
}
```

## Getting an artist's albums

```php
$albums = $api->getArtistAlbums('ARTIST_ID');

foreach ($albums->items as $album) {
echo '<b>' . $album->name . '</b> <br>';
}
```

## Getting an artist's related artists

```php
$artists = $api->getArtistRelatedArtists('ARTIST_ID');

foreach ($artists->artists as $artist) {
echo '<b>' . $artist->name . '</b> <br>';
}
```

## Getting an artist’s top tracks in a country

```php
$tracks = $api->getArtistTopTracks('ARTIST_ID', [
'country' => 'se',
]);

foreach ($tracks->tracks as $track) {
echo '<b>' . $track->name . '</b> <br>';
}
```

## Getting recommendations based on artists

```php
$seedArtist = ['ARTIST_ID', 'ARTIST_ID'];

$recommendations = $api->getRecommendations([
'seed_artists' => $seedArtist,
]);

print_r($recommendations);
```

It's also possible to fetch recommendations based on genres and tracks, see the [Spotify docs](https://developer.spotify.com/documentation/web-api/reference/browse/get-recommendations/) for more info.

Please see the [method reference](/docs/method-reference/SpotifyWebAPI.md) for more available options for each method.
106 changes: 0 additions & 106 deletions docs/examples/fetching-catalog-information.md

This file was deleted.

57 changes: 57 additions & 0 deletions docs/examples/fetching-podcast-information.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Fetching Information About Podcasts

There are a few methods for retrieving information about one or more podcasts from the Spotify catalog. For example, the description of a podcast or all of a podcast's episodes.

## Getting info about a single podcast show

```php
$show = $api->getShow('SHOW_ID');

echo '<b>' . $show->name . '</b>';
```

## Getting info about multiple podcast shows

```php
$shows = $api->getShows([
'SHOW_ID',
'SHOW_ID',
]);

foreach ($shows->shows as $show) {
echo '<b>' . $show->name . '</b> <br>';
}
```

## Getting info about a single podcast episode

```php
$episode = $api->getEpisode('EPISODE_ID');

echo '<b>' . $episode->name . '</b>';
```

## Getting info about multiple podcast episodes

```php
$episodes = $api->getEpisodeS([
'EPISODE_ID',
'EPISODE_ID',
]);

foreach ($episodes->episodes as $episode) {
echo '<b>' . $episode->name . '</b> <br>';
}
```

## Getting a podcast show's episodes

```php
$episodes = $api->getShowEpisodes('SHOW_ID');

foreach ($episodes->items as $episode) {
echo '<b>' . $episode->name . '</b> <br>';
}
```

Please see the [method reference](/docs/method-reference/SpotifyWebAPI.md) for more available options for each method.
48 changes: 48 additions & 0 deletions docs/examples/fetching-track-information.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Fetching Information About Tracks

There are a few methods for retrieving information about one or more albums from the Spotify catalog. For example, info about a track's artist or recommendations on similar tracks.

## Getting info about a single track

```php
$track = $api->getTrack('TRACK_ID');

echo '<b>' . $track->name . '</b> by <b>' . $track->artists[0]->name . '</b>';
```

## Getting info about multiple tracks

```php
$tracks = $api->getTracks([
'TRACK_ID',
'TRACK_ID',
]);

foreach ($tracks->tracks as $tracks) {
echo '<b>' . $track->name . '</b> by <b>' . $track->artists[0]->name . '</b> <br>';
}
```

## Getting the audio analysis of a track

```php
$analysis = $api->getAudioAnalysis('TRACK_ID');

print_r($analysis);
```

## Getting recommendations based on tracks

```php
$seedTracks = ['TRACK_ID', 'TRACK_ID'];

$recommendations = $api->getRecommendations([
'seed_tracks' => $seedTracks,
]);

print_r($recommendations);
```

It's also possible to fetch recommendations based on genres and tracks, see the [Spotify docs](https://developer.spotify.com/documentation/web-api/reference/browse/get-recommendations/) for more info.

Please see the [method reference](/docs/method-reference/SpotifyWebAPI.md) for more available options for each method.

0 comments on commit e69175c

Please sign in to comment.