OsuSharp 6.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package OsuSharp --version 6.2.0                
NuGet\Install-Package OsuSharp -Version 6.2.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="OsuSharp" Version="6.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OsuSharp --version 6.2.0                
#r "nuget: OsuSharp, 6.2.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.
// Install OsuSharp as a Cake Addin
#addin nuget:?package=OsuSharp&version=6.2.0

// Install OsuSharp as a Cake Tool
#tool nuget:?package=OsuSharp&version=6.2.0                

OsuSharp

NuGet version SlimGet Build Status

OsuSharp is a wrapper written in C# for the osu! API.

  • Compatible with .NET 5

Installation

You can install the stable version of the wrapper with NuGet (only supports API v1 for packages prior to 6.0.0):

PM> Install-Package OsuSharp

You can also try Nightly Builds for the API v2. You need to add the following URL as a new NuGet Source:

​https://nuget.emzi0767.com/api/v3/index.json

Then, you can just pull the nightly packages. You may need to enable preview builds to find them.

Finally, you can just compile from source:

git clone https://github.com/Kiritsu/OsuSharp.git

Basic Usage

You can use the following example to get started with the library:

Program.cs

public static class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args)
    {
        return Host.CreateDefaultBuilder(args)
            .ConfigureOsuSharp((ctx, options) => options.Configuration = new OsuClientConfiguration
            {
                ClientId = 123,
                ClientSecret = "my-super-secret"
            })
            .ConfigureServices((ctx, services) => services.AddSingleton<IOsuService, OsuService>());
    }
}

IOsuService.cs

internal interface IOsuService
{
    IAsyncEnumerable<IBeatmapset> GetLastRankedBeatmapsetsAsync(int count);
    Task<string> GetUserAvatarUrlAsync(string username);
}

OsuService.cs

public class OsuService : IOsuService
{
    private readonly IOsuClient _client;

    public OsuService(IOsuClient client)
    {
        _client = client;
    }

    public async IAsyncEnumerable<IBeatmapset> GetLastRankedBeatmapsetsAsync(int count)
    {
        var builder = new BeatmapsetsLookupBuilder()
            .WithGameMode(GameMode.Osu)
            .WithConvertedBeatmaps()
            .WithCategory(BeatmapsetCategory.Ranked);

        await foreach (var beatmap in _client.EnumerateBeatmapsetsAsync(builder, BeatmapSorting.Ranked_Desc))
        {
            yield return beatmap;

            count--;
            if (count == 0)
            {
                break;
            }
        }
    }

    public async Task<string> GetUserAvatarUrlAsync(string username)
    {
        var user = await _client.GetUserAsync(username);
        return user.AvatarUrl.ToString();
    }
}

Contributing

If you want to contribute, feel free to use Issues or Pull Requests!

Todo:

Beatmapset Discussions
 - /beatmapsets/discussions/posts (Get Beatmapset Discussion Posts)
 - /beatmapsets/discussions/votes (Get Beatmapset Discussion Votes)
 - /beatmapsets/discussions/ (Get Beatmapset Discussions)

Changelog
 - /changelog/{stream}/{build} (Get Changelog Build)
 - /changelog (Get Changelog Listing)
 - /changelog/{changelog} (Lookup Changelog Build)

Chat
 - /chat/new (Create New PM)

Comments
 - /comments (Get Comments)
 - /comments/{comment} (Get a Comment)

Forum
 - /forums/topics/{topic}/reply (Reply Topic)
 - /forums/topics (Create Topic)
 - /forums/topics/{topic} (Get Topic and Posts)
 - /forums/topics/{topic} (Edit Topic)
 - /forums/posts/{topic} (Edit Post)

Home
 - /search (Search | Users AND/OR Wiki pages) 

Multiplayer
 - /rooms/{room}/playlist/{playlist}/scores (Get Scores)

News
 - /news (Get News Listing)
 - /news/{news} (Get News Post)

