copyright-free-songs
v1767774.444.65
Published
Professional integration for https://supermaker.ai/music/copyright-free-songs/
Maintainers
Readme
copyright-free-songs
A JavaScript package providing access to a curated list of copyright-free songs and related metadata. This utility simplifies the process of finding and utilizing music for your projects without licensing concerns.
Installation
Install the package using npm: bash npm install copyright-free-songs
Usage Examples
Here are some examples of how to use the copyright-free-songs package in your JavaScript/Node.js projects:
1. Retrieving a Random Song: javascript const copyrightFreeSongs = require('copyright-free-songs');
const randomSong = copyrightFreeSongs.getRandomSong();
console.log('Random Song:', randomSong); // Expected output (example): // Random Song: { title: 'Inspiring Piano', artist: 'Anonymous', genre: 'Classical', url: 'https://example.com/inspiring-piano.mp3' }
2. Filtering Songs by Genre: javascript const copyrightFreeSongs = require('copyright-free-songs');
const classicalSongs = copyrightFreeSongs.getSongsByGenre('Classical');
console.log('Classical Songs:', classicalSongs); // Expected output (example): // Classical Songs: [ { title: 'Inspiring Piano', artist: 'Anonymous', genre: 'Classical', url: 'https://example.com/inspiring-piano.mp3' }, ... ]
3. Searching for a Song by Title (Partial Match): javascript const copyrightFreeSongs = require('copyright-free-songs');
const searchResults = copyrightFreeSongs.searchSongs('Inspiring');
console.log('Search Results:', searchResults); // Expected output (example): // Search Results: [ { title: 'Inspiring Piano', artist: 'Anonymous', genre: 'Classical', url: 'https://example.com/inspiring-piano.mp3' }, ... ]
4. Getting All Songs: javascript const copyrightFreeSongs = require('copyright-free-songs');
const allSongs = copyrightFreeSongs.getAllSongs();
console.log('All Songs:', allSongs); // Expected output (example): // All Songs: [ { title: 'Inspiring Piano', artist: 'Anonymous', genre: 'Classical', url: 'https://example.com/inspiring-piano.mp3' }, { title: 'Upbeat Electronic', artist: 'Producer X', genre: 'Electronic', url: 'https://example.com/upbeat-electronic.mp3' }, ...]
5. Using with Express.js to serve song metadata: javascript const express = require('express'); const copyrightFreeSongs = require('copyright-free-songs');
const app = express(); const port = 3000;
app.get('/songs/random', (req, res) => { res.json(copyrightFreeSongs.getRandomSong()); });
app.listen(port, () => {
console.log(Server listening at http://localhost:${port});
});
API Summary
getRandomSong(): Song: Returns a randomly selected song object from the available list. TheSongobject containstitle,artist,genre, andurlproperties.getSongsByGenre(genre: string): Song[]: Returns an array of song objects that match the specified genre.searchSongs(query: string): Song[]: Returns an array of song objects whose titles contain the specified query string (case-insensitive).getAllSongs(): Song[]: Returns an array containing all available song objects.
Where Song object structure is:
typescript
{
title: string;
artist: string;
genre: string;
url: string;
}
License
MIT License
This package is part of the copyright-free-songs ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/music/copyright-free-songs/
