Skip to content

Search Artists

Searches Spotify's artist catalog by name. Use it to resolve a name typed by a human into a Spotify artist ID, which you then pass to add_artist or to Create Link.

This searches Spotify, not your ArtistHub account. To list the artists you already manage, use Get Artists.

Request

graphql
query SearchArtists($name: String!) {
  search_artists(name: $name) {
    data
  }
}

Variables:

json
{ "name": "Example Artist" }

Arguments

ArgumentTypeDescription
nameString!Artist name to search for.

Response

search_artists returns a single field, data, containing a JSON-encoded string of Spotify artist objects. Parse it before use.

json
{
  "data": {
    "search_artists": {
      "data": "[{\"id\":\"1uNFoZAHBGtllmzznpCI3s\",\"name\":\"Example Artist\",\"images\":[...],\"followers\":{\"total\":48210},\"genres\":[\"pop\"]}]"
    }
  }
}
js
const artists = JSON.parse(response.data.search_artists.data);
const spotifyId = artists[0].id;

Each element is a Spotify artist object as returned by Spotify's search API, so the useful fields are id, name, images, followers.total, genres, and popularity.

INFO

Several ArtistHub resolvers wrap third-party payloads this way — a single data field holding a JSON string. search_artists, meta, search_numbers, link_totals, and link_stats all follow this pattern. Table-backed fields never do; they return typed objects.

Typical flow

graphql
# 1. Find the Spotify artist
query { search_artists(name: "Example Artist") { data } }
graphql
# 2. Attach it to your account
mutation AddArtist($spotify_id: String!) {
  add_artist(artist_spotify_id: $spotify_id) {
    token
    user {
      artists { id name spotify_id }
    }
  }
}

add_artist returns a fresh Auth payload. Replace your stored token with the new one — it carries updated access to the artist you just added.

FieldTypePurpose
get_releases_by_spotify_id(spotify_id: String!): ReleasesqueryCatalog for any Spotify artist, whether or not you manage them.
get_artist_releases(artist_id: String!): ReleasesqueryCatalog for an ArtistHub artist you manage. See Artist Releases.
get_spotify_preview_url(link: String): SpotifyPreviewUrlquery30-second preview URL for a Spotify track.
get_long_spotify_url_from_shortened(link: String): SpotifyPreviewUrlqueryExpands a spotify.link short URL into a full open.spotify.com URL.

That last one is worth knowing about: create_link requires a full open.spotify.com URL and rejects shortened spotify.link URLs. If your input comes from a share sheet, expand it first.

ArtistHub developer documentation