{"id":34822763,"url":"https://github.com/alertua/bandcamp_async_api","last_synced_at":"2026-04-02T15:39:32.704Z","repository":{"id":330015151,"uuid":"1120700180","full_name":"ALERTua/bandcamp_async_api","owner":"ALERTua","description":"Asynchronous Python client for the Bandcamp API.","archived":false,"fork":false,"pushed_at":"2026-01-26T17:14:07.000Z","size":147,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-27T05:32:57.094Z","etag":null,"topics":["aiohttp","api","async","bandcamp","python"],"latest_commit_sha":null,"homepage":"https://github.com/ALERTua/bandcamp_async_api","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ALERTua.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-21T19:03:49.000Z","updated_at":"2026-01-12T23:29:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ALERTua/bandcamp_async_api","commit_stats":null,"previous_names":["alertua/bandcamp_async_api"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ALERTua/bandcamp_async_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALERTua%2Fbandcamp_async_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALERTua%2Fbandcamp_async_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALERTua%2Fbandcamp_async_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALERTua%2Fbandcamp_async_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ALERTua","download_url":"https://codeload.github.com/ALERTua/bandcamp_async_api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALERTua%2Fbandcamp_async_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28980159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T13:38:33.235Z","status":"ssl_error","status_checked_at":"2026-02-01T13:38:32.912Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["aiohttp","api","async","bandcamp","python"],"created_at":"2025-12-25T14:51:12.011Z","updated_at":"2026-04-02T15:39:32.693Z","avatar_url":"https://github.com/ALERTua.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://stand-with-ukraine.pp.ua)\n[![Made in Ukraine](https://img.shields.io/badge/made_in-Ukraine-ffd700.svg?labelColor=0057b7)](https://stand-with-ukraine.pp.ua)\n[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua)\n[![Russian Warship Go Fuck Yourself](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/RussianWarship.svg)](https://stand-with-ukraine.pp.ua)\n\n# Bandcamp Async API\n\nA modern, asynchronous Python client for the Bandcamp API.\n\n###### This project was created to [implement](https://github.com/music-assistant/server/pull/2871) a Bandcamp music provider for [Music Assistant](https://github.com/music-assistant), enabling seamless integration of Bandcamp's music catalog into home audio systems.\n\n- **Repository**: https://github.com/ALERTua/bandcamp_async_api\n- **Changelog**: https://github.com/ALERTua/bandcamp_async_api/releases\n- **PyPI**: https://pypi.org/project/bandcamp_async_api/\n- **Music Assistant**: https://github.com/music-assistant\n\n## Features\n\n- **Search**: Search for artists, albums, and tracks across Bandcamp\n- **Albums**: Retrieve detailed album information including track listings\n- **Tracks**: Get individual track details and streaming information\n- **Artists**: Access artist profiles, discographies, and metadata\n- **Collections**: Browse user collections and wishlists (auth required for private data)\n- **Following**: Access following bands, following fans, and followers\n- **Feed**: Get personalized music feed with new releases from followed artists\n- **Async**: Fully asynchronous API using aiohttp\n- **Type-safe**: Complete type hints for all models and methods\n- **Well-tested**: Comprehensive test suite with real API data\n\n## Installation\n\nInstall from PyPI:\n\n```bash\npip install bandcamp-async-api\n```\n\nOr using uv:\n\n```bash\nuv add bandcamp-async-api\n```\n\n## Quick Start\n\n```python\nimport asyncio\nfrom bandcamp_async_api import BandcampAPIClient\n\nasync def main():\n    async with BandcampAPIClient(identity_token='7%09optional_identity_token%7D') as client:\n        # Search for music\n        results = await client.search(\"radiohead\")\n        print(f\"Found {len(results)} results\")\n\n        # Get album details\n        if results:\n            album_result = next(r for r in results if r.type == \"album\")\n            album = await client.get_album(album_result.artist_id, album_result.id)\n            print(f\"Album: {album.title} by {album.artist.name}\")\n\n        # Get artist information\n        artist_result = next(r for r in results if r.type == \"artist\")\n        artist = await client.get_artist(artist_result.id)\n        print(f\"Artist: {artist.name} - {artist.bio}\")\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\n\n## Authentication\n\nFor accessing user collections, you need to obtain an identity token from Bandcamp cookies:\n\n```python\nfrom bandcamp_async_api import BandcampAPIClient\n\nclient = BandcampAPIClient(identity_token=\"your_identity_token\")\n```\n\n## Music Feed\n\nThe `get_feed()` method retrieves a personalized music feed containing new releases from followed artists, fan purchases, and fan picks. This endpoint requires authentication - you must provide an identity token.\n\n```python\nimport asyncio\nfrom bandcamp_async_api import BandcampAPIClient, BandcampMustBeLoggedInError\n\nasync def main():\n    async with BandcampAPIClient(identity_token='your_identity_token') as client:\n        # Get your music feed\n        feed = await client.get_feed()\n        print(f\"New stories: {len(feed.stories)}\")\n        print(f\"Has more: {feed.has_more}\")\n\n        # Iterate through feed stories\n        for story in feed.stories:\n            print(f\"  - {story.story_type}: {story.item_title} by {story.band_name}\")\n\n        # Access tracks with streaming URLs\n        for track in feed.track_list:\n            print(f\"  Track: {track.title} - {track.streaming_url}\")\n\n        # Paginate through older stories\n        if feed.has_more and feed.oldest_story_date:\n            older_feed = await client.get_feed(older_than=feed.oldest_story_date)\n            print(f\"Older stories: {len(older_feed.stories)}\")\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\n\n### Feed Story Types\n\nThe feed contains different story types:\n- `np` - New track/track release\n- `nr` - New album release\n- `p` - Fan purchase\n- `fp` - Fan pick\n\n### Error Handling\n\nThe feed endpoint requires authentication. If you try to access it without an identity token, you'll receive a `BandcampMustBeLoggedInError`:\n\n```python\nfrom bandcamp_async_api import BandcampAPIClient, BandcampMustBeLoggedInError\n\nasync def safe_get_feed():\n    client = BandcampAPIClient()  # No identity token\n    try:\n        feed = await client.get_feed()\n    except BandcampMustBeLoggedInError:\n        print(\"Feed requires authentication - provide an identity token\")\n```\n\n## API Reference\n\n### Core Client\n\n- `BandcampAPIClient()` - Main API client\n- `search(query: str)` - Search Bandcamp\n- `get_album(artist_id, album_id)` - Get album details\n- `get_track(artist_id, track_id)` - Get track details\n- `get_artist(artist_id)` - Get artist details\n- `get_collection_summary()` - Get collection overview\n- `get_collection_items(collection_type, older_than_token, count, fan_id)` - Get collection/wishlist/following items with pagination\n- `get_artist_discography(artist_id)` - Get artist's complete discography\n- `get_feed(older_than)` - Get personalized music feed with pagination support\n\n### Data Models\n\n- `SearchResultItem` - Base search result\n- `BCAlbum` - Album with tracks and metadata\n- `BCTrack` - Individual track information\n- `BCArtist` - Artist/band profile\n- `CollectionSummary` - User's collection data\n- `CollectionItem` - Individual collection item\n- `FollowingItem` - Band/artist from following list\n- `FanItem` - Fan/user from following_fans or followers\n- `FeedResponse` - User's music feed with stories and tracks\n- `FeedStory` - Individual feed story (new release, fan purchase, etc.)\n- `FeedTrack` - Track from feed with streaming URL\n- `FeedBandInfo` - Band information referenced in feed\n- `FeedFanInfo` - Fan information referenced in feed\n\n### Exceptions\n\n- `BandcampAPIError` - Base API error\n- `BandcampNotFoundError` - Resource not found\n- `BandcampBadQueryError` - Invalid search query\n- `BandcampRateLimitError` - Rate limit exceeded (includes `retry_after` attribute)\n\n## Error Handling\n\nThe client provides specific exception types for different error conditions:\n\n```python\nfrom bandcamp_async_api import (\n    BandcampAPIClient,\n    BandcampNotFoundError,\n    BandcampAPIError\n)\n\nasync def safe_get_album(client, artist_id, album_id):\n    try:\n        return await client.get_album(artist_id, album_id)\n    except BandcampNotFoundError:\n        print(\"Album not found\")\n        return None\n    except BandcampAPIError as e:\n        print(f\"API error: {e}\")\n        return None\n```\n\n### Rate Limiting\n\nWhen Bandcamp's API rate limit is exceeded, a `BandcampRateLimitError` is raised with a `retry_after` attribute indicating how many seconds to wait before retrying:\n\n```python\nimport asyncio\nfrom bandcamp_async_api import BandcampAPIClient, BandcampRateLimitError\n\nasync def get_album_with_retry(client, artist_id, album_id, max_retries=3):\n    for attempt in range(max_retries):\n        try:\n            return await client.get_album(artist_id, album_id)\n        except BandcampRateLimitError as e:\n            if attempt \u003c max_retries - 1:\n                wait_time = e.retry_after or 30\n                print(f\"Rate limited. Waiting {wait_time} seconds...\")\n                await asyncio.sleep(wait_time)\n            else:\n                raise\n```\n\nFor automatic retries with exponential backoff, you can use the `tenacity` library:\n\n```python\nfrom tenacity import retry, retry_if_exception_type, wait_exponential\nfrom bandcamp_async_api import BandcampAPIClient, BandcampRateLimitError\n\n@retry(\n    retry=retry_if_exception_type(BandcampRateLimitError),\n    wait=wait_exponential(multiplier=1, min=30, max=300)\n)\nasync def get_album(client, artist_id, album_id):\n    return await client.get_album(artist_id, album_id)\n```\n\n## Development\n\n### Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/ALERTua/bandcamp_async_api.git\ncd bandcamp_async_api\n\n# Install dependencies\nuv sync --dev\n\n# Run tests\nuv run pytest\n\n# Run linting\nuv run ruff check\n```\n\n### Testing\n\nThe project includes comprehensive tests:\n\n```bash\n# Run all tests\nuv run pytest\n\n# Run integration tests (requires real API access)\necho \"BANDCAMP_IDENTITY_TOKEN=7%09identity_token%7D\" \u003e .env\nuv run pytest tests/real_data/\n```\n\n## Contributing\n\nContributions are welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch\n3. Add tests for new functionality\n4. Ensure all tests pass\n5. Submit a pull request\n\n\nThis project is built based on data from:\n- https://github.com/michaelherger/Bandcamp-API\n- https://github.com/impliedchaos/mopidy-bandcamp\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falertua%2Fbandcamp_async_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falertua%2Fbandcamp_async_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falertua%2Fbandcamp_async_api/lists"}