# Quickstart: MusicAPI Core
URL: https://musicapi.com/docs/get-started/quickstart-core.md

> Get your API keys, connect one test user through the hosted sign-in, and read their playlists. About five minutes.

Product: MusicAPI Core. Section: Get started.

You get your keys, connect your own music account as a test user, and read its playlists with one API call.

> **Signed in to the docs?:** Sign in with your dashboard account (top right). The examples on this page then show your own slug, Client ID and return URL. Your Client Secret never shows on this site.

1. **Create an account**

   Sign up at [app.musicapi.com/admin/signup](https://app.musicapi.com/admin/signup). Pick what you build: **integrating** music services into your app, or **transferring** libraries into your service. See [Sandbox and going live](https://musicapi.com/docs/get-started/sandbox-and-going-live.md) for what each choice turns on.
2. **Copy your API keys**

   Open **API & webhooks** in the dashboard. Under **API keys**, create a key and copy its Client ID and Client Secret. The values show only once. Keep the secret on your server only.
3. **Add a return URL**

   Open **Settings** and add an **Accepted Return URL**: the page of your app that the user comes back to after the sign-in. For a first test, any URL you control works, for example `http://localhost:3000/callback`.
4. **Turn on one service**

   Open **Integrations** and enable a service, for example Spotify. A `transferring` sign-up has ready-made integrations. An `integrating` sign-up adds its own developer app first: see [Set up Spotify](https://musicapi.com/docs/connect-users/configure-spotify.md).
5. **Connect yourself**

   Open the hosted sign-in in your browser, pick the service and sign in.
6. **Read your playlists**

   Take the `integrationUserUUID` from the callback and call the API.

## 1. Store your keys

Put the two values into the environment of your backend as `MUSICAPI_CLIENT_ID` and `MUSICAPI_CLIENT_SECRET`, from your secret store. Every example on this site reads them from there. Your Client ID is `$MUSICAPI_CLIENT_ID`.

## 2. Open the hosted sign-in

Your account slug goes into the path. The `returnUrl` must match one of your Accepted Return URLs.

```url
https://app.musicapi.com/{slug}?returnUrl={returnUrl}
```

The user picks a service, signs in and comes back to your return URL. The full list of query parameters is in [Start a sign-in](https://musicapi.com/docs/connect-users/start-sign-in.md).

## 3. Read the callback

The return URL gets a `data64` query parameter: base64-encoded JSON. Decode it on your server.

```js
const params = new URL(request.url, "https://example.com").searchParams;
const data = JSON.parse(Buffer.from(params.get("data64"), "base64").toString("utf8"));

if (data.authModel.status !== "success") {
  throw new Error(`Sign-in failed: ${data.authModel.errorType ?? data.authModel.error}`);
}
const integrationUserUUID = data.integrationUserUUID; // store it with your user
```

```python
import base64, json
from urllib.parse import parse_qs, urlparse

query = parse_qs(urlparse(request_url).query)
data = json.loads(base64.b64decode(query["data64"][0]))

if data["authModel"]["status"] != "success":
    raise RuntimeError(f"Sign-in failed: {data['authModel']['errorType'] or data['authModel']['error']}")
integration_user_uuid = data["integrationUserUUID"]  # store it with your user
```

```json
{
  "integration": {
    "type": "spotify",
    "isSuperPrivate": false,
    "returnUrl": "https://api.musicapi.com/callback/spotify"
  },
  "authModel": {
    "uuid": "a1869581-38b2-4268-aee2-a4c2355efeb0",
    "status": "success",
    "error": null,
    "errorType": null
  },
  "integrationUserUUID": "3f0b8c1e-6a4d-4c7a-9a55-2f1e7d9b0c11"
}
```

The `integrationUserUUID` is the id of this connected account. Store it next to your own user.

## 4. Read the playlists

```bash
curl "https://api.musicapi.com/api/3f0b8c1e-6a4d-4c7a-9a55-2f1e7d9b0c11/playlists" \
  -u "$MUSICAPI_CLIENT_ID:$MUSICAPI_CLIENT_SECRET"
```

```js
const auth = Buffer.from(`${process.env.MUSICAPI_CLIENT_ID}:${process.env.MUSICAPI_CLIENT_SECRET}`).toString("base64");
const response = await fetch(`https://api.musicapi.com/api/${integrationUserUUID}/playlists`, {
  headers: { Authorization: `Basic ${auth}` },
});
const { results, nextParam } = await response.json();
```

```python
import os, requests

response = requests.get(
    f"https://api.musicapi.com/api/{integration_user_uuid}/playlists",
    auth=(os.environ["MUSICAPI_CLIENT_ID"], os.environ["MUSICAPI_CLIENT_SECRET"]),
)
page = response.json()
```

```json
{
  "results": [
    {
      "id": "37i9dQZF1DXcBWIGoYBM5M",
      "name": "Road trip",
      "totalItems": 42,
      "imageUrl": "https://images.example.com/road-trip.jpg",
      "isOwner": true
    }
  ],
  "nextParam": "eyJvZmZzZXQiOjUwfQ==",
  "totalItems": 87
}
```

A `nextParam` that is not `null` means there is another page. Send it back as the `nextParam` query parameter. See [Pagination](https://musicapi.com/docs/user-library/overview-and-pagination.md).

> **No account yet?:** Use **Try it** on any endpoint page of the [API reference](https://musicapi.com/docs/reference.md) while signed out. The docs give you a sandbox session for the catalog calls. Choose **Connect your music account** to run the library calls on your own Spotify, Deezer or other account, so you can see real answers before you sign up.

## Next steps

- [Handle the callback](https://musicapi.com/docs/connect-users/handle-callback.md) in production, including failures.
- [Read and write the library](https://musicapi.com/docs/user-library/overview-and-pagination.md): playlists, liked tracks, albums, artists.
- [Handle a 412](https://musicapi.com/docs/get-started/rate-limits-and-errors.md#the-user-must-sign-in-again-412): the user must connect again.
