GithubHelp home page GithubHelp logo

mastodot's Introduction

Mastodot - Mastodon API library for C# (.NET)

NuGetBadge

日本語はこちら

Sample code

See example

Sample code contains how to generate tokens, toot, and subscribe stream.

Regist an app to Mastodon Instance

var registeredApp = await ApplicationManager.RegistApp("Host name" /* ex: mastodon.cloud */, "Your Application Name", Scope.Read | Scope.Write | Scope.Follow);

registeredApp contains ClienID and ClientSecret.

Login and get AccessToken

// if login by email
var tokens = ApplicationManager.GetAccessTokenByEmail(registeredApp, "Email", "Password");

// if login by use OAuth
var url = ApplicationManager.GetOAuthUrl(registeredApp);
// access this url via browser, HttpClient, ...
var tokens = await ApplicationManager.GetAccessTokenByCode(registeredApp, "Code that Browser shows");

tokens contains AccessToken. You can access Mastodon API by using this AccessToken.

Using Mastodon API

This code is how to Toot.

var client = new MastodonClient("Host name (url)", tokens.AccessToken);
client.PostNewStatus(status: "Hello Mastodon!");
// With media
var attachment = await client.UploadMedia("File Path");
client.PostNewStatus("Look my cuuuuute dog!", mediaIds: new int[]{attachment.Id});

and Using StreamAPI

var publicStream = client.GetObservablePublicTimeline()
                    .OfType<Status>()
                    .Subscribe(x => Console.WriteLine($"{x.Account.FullUserName} Tooted: {x.Content}"));

MastodonAPIs

Mastodon APIs

All APIs is ready

Accounts

  • GET /api/v1/accounts/:id
  • GET /api/v1/accounts/verify_credentials
  • PATCH /api/v1/accounts/update_credentials
  • GET /api/v1/accounts/:id/followers
  • GET /api/v1/accounts/:id/following
  • GET /api/v1/accounts/:id/statuses
  • POST /api/v1/accounts/:id/follow
  • POST /api/v1/accounts/:id/unfollow
  • POST /api/v1/accounts/:id/block
  • POST /api/v1/accounts/:id/unblock
  • POST /api/v1/accounts/:id/mute
  • POST /api/v1/accounts/:id/unmute
  • GET /api/v1/accounts/relationships
  • GET /api/v1/accounts/search

Apps

  • POST /api/v1/apps

Blocks

  • GET /api/v1/blocks

Favourites

  • GET /api/v1/favourites

Follow Requests

  • GET /api/v1/follow_requests
  • POST /api/v1/follow_requests/:id/authorize
  • POST /api/v1/follow_requests/:id/reject

Follows

  • POST /api/v1/follows

Instances

  • GET /api/v1/instance

Media

  • POST /api/v1/media

Mutes

  • GET /api/v1/mutes

Notifications

  • GET /api/v1/notifications
  • GET /api/v1/notifications/:id
  • POST /api/v1/notifications/clear

Reports

  • GET /api/v1/reports
  • POST /api/v1/reports

Search

  • GET /api/v1/search

Statuses

  • GET /api/v1/statuses/:id
  • GET /api/v1/statuses/:id/context
  • GET /api/v1/statuses/:id/card
  • GET /api/v1/statuses/:id/reblogged_by
  • GET /api/v1/statuses/:id/favourited_by
  • POST /api/v1/statuses
  • DELETE /api/v1/statuses/:id
  • POST /api/v1/statuses/:id/reblog
  • POST /api/v1/statuses/:id/unreblog
  • POST /api/v1/statuses/:id/favourite
  • POST /api/v1/statuses/:id/unfavourite

Timelines

  • GET /api/v1/timelines/home
  • GET /api/v1/timelines/public
  • GET /api/v1/timelines/tag/:hashtag

Streaming

  • GET /api/v1/streaming/user
  • GET /api/v1/streaming/public
  • GET /api/v1/streaming/hashtag

License

MIT

Other

Welcode pull requests!

For developer

For support multi target frameworks, Mastodot.csproj is not supported format.

When edit and debug this library, replace <TargetFrameworks>netstandard1.1;netstandard1.3</TargetFrameworks> to <TargetFramework>netstandard1.1</TargetFramework> or <TargetFramework>netstandard1.1</TargetFramework>

mastodot's People

Contributors

iknowbashfu avatar yamachu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.