mirror of
https://github.com/mintlify/docs.git
synced 2026-09-14 13:35:46 +08:00
65fd3621dc
- Created 111 MDX documentation files - Added 89 API endpoint pages across 14 categories - Included 11 concept guides and 7 tutorials - Configured Mintlify with Spotify branding (#1DB954) - All pages validated successfully
114 lines
3.7 KiB
Plaintext
114 lines
3.7 KiB
Plaintext
---
|
|
title: "Overview"
|
|
description: "Learn the basics of the Spotify Web API and how to get started"
|
|
---
|
|
|
|
# Getting started with the Spotify Web API
|
|
|
|
The Spotify Web API is a RESTful API that provides access to Spotify's music catalog and user data. This guide will help you understand the fundamentals and get started building your first application.
|
|
|
|
## Prerequisites
|
|
|
|
Before you begin, you should have:
|
|
|
|
- A Spotify account (free or premium)
|
|
- Basic understanding of RESTful APIs
|
|
- Familiarity with HTTP requests and JSON
|
|
- Development environment set up for your preferred programming language
|
|
|
|
## Core concepts
|
|
|
|
### Authentication
|
|
|
|
All requests to the Spotify Web API require authentication. You'll need to:
|
|
|
|
1. Register your application to get a Client ID and Client Secret
|
|
2. Choose an appropriate authentication flow
|
|
3. Obtain an access token
|
|
4. Include the token in your API requests
|
|
|
|
Learn more about [authentication flows](/getting-started/authentication-flows).
|
|
|
|
### Authorization scopes
|
|
|
|
Some endpoints require specific permissions called scopes. When requesting access, you must specify which scopes your application needs. For example:
|
|
|
|
- `user-read-private` - Read access to user's subscription details
|
|
- `playlist-modify-public` - Write access to user's public playlists
|
|
- `user-modify-playback-state` - Control playback on user's devices
|
|
|
|
See the complete list of [scopes](/concepts/scopes).
|
|
|
|
### Rate limits
|
|
|
|
The API uses rate limiting to ensure service stability. Your requests may be throttled if you exceed the limits. Always check the rate limit headers in responses and implement appropriate retry logic.
|
|
|
|
Learn more about [rate limits](/concepts/rate-limits).
|
|
|
|
## Your first API call
|
|
|
|
Here's a simple example of making an API call to get information about a track:
|
|
|
|
```bash
|
|
curl -X GET "https://api.spotify.com/v1/tracks/11dFghVXANMlKmJXsNCbNl" \
|
|
-H "Authorization: Bearer {your_access_token}"
|
|
```
|
|
|
|
<Tip>
|
|
Replace `{your_access_token}` with a valid access token from your authentication flow.
|
|
</Tip>
|
|
|
|
The response will contain detailed information about the track in JSON format:
|
|
|
|
```json
|
|
{
|
|
"album": {
|
|
"name": "Album Name",
|
|
"release_date": "2023-01-01"
|
|
},
|
|
"artists": [
|
|
{
|
|
"name": "Artist Name",
|
|
"id": "artist_id"
|
|
}
|
|
],
|
|
"name": "Track Name",
|
|
"duration_ms": 240000,
|
|
"popularity": 75
|
|
}
|
|
```
|
|
|
|
## Best practices
|
|
|
|
<AccordionGroup>
|
|
<Accordion title="Handle errors gracefully">
|
|
Always check response status codes and handle errors appropriately. Implement retry logic for rate limit errors (429) and temporary failures (5xx).
|
|
</Accordion>
|
|
<Accordion title="Cache responses when appropriate">
|
|
Many resources like album metadata don't change frequently. Cache responses to reduce API calls and improve performance.
|
|
</Accordion>
|
|
<Accordion title="Use batch endpoints">
|
|
When retrieving multiple items, use batch endpoints (like `/albums` instead of multiple `/albums/{id}` calls) to minimize requests.
|
|
</Accordion>
|
|
<Accordion title="Respect user privacy">
|
|
Only request the scopes you need and clearly explain why you need access to user data.
|
|
</Accordion>
|
|
</AccordionGroup>
|
|
|
|
## Next steps
|
|
|
|
<CardGroup cols={2}>
|
|
<Card title="Authentication flows" icon="key" href="/getting-started/authentication-flows">
|
|
Choose the right authentication method for your app
|
|
</Card>
|
|
<Card title="Making API calls" icon="code" href="/getting-started/making-api-calls">
|
|
Learn how to structure and make API requests
|
|
</Card>
|
|
<Card title="Tutorial" icon="graduation-cap" href="/tutorials/getting-started">
|
|
Follow a complete tutorial to build your first app
|
|
</Card>
|
|
<Card title="API reference" icon="book" href="/api-reference/overview">
|
|
Browse all available endpoints
|
|
</Card>
|
|
</CardGroup>
|