API Documentation

Welcome to the FreeMusicBG API! Access thousands of royalty-free music tracks programmatically.

Get Started: Create a free account to get your API key and start making requests.

Base URL

https://freebgmusic.info/api/v1

Authentication

All API requests require authentication using an API key.

Getting Your API Key:
  1. Create a free account
  2. Your API key will be automatically generated
  3. Find it in your dashboard
Using Your API Key:

You can provide your API key in two ways:

Method 1: Header (Recommended)

Include in request header:

X-API-Key: your_api_key_here
Method 2: Query Parameter

Include in URL:

?api_key=your_api_key_here
Keep it secret! Never share your API key publicly or commit it to version control.

Rate Limiting

Please be respectful with API usage. Excessive requests may be throttled.

  • Recommended: Max 60 requests per minute
  • Max results per page: 100

Endpoints

Tracks

GET /api/v1/tracks

Get a paginated list of all tracks.

Query Parameters:
Parameter Type Description
search string Search by title or artist
genre string Filter by genre slug
instrument string Filter by instrument slug
feel string Filter by mood/feel slug
sort string Sort by: latest, popular, title
per_page integer Results per page (max: 100, default: 15)
page integer Page number
Example Request:
GET https://freebgmusic.info/api/v1/tracks?search=summer&sort=popular&per_page=20
GET /api/v1/tracks/{slug}

Get a single track by slug.

Example Request:
GET https://freebgmusic.info/api/v1/tracks/summer-vibes

Genres

GET /api/v1/genres

Get all genres with track counts.

GET /api/v1/genres/{slug}

Get a genre with its tracks (paginated).

Query params: sort, per_page, page

Instruments

GET /api/v1/instruments

Get all instruments with track counts.

GET /api/v1/instruments/{slug}

Get an instrument with its tracks (paginated).

Feels/Moods

GET /api/v1/feels

Get all moods/feels with track counts.

GET /api/v1/feels/{slug}

Get a mood/feel with its tracks (paginated).

Code Examples

cURL

curl -X GET "https://freebgmusic.info/api/v1/tracks?sort=popular&per_page=10" \
  -H "X-API-Key: YOUR_API_KEY_HERE"
curl -X GET "https://freebgmusic.info/api/v1/tracks?sort=popular&per_page=10&api_key=YOUR_API_KEY_HERE"

JavaScript (Fetch API)

// With Header (Recommended)
fetch('https://freebgmusic.info/api/v1/tracks?sort=popular&per_page=10', {
    headers: {
        'X-API-Key': 'YOUR_API_KEY_HERE'
    }
})
.then(response => response.json())
.then(data => {
    console.log(data.data); // Array of tracks
    console.log(data.total); // Total count
});

// With Query Parameter
fetch('https://freebgmusic.info/api/v1/tracks?sort=popular&per_page=10&api_key=YOUR_API_KEY_HERE')
.then(response => response.json())
.then(data => console.log(data));

Node.js (Axios)

const axios = require('axios');

// With Header
axios.get('https://freebgmusic.info/api/v1/tracks', {
    headers: {
        'X-API-Key': 'YOUR_API_KEY_HERE'
    },
    params: {
        sort: 'popular',
        per_page: 10
    }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));

PHP (cURL)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://freebgmusic.info/api/v1/tracks?sort=popular&per_page=10');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-API-Key: YOUR_API_KEY_HERE'
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);

print_r($data['data']);

Python (Requests)

import requests

# With Header
headers = {
    'X-API-Key': 'YOUR_API_KEY_HERE'
}

params = {
    'search': 'summer',
    'sort': 'popular',
    'per_page': 20
}

response = requests.get('https://freebgmusic.info/api/v1/tracks', 
                       headers=headers, 
                       params=params)

data = response.json()
for track in data['data']:
    print(track['title'])

Ruby

require 'net/http'
require 'json'

uri = URI('https://freebgmusic.info/api/v1/tracks?sort=popular&per_page=10')
request = Net::HTTP::Get.new(uri)
request['X-API-Key'] = 'YOUR_API_KEY_HERE'

response = Net::HTTP.start(uri.hostname, uri.port) do |http|
  http.request(request)
end

data = JSON.parse(response.body)
puts data['data']

Go

package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    client := &http.Client{}
    req, _ := http.NewRequest("GET", "https://freebgmusic.info/api/v1/tracks?sort=popular&per_page=10", nil)
    req.Header.Add("X-API-Key", "YOUR_API_KEY_HERE")
    
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    
    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}

Response Format

All responses are in JSON format. Paginated responses include:

{
  "current_page": 1,
  "data": [...],
  "first_page_url": "...",
  "from": 1,
  "last_page": 10,
  "last_page_url": "...",
  "next_page_url": "...",
  "path": "...",
  "per_page": 15,
  "prev_page_url": null,
  "to": 15,
  "total": 150
}

Don't Miss New Copyright-Free Tracks

Get newly added music and licensing updates delivered to your inbox.

We respect your privacy. Unsubscribe at any time.

Recently Viewed
No History Yet

Tracks you listen to will appear here.

Unlock Full Experience

Sync favorites forever & Get Free API Key.

Login / Sign Up