---
title: "Identify a song from a link with an iPhone Shortcut"
description: "Build an iPhone Shortcut that sends a link to an audio file to AudD from the share sheet and shows the artist, title and song link, with the no-match and error cases handled."
slug: "/resources/integrations/ios-shortcuts"
section: "integrations"
keywords: [audd, iphone shortcut, shortcuts app, ios, identify song from link, get contents of url, share sheet, music recognition]
---

# Identify a song from a link with an iPhone Shortcut

You can build a Shortcut that recognizes music from links on your iPhone. When you share a link to an audio file with it, it sends the link to AudD's Music Recognition API with your token. AudD's response will contain the title and artist of the song, and a link to the song's lis.tn page. The Shortcut shows them in an alert.

If the music is playing around you, the Recognize Music button that's built into iPhone is the better tool. This Shortcut is for a song in a file that you have a link to, and it uses your own AudD account.

## What you need

- An API token. You can get a token from our [API Dashboard](https://dashboard.audd.io). For a first try, the public `test` token allows 10 requests a day.
- A link to an audio file (a link to a video file sometimes works too). Our standard endpoint is for short clips: it recognizes the first 12 seconds of the audio.

## The finished Shortcut

These are the actions you'll build, from top to bottom:

1. The input action: URLs from the share sheet, or Get Clipboard if there's no input
2. URL: `https://api.audd.io/`
3. Get Contents of URL: POST, with a Form request body: `api_token` and `url`
4. Get Value for `status` in Contents of URL
5. If Dictionary Value is not `success`: Get Value for `error.error_message` in Contents of URL, Show Alert, Stop Shortcut
6. End If
7. Get Value for `result.song_link` in Contents of URL
8. If Dictionary Value contains `lis.tn`: Get Value for `result.artist`, Get Value for `result.title`, Show Alert with the song
9. Otherwise: Show Alert that there's no match
10. End If

## Build it

### Create the Shortcut and let it take links

1. Open the Shortcuts app on your iPhone and tap the Add button to create a new shortcut.
2. Give it a name: tap New Shortcut, tap Rename, type the name, then tap the back button.
3. To make the shortcut appear in the share sheet, open Details and turn on Show in Share Sheet, then tap Done. A new action appears at the beginning of the shortcut: the input action.
4. To accept only links, tap Any in the input action, tap Clear, turn on URLs, and tap Done.
5. To use a copied link when you run it from the Shortcuts app, tap Continue in the same action and choose Get Clipboard.

### Send the link to AudD

1. Add the URL action, and type `https://api.audd.io/` in it. To add an action, swipe up on the search field at the bottom of the screen, then choose the action.
2. Add the Get Contents of URL action after it. It takes the URL from the action before it.
3. In Get Contents of URL, tap Show More, and change the method to POST. A new parameter called Request Body appears. Set it to Form.
4. Add a text field to the form with the key `api_token`, and type your token (`your-api-token` here) as its value.
5. Add a second text field with the key `url`. Tap its value, then tap Shortcut Input in the Variables bar. You may need to swipe left to see it.

### Stop on an error

All the responses contain the `status` field that equals either `success` if the request was successfully processed or `error` if there's been an error. The Shortcut checks it first.

1. Add Get Dictionary Value, and set the key to `status`. It reads the output of Get Contents of URL.
2. Add an If action. Its input is the Dictionary Value from the action before it. Set the condition to is not, and type `success`.
3. Inside the If, add Get Dictionary Value with the key `error.error_message`. Set its Dictionary to the output of Get Contents of URL: tap the parameter and choose the Contents of URL variable.
4. Add Show Alert after it. Type `AudD returned an error:` in its text, then tap Select Variable and tap the Dictionary Value under the action before it.
5. Add Stop Shortcut after Show Alert. Leave the Otherwise part of this If empty.

### Show the song, or say there's no match

If the server has successfully processed the request, but there are no matches, the `result` field is `null`. So the Shortcut checks the `song_link` before it reads the name: every match has a link to the song's lis.tn page.

1. After End If, add Get Dictionary Value with the key `result.song_link`, and set its Dictionary to Contents of URL.
2. Add an If action with the condition contains, and type `lis.tn`.
3. Inside the If, add two Get Dictionary Value actions with the keys `result.artist` and `result.title`. Set the Dictionary of both to Contents of URL.
4. Add Show Alert. In its text, use Select Variable to insert the artist, the title, and the song link: tap the blue token under each Get Dictionary Value action.
5. After Otherwise, add Show Alert with a message such as `No match. AudD recognizes the first 12 seconds of the file.`
6. Tap Done.

## Try it

1. In the `api_token` field, type `test` instead of your token for now.
2. Copy this link: `https://audd.tech/example.mp3`.
3. Open the shortcut in the shortcut editor and tap the Run button. If a Privacy dialog appears, choose Allow Once or Always Allow.
4. You should see an alert with Tears For Fears, Everybody Wants To Rule The World, and `https://lis.tn/NbkVb`.
5. Replace `test` with your own token.

To identify a song from a link in Safari or another app, tap the Share button, scroll down, and pick the Shortcut. A notification shows the progress of each action while the Shortcut runs.

## What AudD sends back

### A match

The response is JSON. The Shortcut reads `status`, then `artist`, `title` and `song_link` inside `result`:

```json
{
  "status": "success",
  "result": {
    "artist": "Tears For Fears",
    "title": "Everybody Wants To Rule The World",
    "album": "Songs From The Big Chair",
    "release_date": "2014-11-10",
    "label": "UMC (Universal Music Catalogue)",
    "timecode": "00:56",
    "song_link": "https://lis.tn/NbkVb"
  }
}
```

### When `result` is null

If there are no matches, the response looks like this:

```json
{
  "status": "success",
  "result": null
}
```

The clip might be mostly speech or silence, or the song might not be in our database. The standard endpoint only recognizes the first 12 seconds, so if the song starts later in the file, it won't be found.

### When `status` is `error`

If there's been an error, `status` is `error`, and the API returns an explanation of what happened:

```json
{
  "status": "error",
  "error": {
    "error_code": 900,
    "error_message": "Recognition failed: authorization failed: the provided api_token is incorrect, invalid, or inactive. Please check the status of your account on dashboard.audd.io: it needs to have either a trial or an active subscription."
  }
}
```

The common errors are about the token (it's wrong, the account has no trial or plan, or the `test` token has used its 10 requests for the day) and about the link (AudD can't download it, or it isn't a file AudD can read). The [Error codes reference](/resources/reference/errors) lists them.

## Keep your token private

The Shortcut includes your API token, in the `api_token` field of the Get Contents of URL action. You can share other shortcuts with your friends, but please don't share this one, and don't post screenshots of that action. Anyone who has your token can send requests with it. If you've already shared it with an iCloud link, [stop sharing it](https://support.apple.com/guide/shortcuts/share-shortcuts-apdf01f8c054/ios).

For a leaked token, rotate the token in the [dashboard](https://dashboard.audd.io), copy the new one, and paste it into the `api_token` field of the Shortcut. The old token stops working immediately.

A token on your own iPhone is fine for your own use, but an app you give to other people shouldn't contain one; see [Keeping your API token on the server](/resources/concepts/keeping-your-token-server-side).

## What it costs

Each run sends 1 request. New accounts get a free trial of 300 requests where available. You can find the usage stats for your API token on [dashboard.audd.io](https://dashboard.audd.io), and all the plans on our [pricing page](https://audd.io/pricing/).

---

**Related**

- [Keeping your API token on the server](/resources/concepts/keeping-your-token-server-side)
- [Recognition result fields](/resources/reference/result-fields)
- [The song_link (lis.tn) universal music link](/resources/concepts/lisn-song-link)
- [Error codes reference](/resources/reference/errors)
- [API reference](https://docs.audd.io)

## Sitemap

See the [resources sitemap](https://audd.io/resources/sitemap.md) for every guide and the [glossary](https://audd.io/resources/reference/glossary.md) for AudD terms.
