Languages

Language SDKs allow you to quickly get started using the API in your language of choice, rather than having to (re-)implement all the HTTP methods from scratch.


Node SDK

NodeJS is a JavaScript runtime allowing you to write JavaScript or TypeScript on the backend. Go to Docs
// Step 1. We begin with creating a Configuration
// This contains the username and password for authentication.
const vrchat = require("vrchat");
const configuration = new vrchat.Configuration({
    username: "username",
    password: "password"
});

// Step 2. VRChat consists of several API's
// e.g. (WorldsApi, UsersApi, FilesApi, NotificationsApi, FriendsApi, etc...)
// Here we instantiate the Authentication API which is required for logging in.
const AuthenticationApi = new vrchat.AuthenticationApi(configuration);

// Step 3. Calling getCurrentUser on Authentication API
// logs you in if the user isn't already logged in.
AuthenticationApi.getCurrentUser().then(resp => {
    const currentUser = resp.data;
    console.log(`Logged in as: ${currentUser.displayName}`);
});

Python SDK

Python is an easy to learn scripting language for developing terminal or backend applications. Go to Docs
# Step 1. We begin with creating a Configuration, which contains the username and password for authentication.
import vrchatapi
from vrchatapi.api import authentication_api
from vrchatapi.exceptions import UnauthorizedException
from vrchatapi.models.two_factor_auth_code import TwoFactorAuthCode

configuration = vrchatapi.Configuration(
    username = 'username',
    password = 'password',
)

# Step 2. VRChat consists of several API's (WorldsApi, UsersApi, FilesApi, NotificationsApi, FriendsApi, etc...)
# Here we enter a context of the API Client and instantiate the Authentication API which is required for logging in.

# Enter a context with an instance of the API client
with vrchatapi.ApiClient(configuration) as api_client:

    # Instantiate instances of API classes
    auth_api = authentication_api.AuthenticationApi(api_client)

    try:
        # Step 3. Calling getCurrentUser on Authentication API logs you in if the user isn't already logged in.
        current_user = auth_api.get_current_user()
    except UnauthorizedException as e:
        if UnauthorizedException.status == 200:
            # Step 3.5. Calling verify2fa if the account has 2FA enabled
            auth_api.verify2_fa(two_factor_auth_code=TwoFactorAuthCode(input("2FA Code: ")))
            current_user = auth_api.get_current_user()
        else:
            print("Exception when calling API: %s\n", e)
    except vrchatapi.ApiException as e:
        print("Exception when calling API: %s\n", e)

    print("Logged in as:", current_user.display_name)

Java SDK

Java is a high-level, class-based OOP language for both desktop, backend and Android. Go to Docs
// Step 1. VRChat consists of several API's
// e.g. (WorldsApi, UsersApi, FilesApi, NotificationsApi, FriendsApi, etc...)
// Here we instantiate the Authentication API which is required for logging in.
ApiClient defaultClient = Configuration.getDefaultApiClient();
AuthenticationApi authApi = new AuthenticationApi(defaultClient);

// Step 2. We begin with creating a Configuration
// This contains the username and password for authentication.
HttpBasicAuth authHeader = (HttpBasicAuth) defaultClient.getAuthentication("authHeader");
authHeader.setUsername("username");
authHeader.setPassword("password");

// Step 3. Call getCurrentUser on Authentication API.
// This logs you in if the user isn't already logged in.
CurrentUser result = authApi.getCurrentUser();
System.out.println(result.getDisplayName());

Dart SDK

Dart is a client-side language allowing compilation for Android, iOS, web, and terminal. Go to Docs
// Step 1. Create instance of VRChatAPI
final api = VrchatDart(userAgent: 'VRChat Dart Demo').api;

// Step 2. Log in with authentication
final loginResponse = await api.auth.login(
  username: 'username',
  password: 'password',
);

// Step 3. Print out current user's username
if (api.auth.currentUser != null) {
  print(api.auth.currentUser?.username);
}

Rust SDK

Rust is a fast and secure language with no runtime nor garbace-collector, whos memory-management makes memory bugs impossible. Go to Docs
// Step 1. We begin with creating a Configuration
// This contains the username and password for authentication.
let config = apis::configuration::Configuration::default();

// Step 2. VRChat consists of several API's
// e.g. (WorldsApi, UsersApi, FilesApi, NotificationsApi, FriendsApi, etc...)
// Here we call the SystemAPI to fetch the number of users online.
let online = apis::system_api::get_current_online_users(&config).unwrap();

// Step 3. Print out the result!
println!("Current Online Users: {}", online);

C# SDK

C# is a high-level, class-based OOP langauge, part of .NET, and builds for desktop and Unity. Go to Docs
// Configure API key authorization: apiKeyCookie
Configuration.Default.Username = "username";
Configuration.Default.Password = "password";

try
{
    // Calling "GetCurrentUser" will log you in.
    AuthenticationApi authApi = new AuthenticationApi();
    var user = await authApi.GetCurrentUserAsync();
    Console.WriteLine($"Logged in user {user.DisplayName}");
}
catch (ApiException e)
{
    Debug.Print("Exception when calling API: " + e.Message);
    Debug.Print("Status Code: " + e.ErrorCode);
    Debug.Print(e.StackTrace);
}