# Spotify Bulk Text-to-URI Matcher (`fanndev/spotify-uri-matcher`) Actor

Paste a list of songs as plain text - 'Title - Artist', 'Artist - Title', 'Title by Artist' - and get the exact Spotify URI and URL for each, with a confidence score. Rejects bad matches instead of guessing, and writes a ready-to-import URI list. No Spotify account or API key needed.

- **URL**: https://apify.com/fanndev/spotify-uri-matcher.md
- **Developed by:** [Faisal Ahdan naufal](https://apify.com/fanndev) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.40 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Spotify Bulk Text-to-URI Matcher

Paste a list of songs as plain text and get the exact **`spotify:track:` URI**
and open.spotify.com link for each — with a confidence score, and with bad
matches **rejected instead of guessed**.

Built for developers, setlist managers and curators automating playlist
building from outside sources: a Billboard chart, a YouTube ranking, a
festival lineup, a radio log, a spreadsheet a promoter emailed over.

No Spotify account, no API key, no browser.

***

### The problem this actually solves

Spotify's search returns a result for **any** text. Ask it for
`"asdkjh qweoiu zxcvbn"` and it hands back a real song. So a matcher that takes
the first result never fails and is wrong every time the input is — and you
find out when the playlist is already built.

This one scores every candidate against your title and artist and refuses
anything below a threshold you set:

```
exact    1.000  Bohemian Rhapsody - Queen        -> Bohemian Rhapsody   | Queen
exact    1.000  Texas Hold 'Em - Beyoncé         -> TEXAS HOLD 'EM      | Beyoncé
medium   0.814  Golden - HUNTR/X, EJAE, …        -> Golden              | HUNTR/X
low      0.320  asdkjh qweoiu zxcvbn             -> (rejected)
```

Rejected lines keep their best guess and the reason, so you can review rather
than re-run.

***

### Input formats it accepts

All of these work, mixed freely in one paste:

```
Bohemian Rhapsody - Queen
Queen - Bohemian Rhapsody
Beautiful Things by Benson Boone
Lose Control / Teddy Swims
12. Blinding Lights - The Weeknd
Birds of a Feather -- Billie Eilish
Title<TAB>Artist
https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT
```

**Both orders are tried** — `Title - Artist` and `Artist - Title` — and
whichever reads better wins, because neither can be told from the text alone.
Leading track numbers are stripped. A line that is already a Spotify link or
URI is passed straight through without spending a request.

For maximum accuracy, use the structured `tracks` input instead, where title
and artist are separate fields and an optional `durationMs` disambiguates
between recordings of the same song.

***

### Quick start

```json
{
  "queriesText": "Bohemian Rhapsody - Queen\nEspresso - Sabrina Carpenter\nNot Like Us - Kendrick Lamar",
  "minimumMatchScore": "0.70",
  "emitUnmatched": true
}
```

Every run also writes **`matched-uris.txt`** to the key-value store — the
matched URIs, one per line, ready to paste into a playlist importer.

***

### Choosing a threshold

| Setting | Use when |
| --- | --- |
| `0.85` | A wrong URI is worse than a missing one — automated playlist writes |
| `0.70` (default) | Balanced; catches casing, accents and version suffixes |
| `0.55` | You will review near-misses by hand and want maximum recall |

A **title-only** query is capped at `high` however well it scores — several
different recordings share a title, and nothing in the input says which one.

***

### Cost

**One request per line**, plus one to pick up an anonymous token. A 500-track
list is 501 requests. Lines that are already Spotify links cost nothing.

***

### Limits worth knowing

- **ISRC lookup is not supported here.** The search this actor uses does not
  understand ISRC queries — it treats the code as free text and returns
  nonsense. ISRC lookup only works on Spotify's public Web API search, which
  bans by IP for about twenty hours once its small anonymous allowance runs
  out, so it is deliberately not wired in.
- **One song, many ids.** Spotify mints a separate track id per release, so an
  album version, a single version and a remaster are different URIs. Supplying
  `durationMs` is the most reliable way to steer towards the one you mean.
- **Regional availability varies.** A track that exists in one market may be
  missing in another; matching is done against Spotify's global catalogue.
- **Scores are a similarity measure, not a probability.** `0.70` does not mean
  "70% likely correct" — calibrate it against your own list once and keep it.

***

### Output

Every run writes to the Apify dataset, plus `matched-uris.txt`. Set
`exportFormats` to also drop a ready-made `spotify-uri-matches.csv`, `.xlsx`,
`.json` or `.ndjson` into the run's key-value store. The **Needs review** table
view in the Console shows only the rejected lines with their best guesses.

See [CRAWLING_METHOD.md](CRAWLING_METHOD.md) for how the data is obtained.

# Actor input Schema

## `queriesText` (type: `string`):

Paste your list straight in. 'Title - Artist', 'Artist - Title', 'Title by Artist', 'Title / Artist' and tab-separated columns all work, and a leading track number such as '12. ' is ignored. A line that is already a Spotify link or URI is passed straight through without a search.

## `queries` (type: `array`):

The same thing as an array, for callers that already hold a list rather than a blob of text.

## `tracks` (type: `array`):

Objects with title and artist kept apart, which removes the guesswork about which side of the separator is which. Optional album and durationMs sharpen the match further - a duration within two seconds of a candidate raises its score, and one more than thirty seconds out lowers it.

## `minimumMatchScore` (type: `string`):

Between 0 and 1. Anything scoring below this is reported as unmatched, with its best guess attached so you can review it. Raise it towards 0.85 when a wrong URI is worse than a missing one; lower it towards 0.55 when you would rather review near-misses by hand. Spotify returns a result for literally any text, so this threshold is what stops nonsense turning into a confident answer.

## `emitUnmatched` (type: `boolean`):

Keep a row for every input line that did not clear the threshold, carrying its best guess and why it was rejected. Turn this off for a clean matched-only output - but then a dropped line leaves no trace.

## `maxQueries` (type: `integer`):

Ceiling on how many lines a single run processes, so an oversized paste cannot run away. Each line costs one request.

## `exportFormats` (type: `array`):

Besides the dataset, write ready-made files into this run's key-value store. A plain matched-uris.txt is always written regardless of this setting.

## `proxyConfiguration` (type: `object`):

Off by default and genuinely optional. This actor searches through Spotify's web player gateway, which has shown no request ceiling - unlike Spotify's public Web API search, which bans by IP for around twenty hours once tripped. That is exactly why the gateway is used here.

## Actor input object example

```json
{
  "queriesText": "Bohemian Rhapsody - Queen\nBlinding Lights - The Weeknd\nEspresso - Sabrina Carpenter",
  "tracks": [
    {
      "title": "Never Gonna Give You Up",
      "artist": "Rick Astley",
      "durationMs": 213573
    }
  ],
  "minimumMatchScore": "0.70",
  "emitUnmatched": true,
  "maxQueries": 1000,
  "exportFormats": [],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Every input line with its matched track, confidence score and any error records.

## `uriList` (type: `string`):

Plain text file of the matched spotify:track: URIs, one per line, ready to paste into a playlist importer.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "queriesText": `Bohemian Rhapsody - Queen
Blinding Lights - The Weeknd
Espresso - Sabrina Carpenter`,
    "tracks": [
        {
            "title": "Never Gonna Give You Up",
            "artist": "Rick Astley",
            "durationMs": 213573
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("fanndev/spotify-uri-matcher").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "queriesText": """Bohemian Rhapsody - Queen
Blinding Lights - The Weeknd
Espresso - Sabrina Carpenter""",
    "tracks": [{
            "title": "Never Gonna Give You Up",
            "artist": "Rick Astley",
            "durationMs": 213573,
        }],
}

# Run the Actor and wait for it to finish
run = client.actor("fanndev/spotify-uri-matcher").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "queriesText": "Bohemian Rhapsody - Queen\\nBlinding Lights - The Weeknd\\nEspresso - Sabrina Carpenter",
  "tracks": [
    {
      "title": "Never Gonna Give You Up",
      "artist": "Rick Astley",
      "durationMs": 213573
    }
  ]
}' |
apify call fanndev/spotify-uri-matcher --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,fanndev/spotify-uri-matcher"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Zf7m1x7W8MvDxwdWs/builds/ggVOdXaOVG46VmUfa/openapi.json
