Spotted 0.5.0

dotnet add package Spotted --version 0.5.0
                    
NuGet\Install-Package Spotted -Version 0.5.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="Spotted" Version="0.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Spotted" Version="0.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Spotted" />
                    
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 Spotted --version 0.5.0
                    
#r "nuget: Spotted, 0.5.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 Spotted@0.5.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=Spotted&version=0.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Spotted&version=0.5.0
                    
Install as a Cake Tool

Unofficial Spotify API Library

The Unofficial Spotify API Library is currently in beta and we're excited for you to experiment with it!

This library has not yet been exhaustively tested in production environments and may be missing some features you'd expect in a stable release. As we continue development, there may be breaking changes that require updates to your code.

We'd love your feedback! Please share any suggestions, bug reports, feature requests, or general thoughts by filing an issue.

The Unofficial Spotify SDK provides convenient access to the Spotted REST API from applications written in C#.

It is generated with Stainless.

The REST API documentation can be found on spotted.stldocs.com.

Installation

Install the package from NuGet:

dotnet add package Spotted

Requirements

This library requires .NET Standard 2.0 or later.

Usage

See the examples directory for complete and runnable examples.

using System;
using Spotted;
using Spotted.Models.Albums;

SpottedClient client = new();

AlbumRetrieveParams parameters = new() { ID = "4aawyAB9vmqN3uQ7FjRGTy" };

var album = await client.Albums.Retrieve(parameters);

Console.WriteLine(album);

Client configuration

Configure the client using environment variables:

using Spotted;

// Configured using the SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET, SPOTIFY_ACCESS_TOKEN and SPOTTED_BASE_URL environment variables
SpottedClient client = new();

Or manually:

using Spotted;

SpottedClient client = new()
{
    ClientID = "My Client ID",
    ClientSecret = "My Client Secret",
};

Or using a combination of the two approaches.

See this table for the available options:

Property Environment variable Required Default value
ClientID SPOTIFY_CLIENT_ID false -
ClientSecret SPOTIFY_CLIENT_SECRET false -
AccessToken SPOTIFY_ACCESS_TOKEN false -
BaseUrl SPOTTED_BASE_URL true "https://api.spotify.com/v1"

Modifying configuration

To temporarily use a modified client configuration, while reusing the same connection and thread pools, call WithOptions on any client or service:

using System;

var album = await client
    .WithOptions(options =>
        options with
        {
            BaseUrl = "https://example.com",
            Timeout = TimeSpan.FromSeconds(42),
        }
    )
    .Albums.Retrieve(parameters);

Console.WriteLine(album);

Using a with expression makes it easy to construct the modified options.

The WithOptions method does not affect the original client or service.

Requests and responses

To send a request to the Spotted API, build an instance of some Params class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a C# class.

For example, client.Albums.Retrieve should be called with an instance of AlbumRetrieveParams, and it will return an instance of Task<AlbumRetrieveResponse>.

Binary responses

The SDK defines methods that return binary responses, which are used for API responses that shouldn't necessarily be parsed, like non-JSON data.

These methods return HttpResponse:

using System;
using System.Text;
using Spotted.Models.Playlists.Images;

ImageUpdateParams parameters = new()
{
    PlaylistID = "3cEYpjA9oz9GiPac4AsH4n",
    Body = Encoding.UTF8.GetBytes("text"),
};

var image = await client.Playlists.Images.Update(parameters);

Console.WriteLine(image);

To save the response content to a file, or any Stream, use the CopyToAsync method:

using System.IO;

using var response = await client.Playlists.Images.Update(parameters);
using var contentStream = await response.ReadAsStream();
using var fileStream = File.Open(path, FileMode.OpenOrCreate);
await contentStream.CopyToAsync(fileStream); // Or any other Stream

Error handling

The SDK throws custom unchecked exception types:

  • SpottedApiException: Base class for API errors. See this table for which exception subclass is thrown for each HTTP status code:
Status Exception
400 SpottedBadRequestException
401 SpottedUnauthorizedException
403 SpottedForbiddenException
404 SpottedNotFoundException
422 SpottedUnprocessableEntityException
429 SpottedRateLimitException
5xx Spotted5xxException
others SpottedUnexpectedStatusCodeException

Additionally, all 4xx errors inherit from Spotted4xxException.

false

  • SpottedIOException: I/O networking errors.

  • SpottedInvalidDataException: Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response.

  • SpottedException: Base class for all exceptions.

Network options

Retries

The SDK automatically retries 2 times by default, with a short exponential backoff between requests.

Only the following error types are retried:

  • Connection errors (for example, due to a network connectivity problem)
  • 408 Request Timeout
  • 409 Conflict
  • 429 Rate Limit
  • 5xx Internal

The API may also explicitly instruct the SDK to retry or not retry a request.

To set a custom number of retries, configure the client using the MaxRetries method:

using Spotted;

SpottedClient client = new() { MaxRetries = 3 };

Or configure a single method call using WithOptions:

using System;

var album = await client
    .WithOptions(options =>
        options with { MaxRetries = 3 }
    )
    .Albums.Retrieve(parameters);

Console.WriteLine(album);

Timeouts

Requests time out after 1 minute by default.

To set a custom timeout, configure the client using the Timeout option:

using System;
using Spotted;

SpottedClient client = new() { Timeout = TimeSpan.FromSeconds(42) };

Or configure a single method call using WithOptions:

using System;

var album = await client
    .WithOptions(options =>
        options with { Timeout = TimeSpan.FromSeconds(42) }
    )
    .Albums.Retrieve(parameters);

Console.WriteLine(album);

Undocumented API functionality

The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.

Response validation

In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a string, but the API could return something else.

By default, the SDK will not throw an exception in this case. It will throw SpottedInvalidDataException only if you directly access the property.

If you would prefer to check that the response is completely well-typed upfront, then either call Validate:

var album = client.Albums.Retrieve(parameters);
album.Validate();

Or configure the client using the ResponseValidation option:

using Spotted;

SpottedClient client = new() { ResponseValidation = true };

Or configure a single method call using WithOptions:

using System;

var album = await client
    .WithOptions(options =>
        options with { ResponseValidation = true }
    )
    .Albums.Retrieve(parameters);

Console.WriteLine(album);

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.0 265 12/18/2025
0.4.0 269 12/18/2025
0.3.1 122 12/12/2025
0.3.0 423 12/11/2025
0.2.0 410 12/8/2025
0.1.0 162 12/5/2025