Last.fm API
ws.audioscrobbler.com · Media
Music metadata, charts, and social listening data — artist bios, similar artists, top tracks, user listening history, album info, and global charts. Free API key.
Authentication
Sample Requests
Get bio and stats for The Beatles.
Hover any highlighted part to learn what it does
curl -X GET "https://ws.audioscrobbler.com/2.0/?artist=The%20Beatles&format=json&method=artist.getinfo&api_key=YOUR_KEY"
import requests
params = {
"artist": "The Beatles",
"format": "json",
"method": "artist.getinfo",
"api_key": "YOUR_KEY"
}
response = requests.get(
"https://ws.audioscrobbler.com/2.0/",
params=params,
)
print(response.json())const url = new URL('https://ws.audioscrobbler.com/2.0/');
url.searchParams.set('artist', 'The Beatles');
url.searchParams.set('format', 'json');
url.searchParams.set('method', 'artist.getinfo');
url.searchParams.set('api_key', 'YOUR_KEY');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://ws.audioscrobbler.com/2.0/")
q := baseURL.Query()
q.Set("artist", "The Beatles")
q.Set("format", "json")
q.Set("method", "artist.getinfo")
q.Set("api_key", "YOUR_KEY")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://ws.audioscrobbler.com/2.0/")
uri.query = URI.encode_www_form({
"artist" => "The Beatles",
"format" => "json",
"method" => "artist.getinfo",
"api_key" => "YOUR_KEY"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://ws.audioscrobbler.com/2.0/?" . http_build_query([
"artist" => "The Beatles",
"format" => "json",
"method" => "artist.getinfo",
"api_key" => "YOUR_KEY"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Get the global top artists chart.
Hover any highlighted part to learn what it does
curl -X GET "https://ws.audioscrobbler.com/2.0/?limit=5&format=json&method=chart.gettopartists&api_key=YOUR_KEY"
import requests
params = {
"limit": "5",
"format": "json",
"method": "chart.gettopartists",
"api_key": "YOUR_KEY"
}
response = requests.get(
"https://ws.audioscrobbler.com/2.0/",
params=params,
)
print(response.json())const url = new URL('https://ws.audioscrobbler.com/2.0/');
url.searchParams.set('limit', '5');
url.searchParams.set('format', 'json');
url.searchParams.set('method', 'chart.gettopartists');
url.searchParams.set('api_key', 'YOUR_KEY');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://ws.audioscrobbler.com/2.0/")
q := baseURL.Query()
q.Set("limit", "5")
q.Set("format", "json")
q.Set("method", "chart.gettopartists")
q.Set("api_key", "YOUR_KEY")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://ws.audioscrobbler.com/2.0/")
uri.query = URI.encode_www_form({
"limit" => "5",
"format" => "json",
"method" => "chart.gettopartists",
"api_key" => "YOUR_KEY"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://ws.audioscrobbler.com/2.0/?" . http_build_query([
"limit" => "5",
"format" => "json",
"method" => "chart.gettopartists",
"api_key" => "YOUR_KEY"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Get a free API key at last.fm/api
- Always add &format=json to get JSON (default is XML)
- Artist info: ?method=artist.getinfo&artist=Radiohead&api_key=KEY&format=json
- Similar artists: ?method=artist.getsimilar&artist=Coldplay&api_key=KEY&format=json
- Top tracks: ?method=chart.gettoptracks&api_key=KEY&format=json
What can you build with Last.fm API?
Last.fm API is a Media API. Developers commonly use media APIs for:
- storing and delivering images, video, and audio
- building digital asset management and media libraries
- transcoding and optimising media for the web
- adding video streaming and playback to your app
- automating content tagging and metadata extraction
API Key authentication. You'll receive a key after signing up. Send it with every request — in a header or query parameter. Keep it out of client-side code and never commit it to version control. Last.fm API is free to use up to a usage limit, making it a low-risk choice to experiment with.
New to APIs? Read our beginner's guide