[−][src]Crate misskey
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.
The latest one (12-63-0
) is enabled as a default. You can opt-in to compile for prior
Misskey version by using default-features = false
and the corresponding feature flag.
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.2"
default-features = false
features = ["12-31-0", "websocket-client", "async-std-runtime", "aid"]
Feature | Supported Misskey versions (inclusive) | Tested Misskey version |
---|---|---|
12-63-0 | v12.63.0 | 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 | Builder types. |
endpoint | API endpoints. |
http | http-client Asynchronous HTTP-based client. |
model | Object types used in API. |
pager | Implementation of pagination. |
prelude | Prelude for crates using |
streaming | Streaming API. |
websocket | websocket-client Asynchronous WebSocket-based client. |
Structs
HttpClient | http-client Asynchronous HTTP-based client for Misskey. |
WebSocketClient | websocket-client Asynchronous WebSocket-based client for Misskey. |
Enums
Error | Possible errors from the high-level API. |
TimelineCursor | Point on the timeline. |
TimelineRange | Range in the timeline. |
Traits
Client | Abstraction over API clients. |
ClientExt | An extension trait for |
StreamingClient | Abstraction over API clients with streaming connections. |
StreamingClientExt | An extension trait for |
UploadFileClient | Abstraction over API clients that can upload files. |
UploadFileClientExt | An extension trait for |