#vr-chat #api-bindings #social-vr #api #borrow

vrc

Unofficial rust types of VRChat's API

9 unstable releases (3 breaking)

0.3.0 Feb 4, 2024
0.2.0 Jan 27, 2024
0.1.1 Apr 15, 2023
0.1.0 Mar 8, 2023
0.0.0-alpha.0 Jan 8, 2023

#237 in Game dev

23 downloads per month
Used in 5 crates (4 directly)

MPL-2.0 license

70KB
1.5K SLoC

VRChat API in rust

License Crates.io Docs

WIP rust models of VRChat's API.

This is fully unofficial and in no way affiliated, endorsed, supported, or created by VRChat.

Huge shoutout to the MIT licensed vrchatapi, which this crate borrows a lot from. If you're looking for a more mature project, please consider looking at their generated rust crate instead.

I disliked the generated nature of it though, and wanted more strong Rust-like things for some things, which is why this crate exists.

There's quite a bit missing, PRs are welcome to improve the situation, even beyond the plans:

Status Category Planned
Implemented Authentication More testing
None Avatars Getting a specific avatar only
None Economy None
None Favorites Eventual implementation
None Files None
Partial Friends Implementation soon
Partial Groups More testing
None Invites Listing invites only
Partial Instances Implementation soon
None Notifications Eventual implementation
None Permissions None
None System Eventual implementation of system statistics
Partial Users Planned to be implemented soon
Partial Worlds None, at least in the near term

The categories are from the awesome VRChat API Docs project.

Testing

The integration tests contact the live API. That's why they are ignored by default.

Pretty much all of them require authentication.

Sadly not all the things can even be reliably tested without creating a mock API. Which in turn defeats the purpose of the tests in the first place. So only some of the behavior is actually tested, though improvements to it are welcome.

Creating a user session manually

Getting the authentication for VRC takes a few steps due to it's usage of cookies, and 2fa requiring another request.

You can use the get_auth.py script for convenience. It's in python since it was created before the proper typed rust API client was ready. Note that you should've have logged in from the same IP address previously, as VRChat handles logins from new IPs differently which just breaks everything.

Running ignored tests

Make sure that you've got:

  • an internet connection
  • a valid user-sesion.json

Then just run the tests;

# A specific test with output logging
cargo test --all-features current_user -- --exact --ignored --nocapture
# All tests
cargo test --all-features -- --ignored

License

Note that the license is MPL-2.0 instead of the more common MIT OR Apache-2.0.

Dependencies

~3–19MB
~260K SLoC