vrchat_dart 0.6.2 copy "vrchat_dart: ^0.6.2" to clipboard
vrchat_dart: ^0.6.2 copied to clipboard

outdated

This is a Dart client that interacts with the unofficial VRChat API

example/main.dart

import 'package:vrchat_dart/vrchat_dart.dart';

void main() async {
  final api = VrchatDart(userAgent: 'vrchat_dart_example').api;

  final loginResponse = await api.auth.login(
    username: 'example',
    password: 'hunter2',
  );

  if (loginResponse.error != null) {
    print('authError');
    print(loginResponse.error);
  } else if (loginResponse.requiresTwoFactorAuth) {
    print('requiresTwoFactorAuth');
    final twoFactorResponse = await api.auth.verify2fa('123456');
    if (twoFactorResponse.error == null) {
      print('2fa verification success');
    } else {
      print('2fa verification failure');
      print(twoFactorResponse.error);
    }
  }

  if (api.auth.currentUser != null) {
    print('Logged in');
    print(api.auth.currentUser?.username);
  }

  // An API key must be fecthed for most other calls to succeed
  final apiKeyResponse = await api.fetchApiKey();
  if (apiKeyResponse.error != null) {
    print(apiKeyResponse.error);
    return;
  }

  print('fetched api key');

  final friendsResponse = await api.rawApi.getFriendsApi().getFriends();
  print(friendsResponse.data?.first.username);
}