Expand description
Asynchronous client for Misskey.
We provide four components in this crate:
- Clients that handles the connection between Misskey. As Misskey provides HTTP and WebSocket
interfaces to interact with, we have
HttpClient
andWebSocketClient
implementations correspondingly. - API bindings, including requests/responses of endpoints and messages on channels.
- Abstraction that connects API datatypes and client implementations:
Request
,ConnectChannelRequest
, etc. - High-level API for easier handling of various functionalities:
ClientExt
and others.
Examples
Create a note:
use misskey::prelude::*;
use misskey::HttpClient;
let client = HttpClient::builder("https://your.instance.example/api/")
.token("API_TOKEN")
.build()?;
client.create_note("Hello, Misskey").await?;
Automatically follow-back:
use futures::stream::TryStreamExt;
use misskey::prelude::*;
use misskey::streaming::channel::main::MainStreamEvent;
use misskey::WebSocketClient;
let client = WebSocketClient::builder("wss://your.instance.example/streaming")
.token("YOUR_API_TOKEN")
.connect()
.await?;
// Connect to the main stream.
// The main stream is a channel that streams events about the connected account.
let mut stream = client.main_stream().await?;
// Wait for the next event in the main stream.
while let Some(event) = stream.try_next().await? {
match event {
// Check if the event is 'followed' and the user is not a bot
MainStreamEvent::Followed(user) if !user.is_bot => {
println!("followed from @{}", user.username);
// Follow back `user` if you haven't already.
if !client.is_following(&user).await? {
client.follow(&user).await?;
}
}
// other events are just ignored here
_ => {}
}
}
See the example directory for more examples.
Feature flags
http-client
: Enables the HTTP client which is capable for uploading files. Enabled by default.websocket-client
: Enables the WebSocket client which is capable for streaming. Enabled by default.tokio-runtime
: Use the tokio v0.3 runtime in the WebSocket client. Enabled by default.tokio02-runtime
: Use the tokio v0.2 runtime in the WebSocket client.async-std-runtime
: Use the async-std runtime in the WebSocket client.aid
: Assume that theaid
ID generation method is used in the targeted Misskey instance. Enabled by default.meid
: Assume that themeid
ID generation method is used in the targeted Misskey instance.ulid
: Assume that theulid
ID generation method is used in the targeted Misskey instance.objectid
: Assume that theobjectid
ID generation method is used in the targeted Misskey instance.- and version flags, as described in version flags section.
Specifying Misskey version
We have a set of feature flags to specify the targeted Misskey version.
For example, to compile for Misskey v12.33.0 with WebSocket client on async-std runtime, add
the following to your Cargo.toml
file:
[dependencies.misskey]
version = "0.3.0-rc.1"
default-features = false
features = ["12-31-0", "websocket-client", "async-std-runtime", "aid"]
Feature | Supported Misskey versions (inclusive) | Tested Misskey version |
---|---|---|
12-75-0 | v12.75.0 ~ v12.75.1 | v12.75.0 |
12-71-0 | v12.71.0 ~ v12.74.1 | v12.71.0 |
12-70-0 | v12.70.0 | v12.70.0 |
12-69-0 | v12.69.0 | v12.69.0 |
12-67-0 | v12.67.0 ~ v12.68.0 | v12.68.0 |
12-66-0 | v12.66.0 | v12.66.0 |
12-65-4 | v12.65.4 ~ v12.65.7 | v12.65.4 |
12-63-0 | v12.63.0 ~ v12.65.3 | v12.63.0 |
12-62-2 | v12.62.2 | v12.62.2 |
12-62-0 | v12.62.0 ~ v12.62.1 | v12.62.0 |
12-61-0 | v12.61.0 ~ v12.61.1 | v12.61.0 |
12-60-0 | v12.60.0 ~ v12.60.1 | v12.60.0 |
12-58-0 | v12.58.0 ~ v12.59.0 | v12.58.0 |
12-57-0 | v12.57.0 ~ v12.57.4 | v12.57.1 |
12-55-0 | v12.55.0 ~ v12.56.0 | v12.55.0 |
12-51-0 | v12.51.0 ~ v12.54.0 | v12.51.0 |
12-49-0 | v12.49.0 ~ v12.50.0 | v12.49.0 |
12-48-0 | v12.48.0 ~ v12.48.3 | v12.48.0 |
12-47-0 | v12.47.0 ~ v12.47.1 | v12.47.1 |
12-42-0 | v12.42.0 ~ v12.46.0 | v12.42.0 |
12-39-0 | v12.39.0 ~ v12.41.3 | v12.39.0 |
12-37-0 | v12.37.0 ~ v12.38.1 | v12.37.0 |
12-31-0 | v12.31.0 ~ v12.36.1 | v12.31.0 |
12-29-0 | v12.29.0 ~ v12.30.0 | v12.29.0 |
12-28-0 | v12.28.0 | v12.28.0 |
12-27-0 | v12.27.0 ~ v12.27.1 | v12.27.0 |
12-19-0 | v12.19.0 ~ v12.26.0 | v12.20.0 |
12-13-0 | v12.13.0 ~ v12.18.1 | v12.13.0 |
12-10-0 | v12.10.0 ~ v12.12.0 | v12.10.0 |
12-9-0 | v12.9.0 | v12.9.0 |
12-8-0 | v12.8.0 | v12.8.0 |
12-5-0 | v12.5.0 ~ v12.7.1 | v12.5.0 |
(no version flag enabled) | v12.0.0 ~ v12.4.1 | v12.0.0 |
Modules
Builder types.
API endpoints.
http-client
Asynchronous HTTP-based client.
Object types used in API.
Implementation of pagination.
Prelude for crates using misskey-rs
.
Streaming API.
websocket-client
Asynchronous WebSocket-based client.
Structs
http-client
Asynchronous HTTP-based client for Misskey.
websocket-client
Asynchronous WebSocket-based client for Misskey.
Enums
Possible errors from the high-level API.
Point on the timeline.
Range in the timeline.
Traits
Abstraction over API clients.
Abstraction over API clients with streaming connections.
An extension trait for StreamingClient
that provides convenient high-level APIs.
Abstraction over API clients that can upload files.
An extension trait for UploadFileClient
that provides convenient high-level APIs.