# Embed player
URL: https://musicapi.com/docs/reference/create-embed-player.md

`POST https://api.musicapi.com/public/embed/url`

Section: Search and match the catalog.
Product: MusicAPI Core.
Auth: none.

This endpoint allows you to send a request with a share URL to any track, artist, or album from music service, and it will generate an embed player code (an `iframe`) for that resource, enabling easy embedding of the music player on a website or application.

This endpoint, in addition to the iframe will return available sizes of that music player, so if you would like to change the default size, you need to insert the selected height in two places: into the `height` property of a returned iframe as well as in the URL height param within that iframe `src` property.

## Request body

`application/json`, required.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | yes | URL to track, album or artist of music service |

## Response 200

ok

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `embedCode` | string | yes | HTML iframe code used to embed music player |
| `embedUrl` | string | yes | URL used as the source of the iframe |
| `sizes` | EmbedPlayerSize[] | yes | Available sizes for iframe |
| `sizes[].height` | number | yes |  |
| `sizes[].label` | string | yes |  |
| `defaultSize` | EmbedPlayerSize | yes |  |
| `defaultSize.height` | number | yes |  |
| `defaultSize.label` | string | yes |  |

```json
{
  "embedCode": "<iframe title='embed-player' width='100%' height='152' src='https://api.musicapi.com/public/embed/track/28?height=152' allow='encrypted-media' style='border:none;position:relative;overflow:hidden;max-width:100%;'/>",
  "embedUrl": "https://api.musicapi.com/public/embed/track/55754?height=152",
  "sizes": [
    {
      "height": 152,
      "label": "Medium"
    }
  ],
  "defaultSize": {
    "height": 152,
    "label": "Medium"
  }
}
```

## Example

```bash
curl -X POST "https://api.musicapi.com/public/embed/url" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://open.spotify.com/track/0pqnGHJpmpxLKifKRmU6WP"}'
```
