Git Product home page Git Product logo

rvk's Introduction

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!

Features

There is a feature trace_response which helps to create reports more informative. If the feature is active the API methods save responses from vk.com into json files. The rules of saving are:

  • if parsing the response failed it is stored into ${RVK_TRACE_DIR}/failed/YY-MM-DD_HH-mm-SS.json file
  • otherwise, if ${RVK_TRACE_ALL}=1 the succeeded response is stored into ${RVK_TRACE_DIR}/succeeded/YY-MM-DD_HH-mm-SS.json file

rvk's People

Contributors

0xaae avatar awaitlink avatar dependabot-preview[bot] avatar humb1t avatar iaiao avatar prostomarkeloff avatar thedeax-lab avatar

Stargazers

 avatar

Forkers

yxiuz

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.