Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/awaitlink/rvk
:package: A set of crates for easy access to the VK (VKontakte) API
https://github.com/awaitlink/rvk
api async await methods objects rust rust-crate vk vk-api vk-sdk
Last synced: about 2 months ago
JSON representation
:package: A set of crates for easy access to the VK (VKontakte) API
- Host: GitHub
- URL: https://github.com/awaitlink/rvk
- Owner: awaitlink
- License: mit
- Created: 2018-05-26T12:41:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-20T10:05:59.000Z (over 2 years ago)
- Last Synced: 2024-10-29T20:51:03.446Z (about 2 months ago)
- Topics: api, async, await, methods, objects, rust, rust-crate, vk, vk-api, vk-sdk
- Language: Rust
- Homepage: https://docs.rs/rvk
- Size: 509 KB
- Stars: 24
- Watchers: 4
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# `rvk`
> A set of crates to be able to easily access VK (VKontakte) API in Rust.
The combined changelog for all crates is available [here](https://github.com/u32i64/rvk/blob/master/CHANGELOG.md).
## Crates
- [`rvk`](https://crates.io/crates/rvk) ([docs](https://docs.rs/rvk)) — simple crate for accessing VK API (using `async`/`await`);
- [`rvk_methods`](https://crates.io/crates/rvk_methods) ([docs](https://docs.rs/rvk_methods)) — provides VK API [methods](https://vk.com/dev/methods) to avoid the need to specify them as strings, depends on `rvk` to call the methods;
- [`rvk_objects`](https://crates.io/crates/rvk_objects) ([docs](https://docs.rs/rvk_objects)) — represents various [objects](https://vk.com/dev/objects) that are returned as JSON by the VK API.Note that for `rvk_methods` and `rvk_objects`, the supported versions of the VK API may be different.
Consult the `API_VERSION` constant in these crates to learn which versions they support.## Usage
Add the necessary dependencies to your project. For example, to use all 3:`Cargo.toml`
```toml
[dependencies]
rvk = "0.23"
rvk_methods = "0.1"
rvk_objects = "0.1"
```Now you can take a look at the documentation (linked above for each crate) to learn more about the available functions.
## Example using all 3 crates
To use this example, you will **also** need the [`tokio`](https://crates.io/tokio) crate for the `tokio::main` attribute proc macro.
### `Cargo.toml`
```toml
[dependencies]
tokio = { version = "1.0", features = ["full"] }
```### `main.rs`
```rust
use rvk::Params;
use rvk_methods::users;
use rvk_objects::user::User;#[tokio::main]
async fn main() {
// Create an API client that uses the API version supported by `rvk_methods`.
let api = rvk_methods::supported_api_client("your_access_token");// A HashMap to store parameters.
let mut params = Params::new();
params.insert("user_ids".into(), "1".into());// Use a type from `rvk_objects` as the result type.
let res = users::get::>(&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),
};
}
```