NoCopyrightSounds API
This is a webscraper designed to provide api like access to the NCS website
Features
import
import * as ncs from 'nocopyrightsounds-api'
const ncs = require('nocopyrightsounds-api')
examples
direct API Access
get all songs from the first page in the music library
import * as ncs from 'nocopyrightsounds-api'
ncs
.getMusic()
.then(songs => {
console.log(songs)
})
.catch(err => {
console.error(err)
})
get all songs from the first page of house songs
import * as ncs from 'nocopyrightsounds-api'
ncs
.search(
{
genre: 10
}
)
.then(songs => {
console.log(songs)
})
.catch(err => {
console.error(err)
})
get artist info
import * as ncs from 'nocopyrightsounds-api'
ncs
.getArtistInfo()
.then(artist => {
console.log(artist)
})
.catch(err => {
console.error(err)
})
download the newest song
import * as ncs from 'nocopyrightsounds-api'
import * as fs from 'fs'
import https from 'https'
ncs
.getMusic()
.then(async songs => {
const newest = songs[0]
const directUrl = newest.songUrl
const writeStream = fs.createWriteStream(`${newest.name}.mp3`)
https.get(directUrl, res => {
res.pipe(writeStream)
})
})
.catch(err => {
console.error(err)
})
using the client class
import * as ncs from 'nocopyrightsounds-api'
const client = new ncs.Client()
client
.getSongs()
.then(songs => {
console.log(songs)
})
.catch(err => {
console.error(err)
})
with caching
import * as ncs from 'nocopyrightsounds-api'
const client = new ncs.Client({
use_cache: true,
cache_path:
})
refreshing the cache
client.getCache().checkForNew()
for debuging
import * as ncs from 'nocopyrightsounds-api'
const client = new ncs.Client({
detailed_log: true
})