Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

rvk

version downloads license api version

A crate for accessing VK (VKontakte) API in Rust (asynchronously).

Changelog is available here.

Modules

Usage

Add the dependency to your project:

Cargo.toml

[dependencies]
rvk = "0.21"

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!