tekore

Package

  • Release notes
  • Reference

Guide

  • Getting started
  • Authorisation guide
  • Advanced usage
  • Examples
    • Artist follower
    • Async server
    • Authenticating server
    • Creating local scripts
    • Discord bot
    • Snippets
      • Albums of user’s top artist
      • Analyse track from playlist
      • Follow with a search
      • Follow category playlist
      • Play saved album
      • Recommended tracks playlist
      • Related artists of user’s top artist
      • Scrape playlist artists
      • Tracks of a new release
  • Additional resources
tekore
  • Examples
  • Snippets
  • Follow with a search
  • View page source

Follow with a search

The following script searches for an artist and prompts the user to follow the first match.

It assumes that your credentials are saved in the environment.

import tekore as tk

conf = tk.config_from_environment()
scope = tk.scope.user_follow_modify
token = tk.prompt_for_user_token(*conf, scope=scope)
spotify = tk.Spotify(token)

search = input('Search for an artist: ')
artists, = spotify.search(search, types=('artist',), limit=1)
artist = artists.items[0]
follow = input(f'Follow {artist.name}? (y/n) ')

if follow.lower() == 'y':
    spotify.artists_follow([artist.id])
    print(f'{artist.name} followed.')
else:
    print('Follow cancelled.')
Previous Next

© Copyright 2019-2026, Felix Hildén.

Built with Sphinx using a theme provided by Read the Docs.