A modern, type-safe TypeScript client for the setlist.fm REST API.
setlistfm-ts provides a lightweight, fully typed interface to the setlist.fm API, enabling easy access to artists, setlists, venues, and more β all in clean, idiomatic TypeScript.
pnpm add setlistfm-ts
# or
npm install setlistfm-ts
# or
yarn add setlistfm-tsImportant: Browser Usage and API Key Safety
This library includes UMD builds for browser environments, but exposing API keys in frontend applications is a security risk. Your setlist.fm API key should be treated as sensitive credentials.
// DON'T: Hardcode API keys in frontend code
const client = createSetlistFMClient({
apiKey: "your-actual-api-key-here", // β Exposed to all users
userAgent: "MyApp"
});
// DON'T: Store API keys in client-side storage
localStorage.setItem("apiKey", "your-api-key"); // β Accessible to any scriptThe browser builds are appropriate for:
- Browser Extensions: Users provide their own API keys stored securely in extension storage
- Electron Applications: API keys stored in main process, not renderer
- Internal Corporate Tools: Behind authentication, no public key exposure
- Development/Prototyping: Local testing with non-production keys
- Educational Projects: Learning environments with temporary keys
For production web applications, proxy API calls through your backend:
// β
Frontend calls your backend
const response = await fetch("/api/setlists/search", {
method: "POST",
headers: { Authorization: `Bearer ${userToken}` },
body: JSON.stringify({ artistName: "Radiohead" })
});
// β
Backend handles setlist.fm API with secure key storage
// server.js
const client = createSetlistFMClient({
apiKey: process.env.SETLISTFM_API_KEY, // β
Server-side only
userAgent: "MyApp Backend"
});- Store API keys in environment variables
- Use different keys for development/production
- Never commit keys to version control
- Rotate keys periodically
- Monitor usage through setlist.fm dashboard
Get started instantly with our comprehensive examples:
# 1. Install the package
pnpm add setlistfm-ts
# 2. Set up your API key
echo "SETLISTFM_API_KEY=your-api-key-here" > .env
# 3. Run all 18 examples automatically
./examples/run-all-examples.shThis will demonstrate all endpoints with rate limiting protection, showing you exactly how to use the library in production.
This project is in active development with working implementations for core endpoints. The infrastructure is complete and several endpoint groups are fully functional with comprehensive tests and examples.
- Project scaffolding and TypeScript setup
- Test framework setup (Vitest)
- Linting and formatting (ESLint with @antfu/eslint-config)
- Package.json configuration
- Directory structure for all endpoints
- Type-safe client implementation with direct method calls
- HTTP client utilities with rate limiting
- Error handling system
- Type definitions and validation
- Shared utilities (pagination, metadata)
- TypeScript configuration (src + examples support)
- Build scripts (separate configs for development vs distribution)
- Test scripts with 100% coverage
- Linting scripts (includes examples directory)
- Git hooks setup (Husky)
- Test coverage reporting
- Rate limiting utilities with automatic STANDARD profile
- Examples directory with full IDE support and automated runner
- Enhanced CI/CD pipeline with cross-platform testing
- Local CI testing with Act support and platform simulation
- Documentation generation
- Artist endpoints (3/3 complete) - WORKING
- Cities endpoints (2/2 complete) - WORKING
- Countries endpoints (1/1 complete) - WORKING
- Setlists endpoints (2/2 complete) - WORKING
- Venues endpoints (3/3 complete) - WORKING
- Users endpoints (0/3 complete) - PENDING
- Type definitions for API responses
- Input validation (Zod schemas)
- Rate limiting
- Caching (optional)
setlistfm-ts includes automatic rate limiting using the STANDARD profile (2 req/sec, 1440 req/day) by default. For premium users, you can configure higher limits.
The modern, type-safe client provides direct methods for cleaner code:
import { createSetlistFMClient, RateLimitProfile } from "setlistfm-ts";
// Default client with STANDARD rate limiting (2 req/sec, 1440 req/day)
const client = createSetlistFMClient({
apiKey: "your-api-key-here",
userAgent: "your-app-name (your-email@example.com)",
});
// Optional: Configure premium rate limiting
const premiumClient = createSetlistFMClient({
apiKey: "your-api-key-here",
userAgent: "your-app-name (your-email@example.com)",
rateLimit: { profile: RateLimitProfile.PREMIUM } // 16 req/sec, 50,000 req/day
});
// Example: Search artists with direct method
const searchResults = await client.searchArtists({
artistName: "Radiohead"
});
// Example: Get artist details
const artist = await client.getArtist("a74b1b7f-71a5-4011-9441-d0b5e4122711");
// Example: Get artist setlists
const setlists = await client.getArtistSetlists("a74b1b7f-71a5-4011-9441-d0b5e4122711");
// Example: Search cities
const cityResults = await client.searchCities({
name: "London",
country: "GB" // ISO 3166-1 alpha-2 country code
});
// Example: Get city details
const city = await client.getCityByGeoId("2643743");
// Example: Get all supported countries
const countries = await client.searchCountries();
// Example: Search venues
const venueResults = await client.searchVenues({
name: "Madison Square Garden",
cityName: "New York",
country: "US"
});
// Example: Get venue details
const venue = await client.getVenue("6bd6ca6e");
// Example: Get venue setlists
const venueSetlists = await client.getVenueSetlists("6bd6ca6e");
// Example: Get specific setlist
const setlist = await client.getSetlist("63de4613");
// Example: Search setlists
const setlistResults = await client.searchSetlists({
artistMbid: "a74b1b7f-71a5-4011-9441-d0b5e4122711", // Radiohead
year: 2023
});
console.log(searchResults.artist);
console.log(artist.name);
console.log(setlists.setlist);
console.log(cityResults.cities);
console.log(city.name, city.country.name);
console.log(countries.country.length, "countries available");
console.log(venueResults.venue);
console.log(venue.name, venue.city?.name);
console.log(venueSetlists.setlist);
console.log(setlist.artist.name, setlist.venue.name);
console.log(setlistResults.setlist.length, "setlists found");- Type-safe client API with direct method calls for all endpoints
- Modern axios-based HTTP client with automatic rate limiting
- Intelligent rate limiting with STANDARD/PREMIUM profiles and queue management
- Fully typed API responses with comprehensive validation
- Built-in pagination support with type-safe parameters
- Developer-friendly errors with detailed context and debugging
- Tree-shakable modular endpoints for optimal bundle size
- Production-ready configuration (TypeScript, ESLint, testing)
- Comprehensive examples with automated testing script
- Real-time rate limiting monitoring with detailed status reporting
- ISO standard validation (country codes, geographic data)
- Enhanced CI/CD pipeline with cross-platform matrix testing
- Local CI testing support with Act integration and platform simulation
- Minimal dependencies (only axios and zod)
- 100% test coverage with comprehensive validation
- Full IDE support with examples directory integration
-
getArtist- Get artist by MusicBrainz ID β -
searchArtists- Search for artists β -
getArtistSetlists- Get setlists for an artist β
-
getSetlist- Get setlist by ID β -
searchSetlists- Search for setlists β
-
getVenue- Get venue by ID β -
getVenueSetlists- Get setlists for a venue β -
searchVenues- Search for venues β
-
searchCities- Search for cities β -
getCityByGeoId- Get city by geographical ID β
-
searchCountries- Get all supported countries β
-
getUser- Get user information -
getUserAttended- Get setlists attended by user -
getUserEdited- Get setlists edited by user
Note: Artists, Cities, Countries, Setlists, and Venues endpoints are fully implemented with comprehensive tests and examples. Users endpoints have scaffolded files with implementations pending.
Comprehensive examples are available for all implemented endpoints with full TypeScript support, rate limiting monitoring, and production-ready patterns:
Use the provided bash script to run all 18 examples across 5 endpoint categories:
# Run from project root directory
./examples/run-all-examples.shThis automated script provides:
- β 18 comprehensive examples across all endpoint categories
- π Smart rate limiting with 1s between scripts, 10s between categories
- β° 60-second timeouts per script to prevent hanging
- π¨ Colorized output with progress indicators and status monitoring
- π Execution summary with timing and statistics
- π Rate limiting demonstrations showing protection in action
basicArtistLookup.ts- Search and retrieve artist information with rate limitingsearchArtists.ts- Advanced artist search with filtering and paginationgetArtistSetlists.ts- Artist setlist analysis with intelligent batchingcompleteExample.ts- Full workflow with setlist analysis and statistics
basicCityLookup.ts- City search and lookup workflow with geographic validationsearchCities.ts- Geographic search with country codes and rate-limited paginationcompleteExample.ts- Advanced geographic data analysis with real-world examples
basicCountriesLookup.ts- Countries retrieval and data explorationcountriesAnalysis.ts- Comprehensive analysis and integration with citiescompleteExample.ts- Production-ready workflow with validation and testing
basicSetlistLookup.ts- Setlist search and retrieval with Beatles examplesearchSetlists.ts- Advanced setlist search with filtering and paginationadvancedAnalysis.ts- Complex multi-year setlist statistics and insightscompleteExample.ts- Comprehensive setlist analysis with Radiohead data
basicVenueLookup.ts- Venue search and lookup workflow with location filteringsearchVenues.ts- Advanced venue search with geographic and rate limiting demonstrationsgetVenueSetlists.ts- Venue setlist analysis and statistics with multi-page processingcompleteExample.ts- Comprehensive venue data exploration and insights
All examples showcase:
- β New type-safe client API with direct method calls
- β Automatic STANDARD rate limiting (2 req/sec, 1440 req/day)
- β Real-time rate limiting status monitoring and queue demonstrations
- β Production-ready error handling and edge case management
- β Full TypeScript type checking and IDE support
- β ESLint compliance with examples-specific rules
From comprehensive testing with rate limiting protection:
- Artists workflows: ~2-4 minutes per complete analysis
- Cities analysis: ~1-3 minutes per geographic workflow
- Countries research: ~2-5 minutes for global analysis
- Setlists deep-dive: ~3-6 minutes for multi-year analysis
- Venues comprehensive: ~4-8 minutes for full workflows
- Total automated run: ~15-30 minutes for all 18 examples
Run individual examples manually:
# Artists examples
pnpm dlx tsx examples/artists/basicArtistLookup.ts
pnpm dlx tsx examples/artists/searchArtists.ts
pnpm dlx tsx examples/artists/getArtistSetlists.ts
pnpm dlx tsx examples/artists/completeExample.ts
# Cities examples
pnpm dlx tsx examples/cities/basicCityLookup.ts
pnpm dlx tsx examples/cities/searchCities.ts
pnpm dlx tsx examples/cities/completeExample.ts
# Countries examples
pnpm dlx tsx examples/countries/basicCountriesLookup.ts
pnpm dlx tsx examples/countries/countriesAnalysis.ts
pnpm dlx tsx examples/countries/completeExample.ts
# Setlists examples
pnpm dlx tsx examples/setlists/basicSetlistLookup.ts
pnpm dlx tsx examples/setlists/searchSetlists.ts
pnpm dlx tsx examples/setlists/advancedAnalysis.ts
pnpm dlx tsx examples/setlists/completeExample.ts
# Venues examples
pnpm dlx tsx examples/venues/basicVenueLookup.ts
pnpm dlx tsx examples/venues/searchVenues.ts
pnpm dlx tsx examples/venues/getVenueSetlists.ts
pnpm dlx tsx examples/venues/completeExample.tsBefore running any examples:
- API Key: Get a free API key from setlist.fm
- Environment Setup: Create a
.envfile in the project root:
SETLISTFM_API_KEY=your-api-key-hereNote: Examples require a valid API key in
.envfile. The automated script includes comprehensive setup validation and helpful error messages.
setlistfm-ts has achieved 100% test coverage with comprehensive testing across all implemented endpoints.
Run the test suite:
pnpm testWatch mode:
pnpm test:watchTest the full CI pipeline locally using Act:
# Install Act (macOS)
brew install act
# Test quick checks
act -j quick-checks -W .github/workflows/ci-local.yml
# Test full local CI pipeline
act -W .github/workflows/ci-local.yml
# Test with dry run first
act -W .github/workflows/ci-local.yml --dryrunThe ci-local.yml workflow mirrors the production CI with Act-optimized features:
- β Cross-platform simulation (Windows, macOS, multiple Ubuntu versions)
- β Same validation steps as production CI
- β Enhanced platform-specific testing
- β Smart test separation for optimal local experience
- β Local-only execution (prevents accidental GitHub Actions runs)
- Test framework setup
- 100% code coverage achieved (515 tests across 16 test files)
- Unit tests for artists endpoints (74 tests)
- Unit tests for cities endpoints (52 tests)
- Unit tests for countries endpoints (40 tests)
- Unit tests for setlists endpoints (69 tests)
- Unit tests for venues endpoints (71 tests)
- Unit tests for core utilities (142 tests)
- Error handling tests
- Validation tests
- Integration tests with real API responses
- Complete type safety validation
Full TypeScript checking for both library code and examples:
pnpm type-check # Check src + examples directories
pnpm type-check:verbose # Verbose output with file listingsESLint with examples-specific rules (allows console.log, process.env in examples):
pnpm lint # Lint src + examples directories
pnpm lint:fix # Auto-fix issuesSeparate configurations for development vs distribution:
pnpm build # Build library only (excludes examples)
pnpm check # Full validation (type-check + lint + test)Configuration Files:
tsconfig.json- Development config (includes examples)tsconfig.build.json- Production build config (excludes examples)eslint.config.ts- Unified linting with examples-specific rules
setlistfm-ts includes intelligent rate limiting to protect against API limits and ensure reliable operation:
- STANDARD Profile (default): 2 requests/second, 1,440 requests/day
- PREMIUM Profile: 16 requests/second, 50,000 requests/day
- DISABLED Profile: No rate limiting (advanced users only)
- β Automatic request queuing when limits are approached
- β Real-time status monitoring with detailed metrics
- β Intelligent retry logic with proper backoff
- β Per-second and per-day limit tracking
- β Configurable queue sizes and timeout handling
import { createSetlistFMClient, RateLimitProfile } from "setlistfm-ts";
// Default STANDARD rate limiting
const client = createSetlistFMClient({
apiKey: "your-api-key",
userAgent: "your-app-name (email@example.com)"
});
// Premium rate limiting
const premiumClient = createSetlistFMClient({
apiKey: "your-api-key",
userAgent: "your-app-name (email@example.com)",
rateLimit: { profile: RateLimitProfile.PREMIUM }
});
// Check rate limit status
const status = client.getRateLimitStatus();
console.log(`Requests: ${status.requestsThisSecond}/${status.secondLimit} this second`);
console.log(`Daily usage: ${status.requestsThisDay}/${status.dayLimit} today`);src/
βββ client.ts # Main API client with type-safe methods
βββ endpoints/ # API endpoint implementations
β βββ artists/ # Artist search and retrieval
β βββ cities/ # City search and geographic data
β βββ countries/ # Country listings and validation
β βββ setlists/ # Setlist search and retrieval
β βββ users/ # User data (pending implementation)
β βββ venues/ # Venue search and setlist data
βββ shared/ # Shared utilities and types
β βββ pagination.ts # Pagination handling
β βββ metadata.ts # API response metadata
β βββ errors.ts # Error handling and types
βββ utils/ # Core HTTP and rate limiting
β βββ httpClient.ts # HTTP client with rate limiting
β βββ rateLimiter.ts # Smart rate limiting implementation
βββ index.ts # Public API exports
We welcome contributions! This project uses a three-branch workflow with AI-powered automation:
- Development branches β
previewβmain - Automated release preparation and changelog generation
- AI-enhanced PR descriptions and professional release notes
Please read our CONTRIBUTING.md guide for the complete workflow and guidelines.
This project leverages GitHub Actions for seamless development and release management:
ci.yml- Core CI pipeline with linting, type-checking, and testing across multiple platformsci-local.yml- Act-optimized workflow for local CI testing with cross-platform simulation
pr-enhance.yml- AI-powered PR description enhancement when targetingpreviewbranchrelease-prepare.yml- Automated version bumping and changelog generation using OpenAIrelease-pr.yml- Automatic creation of professionally described release PRs frompreviewtomain
- β Zero-effort releases - Automated semantic versioning and changelog generation
- β AI-enhanced documentation - Professional PR descriptions and release notes
- β Quality assurance - Comprehensive testing before any release
- β Human oversight - Manual approval steps maintain quality control
- β Local testing - Full CI pipeline available locally with Act
Created with π by @tkozzer API documentation: https://api.setlist.fm/docs