|
1 | 1 | # @syncfm/applemusic-api |
2 | | -> A lot of work here is based off the work of https://github.com/oxmc |
3 | 2 |
|
| 3 | +Typed helpers around Apple Music catalog endpoints with shared configuration, logging, and token management. The client is still in active development, so expect method signatures to move as we close gaps. |
4 | 4 |
|
| 5 | +## Features |
5 | 6 |
|
6 | | -More coming soon :D |
| 7 | +- Zero configuration authentication with automatic scraping and validation of session tokens |
| 8 | +- Strong typing across endpoints for albums, artists, songs, music videos, search, hints, suggestions, and relationships |
| 9 | +- Consistent logging hooks so you can forward diagnostics to your own observability stack |
| 10 | +- Built with Bun and Vitest for fast builds and test feedback |
| 11 | + |
| 12 | +## Requirements |
| 13 | + |
| 14 | +- Node.js 18 or newer, or Bun 1.1 or newer |
| 15 | +- Optional developer or user tokens if you want to override the default scraped authentication flow |
| 16 | + |
| 17 | + |
| 18 | +Guides, endpoint details, and configuration notes live at https://docs.syncfm.dev/applemusic-api . |
| 19 | + |
| 20 | +## Installation |
| 21 | + |
| 22 | +```bash |
| 23 | +npm install @syncfm/applemusic-api |
| 24 | +# or |
| 25 | +pnpm add @syncfm/applemusic-api |
| 26 | +# or |
| 27 | +yarn add @syncfm/applemusic-api |
| 28 | +# or |
| 29 | +bun add @syncfm/applemusic-api |
| 30 | +``` |
| 31 | + |
| 32 | +## Quick start |
| 33 | + |
| 34 | +```ts |
| 35 | +import { AppleMusic, AuthType, Region } from "@syncfm/applemusic-api"; |
| 36 | + |
| 37 | +const music = new AppleMusic({ |
| 38 | + region: Region.US, |
| 39 | + authType: AuthType.Scraped, |
| 40 | +}); |
| 41 | + |
| 42 | +await music.init(); |
| 43 | + |
| 44 | +const results = await music.Search.search({ |
| 45 | + term: "bad omens", |
| 46 | + types: ["songs", "albums"], |
| 47 | + limit: 5, |
| 48 | +}); |
| 49 | + |
| 50 | +console.log(results.songs?.data?.map((song) => song.attributes?.name)); |
| 51 | +``` |
| 52 | + |
| 53 | +### Endpoint usage examples |
| 54 | + |
| 55 | +Every top level namespace mirrors an Apple Music resource. Each method enforces the correct parameter and response types. |
| 56 | + |
| 57 | +```ts |
| 58 | +await music.Albums.get({ |
| 59 | + ids: ["1644355784"], |
| 60 | +}); |
| 61 | + |
| 62 | +await music.Albums.getRelationship({ |
| 63 | + id: "1644355784", |
| 64 | + relationship: "tracks", |
| 65 | +}); |
| 66 | + |
| 67 | +await music.Suggestions.suggestions({ |
| 68 | + term: "blind cha", |
| 69 | + limit: 10, |
| 70 | +}); |
| 71 | +``` |
| 72 | + |
| 73 | +## Configuration |
| 74 | + |
| 75 | +`AppleMusic` accepts either an `AppleMusicConfig` instance or plain `AppleMusicConfigParams`. |
| 76 | + |
| 77 | +- `region`: defaults to `Region.US` but can be set to any supported storefront |
| 78 | +- `authType`: choose between `Scraped`, `DeveloperToken`, `UserTokenViaDevToken`, or `UserTokenUnofficial` |
| 79 | +- `logger`: pass a custom logger implementing the client logger interface, or configure the built in logger through `loggerOptions` |
| 80 | + |
| 81 | + |
| 82 | +## Tooling |
| 83 | + |
| 84 | +- Build: `bun run build` |
| 85 | +- Type check: `bun run type-check` |
| 86 | +- Tests with coverage: `bun run test` |
| 87 | +- Lint and format: `bun run check` |
| 88 | +- Generate reference docs: `bun run docs:build` |
| 89 | + |
| 90 | +## Documentation |
| 91 | + |
| 92 | +Guides, endpoint details, and configuration notes live at https://docs.syncfm.dev/applemusic-api . |
| 93 | + |
| 94 | +## Contributing |
| 95 | + |
| 96 | +1. Fork the repository and create a feature branch |
| 97 | +2. Install dependencies and run the test suite |
| 98 | +3. Open a pull request with a clear description and examples |
| 99 | + |
| 100 | +Please include tests or docs when you add new features. |
| 101 | + |
| 102 | +## Legal |
| 103 | + |
| 104 | +Apple Music and the Apple logo are trademarks of Apple Inc., registered in the U.S. and other countries. This project is an independent community effort and is not affiliated with, endorsed by, or sponsored by Apple Inc. Any interaction with Apple services remains subject to Apple policies, terms, and applicable laws. Ensure you have the necessary authorization before using this client in your applications. |
| 105 | + |
| 106 | +## License |
| 107 | + |
| 108 | +MIT License. See `LICENSE.md` for details. |
0 commit comments