Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/potatomaster101/mojapi
Asynchronous Mojang API wrapper targeting .NET 5 and above
https://github.com/potatomaster101/mojapi
api api-wrapper async csharp dotnet mit-license mojang-api nuget
Last synced: about 1 month ago
JSON representation
Asynchronous Mojang API wrapper targeting .NET 5 and above
- Host: GitHub
- URL: https://github.com/potatomaster101/mojapi
- Owner: PotatoMaster101
- License: mit
- Created: 2021-06-13T10:52:05.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-12T11:30:43.000Z (about 3 years ago)
- Last Synced: 2024-11-08T16:29:37.763Z (3 months ago)
- Topics: api, api-wrapper, async, csharp, dotnet, mit-license, mojang-api, nuget
- Language: C#
- Homepage:
- Size: 38.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mojang API
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://github.com/PotatoMaster101/mojapi/blob/main/LICENCE)
[![.NET](https://github.com/PotatoMaster101/mojapi/actions/workflows/dotnet.yml/badge.svg)](https://github.com/PotatoMaster101/mojapi/actions/workflows/dotnet.yml)
[![Nuget](https://img.shields.io/nuget/v/PotatoMaster101.Mojapi)](https://www.nuget.org/packages/PotatoMaster101.Mojapi/)**Deprecation notice: This project will be archived once [PotatoMaster101/MojSharp](https://github.com/PotatoMaster101/MojSharp) is completed.**
An asynchronous [Mojang API](https://wiki.vg/Mojang_API) wrapper in C# targeting `.NET 5` and above.
## Build
Build with [`dotnet`](https://dotnet.microsoft.com/download):
```
$ dotnet build -c Release
```## Test
Run unit tests on local PC:
```
$ dotnet test -c Release
```Run unit tests in docker:
```
$ docker build -t mojapi .
```## Quick Start
### I want to authenticate!
```cs
var auth = await new AuthenticationEndpoint(new Credentials("username", "password")).Request();
Console.WriteLine(auth.Token.AccessToken);
Console.WriteLine(auth.Token.ClientToken);
```### Who the hell is this guy? Give me his past names!
```cs
var player = await new SingleUuidEndpoint("player").Request();
var history = await new NameHistoryEndpoint(player.Player.Uuid).Request();foreach (var (name, timestamp) in history.History)
Console.WriteLine($"{name}, {timestamp}");
```### Give me this guy's skin! I like it!
```cs
var player = await new SingleUuidEndpoint("player").Request();
var profile = await new ProfileEndpoint(player.Player.Uuid).Request();
Console.WriteLine(profile.Texture.SkinUrl);
```### Let me change my skin!
Change skin to a local file:
```cs
var skin = new Skin("some/minecraft/skin.png", Skin.SlimStyle); // or Skin.ClassicStyle
var upload = await new UploadSkinEndpoint("access token", skin).Request();
Console.WriteLine(upload.ChangedSkin.Url);
```Change skin to a network image:
```cs
var skin = new Skin("https://some/online/skin.png", Skin.SlimStyle); // or Skin.ClassicStyle
var upload = await new ChangeSkinEndpoint("access token", skin).Request();
Console.WriteLine(upload.ChangedSkin.Url);
```### More examples!
More sample projects can be found under `examples/`