Skip to content
Auros Nexus edited this page Aug 6, 2021 · 5 revisions

Welcome to the BeatSaverSharper wiki!

How To Use

First off, make sure to pick the version that's right for you. There is the Normal version and Unity version. They're both built against .NET Standard 2.0, but the Unity version uses UnityWebRequests while the Normal version uses System.Net.HttpClient.

Basically everything is nullable, so always expect anything you can await to potentially be null. Everything you await can also contain a CancellationToken

Create your instance

Create an instance of BeatSaver

BeatSaver beatSaver = new BeatSaver("ApplicationName", version);

Note: The client inherits IDisposable. This means absolutely nothing if using the Unity version, but in the normal version, it disposes the internal HttpClient.

where...

"ApplicationName" is the name of your application. Some examples would be...

  • BeatSaverDownloader
  • BeatSearch
  • RankedMapDownloader

and version is a System.Version corresponding to the version of your application.

These properties are used to construct the user agent.

Optionally, use can use the alternate constructor where you can configure with an instance of BeatSaverOptions.

Beatmaps

Getting a Beatmap is simple.

var weAreBack = await beatSaver.Beatmap("d00c"); // d00c is the key of the map.

You can also get a Beatmap by hash.

var backFromWhere = await beatSaver.BeatmapByHash("f6dbd83b699872e2e42c2fc90337ef0ac2ab8f30");

Downloading the cover.

await backFromWhere.LatestVersion.DownloadCoverImage(/* optional IProgress<double> */);

Downloading the ZIP.

await backFromWhere.LatestVersion.DownloadZIP(/* optional IProgress<double> */);

Downloading the audio preview.

await backFromWhere.LatestVersion.DownloadPreview(/* optional IProgress<double> */)

Users

Getting a user.

var reaxt = await beatSaver.User(4235136);

You can also get a user by username. This must be exact, but case doesn't matter.

var denyah = await beatSaver.User("dEnYaH_");

Get the maps that a user has made.

var bobbie = await beatSaver.User(4284355);
var bobbieMaps = await bobbie.Beatmaps(); // Returns a page!

Searching and Paging

If you only want the latest beatmaps uploaded, use:

var latestPage = await beatSaver.LatestBeatmaps(/* optionals for automapper querying */);

Search and filter using an instance of SearchTextFilterOption.

var noodleExtensionMaps = await beatSaver.SearchBeatmaps(new SearchTextFilterOption
{
    NoodleExtensions = true
});

var rankedFullSpreadMaps = await beatSaver.SearchBeatmaps(new SearchTextFilterOption
{
    Ranked = true,
    FullSpread = true,
});

Want to move to the next page? You can!

var secondPageNoodleExtensions = await noodleExtensionMaps.Next();

Disclaimer

The examples provided above are just the basics. You are encouraged to go to the Models and BeatSaver class to look at the properties yourself.

Clone this wiki locally