{"id":28265653,"url":"https://github.com/frostbreker/spotify-private-api","last_synced_at":"2026-01-25T20:17:37.686Z","repository":{"id":210569575,"uuid":"726857063","full_name":"FrostBreker/spotify-private-api","owner":"FrostBreker","description":"This package provides a simple way to interact with Spotify's private API. It includes methods to fetch track information and play count.","archived":false,"fork":false,"pushed_at":"2024-04-08T16:46:26.000Z","size":29,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-15T07:48:23.283Z","etag":null,"topics":["api","golang","scraper","spotify"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FrostBreker.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.MD","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-12-03T15:55:39.000Z","updated_at":"2025-03-22T09:23:03.000Z","dependencies_parsed_at":"2024-04-08T17:49:34.706Z","dependency_job_id":"2fe0e087-796c-4ce6-a1cd-85170af39f84","html_url":"https://github.com/FrostBreker/spotify-private-api","commit_stats":null,"previous_names":["frostbreker/spotify-private-api"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/FrostBreker/spotify-private-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrostBreker%2Fspotify-private-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrostBreker%2Fspotify-private-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrostBreker%2Fspotify-private-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrostBreker%2Fspotify-private-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FrostBreker","download_url":"https://codeload.github.com/FrostBreker/spotify-private-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrostBreker%2Fspotify-private-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28757732,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T16:32:25.380Z","status":"ssl_error","status_checked_at":"2026-01-25T16:32:09.189Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","golang","scraper","spotify"],"created_at":"2025-05-20T13:13:27.599Z","updated_at":"2026-01-25T20:17:37.680Z","avatar_url":"https://github.com/FrostBreker.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spotify Private API Go Package\n\n[![Go Version](https://img.shields.io/badge/Go-1.24+-blue.svg)](https://golang.org)\n[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.MD)\n[![Tests](https://github.com/FrostBreker/spotify-private-api/actions/workflows/tests.yml/badge.svg)](https://github.com/FrostBreker/spotify-private-api/actions/workflows/tests.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/FrostBreker/spotify-private-api)](https://goreportcard.com/report/github.com/FrostBreker/spotify-private-api)\n\nA Go package for accessing Spotify data by scraping public pages. No authentication or API tokens required.\n\n## Features\n\n- 🎵 **Track Information** - Track name, duration, album, artists, and cover art\n- 🎤 **Artist Profiles** - Artist stats, biography, followers, and monthly listeners\n- 💿 **Album Details** - Album info with track listings and artwork\n- 🔓 **No Authentication** - Works without any API tokens or OAuth\n- 🌐 **Browser-Like Requests** - Uses TLS fingerprinting to mimic real browsers\n- ⚡ **Context Support** - All operations support cancellation and timeouts\n- 🧪 **Fully Testable** - Mock support for comprehensive unit testing\n- 🛡️ **Type-Safe Errors** - Custom error types for precise error handling\n\n## Installation\n\n```bash\ngo get github.com/FrostBreker/spotify-private-api\n```\n\n**Requirements:** Go 1.24 or higher\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n\n    spotify \"github.com/FrostBreker/spotify-private-api\"\n)\n\nfunc main() {\n    client := spotify.NewClient()\n    ctx := context.Background()\n\n    // Fetch a track\n    track, err := client.FetchTrack(ctx, \"4cOdK2wGLETKBW3PvgPWqT\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Printf(\"Track: %s\\n\", track.Data.TrackUnion.Name)\n    fmt.Printf(\"Artist: %s\\n\", track.Data.TrackUnion.FirstArtist.Items[0].Profile.Name)\n    fmt.Printf(\"Album: %s\\n\", track.Data.TrackUnion.AlbumOfTrack.Name)\n}\n```\n\n## Usage Examples\n\n### Track Information\n\n```go\nclient := spotify.NewClient()\nctx := context.Background()\n\ntrack, err := client.FetchTrack(ctx, \"4cOdK2wGLETKBW3PvgPWqT\")\nif err != nil {\n    log.Fatal(err)\n}\n\nfmt.Printf(\"Name: %s\\n\", track.Data.TrackUnion.Name)\nfmt.Printf(\"URI: %s\\n\", track.Data.TrackUnion.URI)\nfmt.Printf(\"Duration: %dms\\n\", track.Data.TrackUnion.Duration.TotalMilliseconds)\nfmt.Printf(\"Album: %s\\n\", track.Data.TrackUnion.AlbumOfTrack.Name)\n\nif len(track.Data.TrackUnion.FirstArtist.Items) \u003e 0 {\n    fmt.Printf(\"Artist: %s\\n\", track.Data.TrackUnion.FirstArtist.Items[0].Profile.Name)\n}\n```\n\n### Artist Information\n\n```go\nclient := spotify.NewClient()\nctx := context.Background()\n\nartist, err := client.FetchArtist(ctx, \"4tZwfgrHOc3mvqYlEYSvVi\")\nif err != nil {\n    log.Fatal(err)\n}\n\nfmt.Printf(\"Artist: %s\\n\", artist.Data.ArtistUnion.Profile.Name)\nfmt.Printf(\"Followers: %d\\n\", artist.Data.ArtistUnion.Stats.Followers)\nfmt.Printf(\"Monthly Listeners: %d\\n\", artist.Data.ArtistUnion.Stats.MonthlyListeners)\n\n// Access artist's avatar\nif len(artist.Data.ArtistUnion.Visuals.AvatarImage.Sources) \u003e 0 {\n    fmt.Printf(\"Avatar URL: %s\\n\", artist.Data.ArtistUnion.Visuals.AvatarImage.Sources[0].URL)\n}\n```\n\n### Album Information\n\n```go\nclient := spotify.NewClient()\nctx := context.Background()\n\nalbum, err := client.FetchAlbum(ctx, \"2noRn2Aes5aoNVsU6iWThc\")\nif err != nil {\n    log.Fatal(err)\n}\n\nfmt.Printf(\"Album: %s\\n\", album.Data.AlbumUnion.Name)\nfmt.Printf(\"URI: %s\\n\", album.Data.AlbumUnion.URI)\nfmt.Printf(\"Total Tracks: %d\\n\", album.Data.AlbumUnion.Tracks.TotalCount)\n\nif len(album.Data.AlbumUnion.Artists.Items) \u003e 0 {\n    fmt.Printf(\"Artist: %s\\n\", album.Data.AlbumUnion.Artists.Items[0].Profile.Name)\n}\n```\n\n## Configuration Options\n\n```go\n// Enable debug logging\nclient := spotify.NewClient(\n    spotify.WithDebug(true),\n)\n\n// Custom logger (uses log/slog)\nlogger := slog.New(slog.NewJSONHandler(os.Stdout, nil))\nclient := spotify.NewClient(\n    spotify.WithLogger(logger),\n)\n\n// Custom HTTP client for testing\nclient := spotify.NewClient(\n    spotify.WithHTTPDoer(mockDoer),\n)\n```\n\n## API Reference\n\n### Client Methods\n\n| Method          | Parameters        | Description              | Returns            |\n| --------------- | ----------------- | ------------------------ | ------------------ |\n| `FetchTrack()`  | `ctx`, `trackID`  | Get track information    | `*TrackResponse`   |\n| `FetchArtist()` | `ctx`, `artistID` | Get artist profile       | `*ArtistResponse`  |\n| `FetchAlbum()`  | `ctx`, `albumID`  | Get album details        | `*AlbumResponse`   |\n\n### Configuration Options\n\n| Option                 | Description                        |\n| ---------------------- | ---------------------------------- |\n| `WithDebug(bool)`      | Enable/disable debug logging       |\n| `WithHTTPDoer(Doer)`   | Use custom HTTP doer (for testing) |\n| `WithLogger(*slog.Logger)` | Use custom structured logger   |\n\n## Error Handling\n\n```go\nimport \"github.com/FrostBreker/spotify-private-api/errors\"\n\ntrack, err := client.FetchTrack(ctx, trackID)\nif err != nil {\n    if errors.IsAPIError(err) {\n        fmt.Println(\"API returned an error\")\n    }\n    if errors.IsParseError(err) {\n        fmt.Println(\"Failed to parse response\")\n    }\n    if err == errors.ErrInvalidID {\n        fmt.Println(\"Invalid Spotify ID provided\")\n    }\n}\n```\n\n### Error Types\n\n| Error Type     | Description                            |\n| -------------- | -------------------------------------- |\n| `APIError`     | Spotify returned an error response     |\n| `ParseError`   | JSON parsing or processing error       |\n| `RequestError` | HTTP request failed                    |\n\n### Sentinel Errors\n\n| Error              | Description                 |\n| ------------------ | --------------------------- |\n| `ErrInvalidID`     | Invalid Spotify ID provided |\n| `ErrEmptyResponse` | Empty response received     |\n\n## Project Structure\n\n```\nspotify-private-api/\n├── client.go          # Main client implementation\n├── track.go           # Track operations\n├── artist.go          # Artist operations\n├── album.go           # Album operations\n├── doc.go             # Package documentation\n├── errors/\n│   └── errors.go      # Custom error types\n├── internal/\n│   └── http/\n│       └── http.go    # Browser-like HTTP client\n├── models/\n│   ├── track.go       # Track response types\n│   ├── artist.go      # Artist response types\n│   └── album.go       # Album response types\n└── example/\n    └── main.go        # Usage examples\n```\n\n## Testing\n\n```go\n// Create a mock HTTP client\ntype mockHTTPClient struct {\n    doFunc func(req *http.Request) (*http.Response, error)\n}\n\nfunc (m *mockHTTPClient) Do(req *http.Request) (*http.Response, error) {\n    return m.doFunc(req)\n}\n\n// Use in tests\nclient := spotify.NewClient(\n    spotify.WithHTTPDoer(\u0026mockHTTPClient{\n        doFunc: func(req *http.Request) (*http.Response, error) {\n            return \u0026http.Response{\n                StatusCode: 200,\n                Body:       io.NopCloser(strings.NewReader(mockHTML)),\n            }, nil\n        },\n    }),\n)\n```\n\nRun tests:\n\n```bash\ngo test ./...\ngo test -v ./...\ngo test -cover ./...\n```\n\n## How It Works\n\nThis package scrapes Spotify's public web pages to extract embedded data. Spotify embeds JSON data in a `\u003cscript id=\"initialState\"\u003e` tag as base64-encoded content. The package:\n\n1. Makes HTTP requests with browser-like TLS fingerprints (using CycleTLS)\n2. Parses the HTML response to find the embedded data\n3. Decodes and unmarshals the JSON into typed Go structs\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.MD](LICENSE.MD) file for details.\n\n## Disclaimer\n\n⚠️ **Important**: This package scrapes Spotify's public web pages. Use responsibly.\n\n- This package is for educational and research purposes only\n- The page structure may change without notice, potentially breaking this package\n- Excessive use may result in rate limiting or IP blocks\n- Not affiliated with or endorsed by Spotify\n\n---\n\n**Happy Listening! 🎧**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrostbreker%2Fspotify-private-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrostbreker%2Fspotify-private-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrostbreker%2Fspotify-private-api/lists"}