API Recipes

Get Top Tracks of an Artist

This recipe was an interactive walkthrough in the previous portal. Each step below names the API call it makes; open it in the API Reference to try it.

Getting Started

Introduction

Welcome to this API Recipe, where we'll show you how to retrieve the top tracks of an artist after searching the artist. This API Recipe will help you navigate through the API endpoints effectively, ensuring you can access the desired information efficiently.

Details

During this walkthrough, we'll be utilizing two key endpoints to achieve our goal:

  1. Search Artist: This endpoint allows us to search for an artist based on their name. This search endpoint can also filter results for albums, playlists, tracks, shows, episodes and audiobooks.

  2. Get an Artist's Top Tracks: Once we've identified the desired artist, we'll use this endpoint to fetch the top tracks for that artist. This step requires passing the Artist ID obtained from the previous endpoint.

Note: For this API Recipe, we'll automatically pass the Artist ID of the first artist fetched in Step 1. However, you can update the Artist ID if needed.

By following this API Recipe, you'll gain a deeper understanding of how to efficiently retrieve an artists top track, even without prior knowledge of its Artist ID. Let's dive in!

Step 1: Search Artist

Description

This endpoint allows us to search for an artist based on their name. This search endpoint can also filter results for albums, playlists, tracks, shows, episodes and audiobooks.

API call: search

Example arguments:

{
            q: "artist:Drake",
            type: ["artist"],
            limit: 10,
            offset: 0,
            market: null,
          }

Description

Once we've identified the desired artist, we'll use this endpoint to fetch the top tracks for that artist. This step requires passing the Artist ID obtained from the previous endpoint.

Note: For this API Recipe, we'll automatically pass the Artist ID of the first artist fetched in Step 1. However, you can update the Artist ID if needed.

API call: get-an-artists-top-tracks

Example arguments:

{
            id: artistId,
            market: null,
          }

On this page