Shoegaze.LastFM 1.1.0

dotnet add package Shoegaze.LastFM --version 1.1.0
                    
NuGet\Install-Package Shoegaze.LastFM -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Shoegaze.LastFM" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Shoegaze.LastFM" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Shoegaze.LastFM" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Shoegaze.LastFM --version 1.1.0
                    
#r "nuget: Shoegaze.LastFM, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Shoegaze.LastFM@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Shoegaze.LastFM&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Shoegaze.LastFM&version=1.1.0
                    
Install as a Cake Tool

Shoegaze.LastFM

A modern C# wrapper for the LastFM API.

NuGet

CI codecov CodeQL SonarCloud

API Implementation Status

Category Progress
Album 100%
Artist 100%
Chart 100%
Geo 100%
Library 100%
Tag 100%
Track 100%
User 100%

Quickstart

Creating a Client

To do any API requests at all you need to instanciate a LastfmClient. You will need to supply your API key and your API secret that you can obtain by creating an API account.

var client = new LastfmClient(apiKey, apiSecret, httpClient);

// you can then call any method that does not require user authentication
var response = await client.user.GetRecentTracksAsync("testUser");
var tracks = response.Data.Items;

All API responses contain error information in case something went wrong.

Getting a Session Key

To be able to do authenticated requests (like scrobbling or adding tracks) you will need a session key granted by the user.

There are two ways to obtain a session key:

1. Automatic Desktop Flow

Use AuthenticateAsync(). This opens the user’s default browser, listens on a temporary http://localhost:{port}/ URL, and automatically exchanges the returned token for a session key.

var auth = new LastfmAuthService(apiKey, apiSecret, httpClient);
var session = await auth.AuthenticateAsync();
Console.WriteLine($"Logged in as {session.User} with key {session.Key}");
2. Manual Flow

Use GetAuthorizationUrlAsync(callbackUrl) with your own callback URL (e.g. a webserver endpoint or custom URI scheme). Redirect the user there, capture the token from Last.fm’s redirect, and then call GetSessionAsync(token) to complete authentication and get a session key.

var auth = new LastfmAuthService(http, apiKey, apiSecret);
var authUrl = await auth.GetAuthorizationUrlAsync("https://myapp.com/callback");

// redirect the user to authUrl and receive the ?token=... in your callback handler
var token = "...";
var session = await auth.GetSessionAsync(token);
Console.WriteLine($"Logged in as {session.User} with key {session.Key}");

Authenticated Requests

After creating a LastfmClient and getting your session key, you can 'authenticate' the client.

var auth = new LastfmAuthService(apiKey, apiSecret, httpClient);
var session = await auth.AuthenticateAsync();

var client = new LastfmClient(apiKey, apiSecret, httpClient);
client.SetSessionKey(session.Key);

// you can then call any method on the client that requires authentication
var response = await client.Artist.AddTagsAsync("My Bloody Valentine", "shoegaze");

Scrobbling

You can scrobble batches of up to 50 scrobbles at once. Scrobbling requires an authenticated client.

var scrobble = new ScrobbleData(artistName: "My Bloody Valentine", trackName: "Loomer", playedAt: DateTime.UtcNow);

var response = await client.Track.ScrobbleAsync(scrobble);
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Shoegaze.LastFM:

Package Downloads
Scrubbler.MediaPlayerScrobblerBase

Base abstractions for Scrubbler media player plugins.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 372 12/19/2025
1.0.0 260 8/24/2025