35 releases (19 breaking)
0.20.0 | Jan 12, 2021 |
---|---|
0.19.0 | Dec 21, 2020 |
0.18.0 | Jul 30, 2020 |
0.15.0 | Mar 27, 2020 |
0.5.0 | Jul 19, 2018 |
#23 in HTTP client
89 downloads per month
Used in vk-bot
170KB
2K
SLoC
rvk
A crate for accessing VK (VKontakte) API in Rust (asynchronously).
The version of VK API that is used by this crate can be found here. Changelog is available here.
Modules
api
- works with the API;error
- handles errors that may occur during an API call;methods
- contains API methods;objects
- contains API objects. See also note about objects.
Usage
Add the dependency to your project:
Cargo.toml
[dependencies]
rvk = "0.20"
Now you can take a look at rvk
's API documentation to learn more about the available functions.
Example
To use this example, you will also need the tokio
crate for the tokio::main
attribute proc macro.
Cargo.toml
[dependencies]
tokio = { version = "1.0", features = ["full"] }
main.rs
use rvk::{methods::users, objects::user::User, APIClient, Params};
#[tokio::main]
async fn main() {
let api = APIClient::new("your_access_token"); // Create an API Client
let mut params = Params::new(); // Create a HashMap to store parameters
params.insert("user_ids".into(), "1".into());
let res = users::get::<Vec<User>>(&api, params).await;
match res {
Ok(users) => {
let user: &User = &users[0];
println!(
"User #{} is {} {}.",
user.id, user.first_name, user.last_name
);
}
Err(e) => println!("{}", e),
};
}
Notes
Objects
Due to the nature of the VK API documentation, it is not always clear if the value is always passed or not, and sometimes the data type is not defined.
If you spot any mistakes or bugs, please report them!
Dependencies
~3.5–7.5MB
~175K SLoC