Ranking
 - /rankings/{mode}/{type} (Get Ranking)
 - /spotlights (Get Spotlights)

Wiki
 - /wiki/{locale}/{path}

Undocumented
 - /beatmapsets/events
 - /matches
 - /matches/{match}
 - /rooms/{mode?}
 - /rooms/{room}/leaderboard
 - /rooms/{room}
 - /beatmapsets/lookup (doesn't seem to work?)
 - /friends

Done already

Users
 - /me/{mode} (Get Own Data)
 - /users/{user}/kudosu (Get User Kudosu)
 - /users/{user}/scores/{types} (Get User Scores)
 - /users/{user}/beatmapsets/{type} (Get User Beatmaps)
 - /users/{user}/recent_activity (Get User Recent Activity)
 - /users/{user}/{mode?} (Get User)

Beatmaps
 - /beatmaps/{beatmap} (Get Beatmap)
 - /beatmaps/{beatmap}/scores/users/{user} (Get a User Beatmap score)
 - /beatmaps/{beatmap}/scores/users/{user}/all (Get all User Beatmap score)
 - /beatmaps/{beatmap}/scores (Get Beatmap scores)
 - /beatmaps/lookup (Lookup Beatmap)

Beatmapsets
 - /beatmapsets/{beatmapset} (Get Beatmapset)
 - /beatmapsets/search/{filters?} (Search beatmapsets)

Scores
 - /scores/{mode}/{score} (Get Score)
 - /scores/{mode}/{score}/download (Get Replay ; Needs Authorization Code Grant)

OAuth Tokens
 - /oauth/tokens/current (Revoke current token)

Misc
 - /seasonal-backgrounds (Get Current Seasonal Backgrounds ; No Auth)

Contact

You can join my personal Discord server: https://discord.gg/UugbeH8

Thanks

Thanks to the following contributors:

Thanks to JetBrains for giving an open source license for their products!

<a href="https://www.jetbrains.com/?from=jensyl"><img src="imgs/jetbrains.svg" alt="JetBrains IDEs" width="150px"></img></a>

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on OsuSharp:

Package Downloads
OsuSharp.Analyzer

Analyzers for the unofficial wrapper of the osu! API (V1) written in C# and compatible with .NET Standard 2.0

OsuSharp.Oppai

Oppai API for the unofficial wrapper of the osu! API (V1) written in C# and compatible with .NET Standard 2.0. This can be used if you don't use the OsuSharp wrapper (but has the dependency for Mode enum bitflags)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.4.1 2,660 12/30/2023
6.4.0 452 11/21/2023
6.3.2 422 10/21/2023
6.3.1 924 9/10/2023
6.3.0 579 9/10/2023
6.2.4 996 9/28/2022
6.2.3 936 9/23/2022
6.2.2 879 6/23/2022
6.2.1 938 6/17/2022
6.2.0 1,025 4/4/2022
6.1.0 960 3/13/2022
6.0.0 914 3/7/2022
5.6.1 3,964 11/28/2021
5.6.0 1,748 7/31/2021
5.5.0 1,472 7/1/2021
5.4.4 2,139 6/3/2020
5.4.3 1,699 6/2/2020
5.4.2 1,633 3/23/2020
5.4.1 1,646 3/23/2020
5.4.0 1,674 1/31/2020
5.3.2 1,691 1/19/2020
5.3.1 1,716 12/21/2019
5.3.0 1,735 11/19/2019
5.2.0 1,372 11/17/2019
5.1.0 1,687 11/17/2019
5.0.2 1,423 11/14/2019
5.0.1 1,391 11/13/2019
5.0.0 1,022 11/13/2019
3.2.8 1,813 1/18/2019 3.2.8 is deprecated because it is no longer maintained and has critical bugs.
3.2.7 1,800 11/30/2018 3.2.7 is deprecated because it is no longer maintained and has critical bugs.
3.2.6 1,664 11/30/2018 3.2.6 is deprecated because it is no longer maintained and has critical bugs.
3.2.5 1,366 11/30/2018 3.2.5 is deprecated because it is no longer maintained and has critical bugs.
3.2.3 1,373 11/30/2018 3.2.3 is deprecated because it is no longer maintained and has critical bugs.
3.2.2 1,341 11/30/2018 3.2.2 is deprecated because it is no longer maintained and has critical bugs.
3.2.1 1,310 11/30/2018 3.2.1 is deprecated because it is no longer maintained and has critical bugs.
3.2.0 1,793 11/6/2018 3.2.0 is deprecated because it is no longer maintained and has critical bugs.
3.1.3 1,440 10/1/2018 3.1.3 is deprecated because it is no longer maintained and has critical bugs.
3.0.2 1,394 10/1/2018 3.0.2 is deprecated because it is no longer maintained and has critical bugs.
3.0.0 1,375 9/24/2018 3.0.0 is deprecated because it is no longer maintained and has critical bugs.
2.0.1 1,751 6/22/2018 2.0.1 is deprecated because it is no longer maintained and has critical bugs.
2.0.0 1,595 6/21/2018 2.0.0 is deprecated because it is no longer maintained and has critical bugs.
1.7.0 1,602 6/20/2018 1.7.0 is deprecated because it is no longer maintained and has critical bugs.
1.6.1 1,607 6/20/2018 1.6.1 is deprecated because it is no longer maintained and has critical bugs.
1.6.0 1,803 3/31/2018 1.6.0 is deprecated because it is no longer maintained and has critical bugs.
1.5.2 1,701 3/9/2018 1.5.2 is deprecated because it is no longer maintained and has critical bugs.
1.5.1 1,651 3/8/2018 1.5.1 is deprecated because it is no longer maintained and has critical bugs.
1.5.0 1,774 2/23/2018 1.5.0 is deprecated because it is no longer maintained and has critical bugs.
1.4.5 1,664 2/16/2018 1.4.5 is deprecated because it is no longer maintained and has critical bugs.
1.4.3 1,682 1/16/2018 1.4.3 is deprecated because it is no longer maintained and has critical bugs.
1.4.1 1,926 12/19/2017 1.4.1 is deprecated because it is no longer maintained and has critical bugs.
1.4.0 1,858 12/12/2017 1.4.0 is deprecated because it is no longer maintained and has critical bugs.
1.3.0 1,859 10/21/2017 1.3.0 is deprecated because it is no longer maintained and has critical bugs.
1.2.4 2,033 8/8/2017 1.2.4 is deprecated because it is no longer maintained and has critical bugs.
1.2.3 1,960 8/7/2017 1.2.3 is deprecated because it is no longer maintained and has critical bugs.
1.2.2 1,988 8/6/2017 1.2.2 is deprecated because it is no longer maintained and has critical bugs.
1.2.1 2,004 8/6/2017 1.2.1 is deprecated because it is no longer maintained and has critical bugs.
1.2.0 1,933 8/6/2017 1.2.0 is deprecated because it is no longer maintained and has critical bugs.
1.1.1 1,937 7/28/2017 1.1.1 is deprecated because it is no longer maintained and has critical bugs.
1.1.0 1,911 7/28/2017 1.1.0 is deprecated because it is no longer maintained and has critical bugs.
1.0.5 1,889 7/28/2017 1.0.5 is deprecated because it is no longer maintained and has critical bugs.
1.0.4 1,907 7/28/2017 1.0.4 is deprecated because it is no longer maintained and has critical bugs.
1.0.3 2,007 7/27/2017 1.0.3 is deprecated because it is no longer maintained and has critical bugs.
1.0.2 2,103 6/27/2017 1.0.2 is deprecated because it is no longer maintained and has critical bugs.
1.0.1 1,722 6/27/2017 1.0.1 is deprecated because it is no longer maintained and has critical bugs.
1.0.0 1,851 6/27/2017 1.0.0 is deprecated because it is no longer maintained and has critical bugs.