@kindlyfire/vrchatapi

0.0.3 • Public • Published

VRChatAPI

This is a VRChat API wrapper. It uses the API types from vrchatapi-javascript, and only depends on an up-to-date version of axios. It only has wrapper methods for endpoints I make use of, but you can make arbitrary requests using the preconfigured Axios instance and the exported types.

It also has a few helper functions.

The project was created to have a nicer-to-use alternative to vrchatapi-javascript.

Installation

Use your preferred package manager:

npm i @kindlyfire/vrchatapi
yarn add @kindlyfire/vrchatapi
pnpm add @kindlyfire/vrchatapi
bun add @kindlyfire/vrchatapi

Disclaimer

Copied from vrchatapi-javascript:

Use of the API using applications other than the approved methods (website, VRChat application) are not officially supported. You may use the API for your own application, but keep these guidelines in mind:

  • We do not provide documentation or support for the API.
  • Do not make queries to the API more than once per 60 seconds.
  • Abuse of the API may result in account termination.
  • Access to API endpoints may break at any given time, with no warning.

Examples

Constructing an instance:

const vrc = new VRChatApi({
	// Make sure to use this format for the user agent, but you must change it
	// to something else.
	userAgent: 'TimmyFriendTracker/1.5.1 timmy@example.com',
	authToken: '...', // optional
})

// You can make a new instance and update options through `.withOptions()`. The
// below is the same as the above:
const vrc = new VRChatApi({
	userAgent: 'TimmyFriendTracker/1.5.1 timmy@example.com',
}).withOptions({
	authToken: '...',
})

Authenticating:

// Get token
const vrc = new VRChatApi({
	userAgent: 'TimmyFriendTracker/1.5.1 timmy@example.com',
})
const authResult = await vrc.auth.login('myuser', 'mypass')
console.log('Token is', authResult.token)
if ('requiresTwoFactorAuth' in authResult.data) {
	console.log('2fa required')
}

// Submit 2fa
const vrc = new VRChatApi({
	userAgent: '...',
	authToken: 'myauthtoken',
})
const result = await vrc.auth.verify2fa('000000')
if (result.data.verified) {
	console.log('2fa succeeded')
}

Once you have a token that is verified, requests can be made:

const vrc = new VRChatApi({
	userAgent: '...',
	authToken: 'myauthtoken',
})
const user = await vrc.user.get()
console.log('Logged in as', user)

List of APIs

The wrapper methods do not cover all API endpoints, but you can easily use the preconfigured Axios instance to make requests to other endpoints.

  • auth.login(username, password)
  • auth.verify2fa(code, kind?)
  • user.get() (returns the logged-in user)
  • user.getFriends(params)
  • user.getNotifications(params)
  • user.acceptNotification(notificationId)
  • user.hideNotification(notificationId)
  • users.get(id)
  • users.search(query)
  • groups.get(groupId, includeRoles)
  • groups.getMember(groupId, userId)
  • groups.getInstances(groupId)
  • groups.kickMember(groupId, userId)
  • groups.banMember(groupId, userId)
  • groups.removeMemberRole(groupId, userId, roleId)
  • groups.addMemberRole(groupId, userId, roleId)
  • instances.get(worldId, instanceId)

An example of making a request to another endpoint (sending a friend request):

import { Notification, VRChatApi } from '@kindlyfire/vrchatapi'

const vrc = new VRChatApi({
	userAgent: '...',
	authToken: 'myauthtoken',
})
const res = await vrc.axios.post<Notification>(`user/usr_000/friendRequest`)

All endpoints can be seen on vrchatapi.github.io.

Utilities

  • Instance method: util.getUserByLinkOrDisplayName(linkOrDisplayName)
  • Exported: getTrustLevelFromTags(tags)
  • Exported: matchUserProfileLink(link)

License

MIT. See LICENSE file.

Dependents (0)

Package Sidebar

Install

npm i @kindlyfire/vrchatapi

Weekly Downloads

1

Version

0.0.3

License

none

Unpacked Size

319 kB

Total Files

6

Last publish

Collaborators

  • kindlyfire