vrcapi

package module
v0.0.0-...-241def6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 12 Imported by: 0

README

VRChat API Library for Golang

Go Reference Go Report Card

A Golang client to interact with the unofficial VRChat API. Supports all REST calls specified in https://github.com/vrchatapi/specification.

Getting Started

Install
go get github.com/g0dm0d/vrcapi
Usage

Import the package into your project.

import "github.com/g0dm0d/vrcapi"

Examples

Below is a list of examples:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EndpointVRC = "https://vrchat.com/"
	EndpointAPI = "https://api.vrchat.cloud/api/1/"

	EndpointLogin = EndpointAPI + "auth/user"
	Endpoint2FA   = EndpointAPI + "auth/twofactorauth/totp/verify"

	EndpointGetInstance = func(worldId string, instanceId InstanceId) string {
		return EndpointAPI + "instances/" + worldId + ":" + instanceId.String()
	}

	EndpointInstance = func(worldId string, instanceId InstanceId) string {
		return EndpointAPI + "instances/" + worldId + ":" + instanceId.String()
	}

	// EndpointInstanceLaunch https://vrchatapi.github.io/tutorials/instances/
	EndpointInstanceLaunch = func(worldId string, instanceId InstanceId) string {
		return EndpointVRC + "home/launch?" + "worldId=" + worldId + "&" +
			"instanceId=" + instanceId.String()
	}

	EndpointInviteUser = func(userId string) string {
		return EndpointAPI + "invite/" + userId
	}

	EndpointInviteMyself = func(instance string) string {
		return EndpointAPI + "invite/myself/to/" + instance
	}

	EndpointRequestInvite = func(userId string) string {
		return EndpointAPI + "requestInvite/" + userId
	}

	EndpointRespondInvite = func(notifyId string) string {
		return EndpointAPI + "invite/" + notifyId + "/response"
	}

	EndpointListInviteMessages = func(userId string, messageType MessageType) string {
		return EndpointAPI + "message/" + userId + "/" + string(messageType)
	}

	EndpointGetInviteMessage = func(userId string, messageType MessageType, slot int) string {
		return EndpointAPI + "message/" + userId + "/" + string(messageType) + "/" + strconv.Itoa(slot)
	}

	EndpointUpdateInviteMessage = func(userId string, messageType MessageType, slot int) string {
		return EndpointAPI + "message/" + userId + "/" + string(messageType) + "/" + strconv.Itoa(slot)
	}

	EndpointResetInviteMessage = func(userId string, messageType MessageType, slot int) string {
		return EndpointAPI + "message/" + userId + "/" + string(messageType) + "/" + strconv.Itoa(slot)
	}

	EndpointGetOwnAvatar = func(userID string) string {
		return EndpointAPI + "user/" + userID + "/avatar"
	}

	EndpointListFriends = EndpointAPI + "auth/user/friends?offline=true"

	EndpointFriendRequest = func(userID string) string {
		return EndpointAPI + "user/" + userID + "/friendRequest"
	}

	EndpointCheckFriendStatus = func(userID string) string {
		return EndpointAPI + "user/" + userID + "/friendStatus"
	}

	EndpointUnfriend = func(userID string) string {
		return EndpointAPI + "auth/user/friends/" + userID
	}
)

Functions

This section is empty.

Types

type Avatar

type Avatar struct {
	AssetUrl       string `json:"assetUrl"`
	AssetUrlObject struct {
	} `json:"assetUrlObject"`
	AuthorId          string    `json:"authorId"`
	AuthorName        string    `json:"authorName"`
	CreatedAt         time.Time `json:"created_at"`
	Description       string    `json:"description"`
	Featured          bool      `json:"featured"`
	Id                string    `json:"id"`
	ImageUrl          string    `json:"imageUrl"`
	Name              string    `json:"name"`
	ReleaseStatus     string    `json:"releaseStatus"`
	Tags              []string  `json:"tags"`
	ThumbnailImageUrl string    `json:"thumbnailImageUrl"`
	UnityPackageUrl   string    `json:"unityPackageUrl"`
	UnityPackages     []struct {
		AssetUrl       string `json:"assetUrl"`
		AssetUrlObject struct {
		} `json:"assetUrlObject"`
		AssetVersion    int       `json:"assetVersion"`
		CreatedAt       time.Time `json:"created_at"`
		Id              string    `json:"id"`
		Platform        string    `json:"platform"`
		PluginUrl       string    `json:"pluginUrl"`
		PluginUrlObject struct {
		} `json:"pluginUrlObject"`
		UnitySortNumber int64  `json:"unitySortNumber"`
		UnityVersion    string `json:"unityVersion"`
	} `json:"unityPackages"`
	UpdatedAt time.Time `json:"updated_at"`
	Version   int       `json:"version"`
}

type CurrentUser

type CurrentUser struct {
	AcceptedTOSVersion     int    `json:"acceptedTOSVersion"`
	AcceptedPrivacyVersion int    `json:"acceptedPrivacyVersion"`
	AccountDeletionDate    string `json:"accountDeletionDate"`
	AccountDeletionLog     []struct {
		Message           string    `json:"message"`
		DeletionScheduled time.Time `json:"deletionScheduled"`
		DateTime          time.Time `json:"dateTime"`
	} `json:"accountDeletionLog"`
	ActiveFriends                  []string  `json:"activeFriends"`
	AllowAvatarCopying             bool      `json:"allowAvatarCopying"`
	Bio                            string    `json:"bio"`
	BioLinks                       []string  `json:"bioLinks"`
	CurrentAvatar                  string    `json:"currentAvatar"`
	CurrentAvatarAssetUrl          string    `json:"currentAvatarAssetUrl"`
	CurrentAvatarImageUrl          string    `json:"currentAvatarImageUrl"`
	CurrentAvatarThumbnailImageUrl string    `json:"currentAvatarThumbnailImageUrl"`
	CurrentAvatarTags              []string  `json:"currentAvatarTags"`
	DateJoined                     string    `json:"date_joined"`
	DeveloperType                  string    `json:"developerType"`
	DisplayName                    string    `json:"displayName"`
	EmailVerified                  bool      `json:"emailVerified"`
	FallbackAvatar                 string    `json:"fallbackAvatar"`
	FriendKey                      string    `json:"friendKey"`
	Friends                        []string  `json:"friends"`
	HasBirthday                    bool      `json:"hasBirthday"`
	HideContentFilterSettings      bool      `json:"hideContentFilterSettings"`
	UserLanguage                   string    `json:"userLanguage"`
	UserLanguageCode               string    `json:"userLanguageCode"`
	HasEmail                       bool      `json:"hasEmail"`
	HasLoggedInFromClient          bool      `json:"hasLoggedInFromClient"`
	HasPendingEmail                bool      `json:"hasPendingEmail"`
	HomeLocation                   string    `json:"homeLocation"`
	Id                             string    `json:"id"`
	IsFriend                       bool      `json:"isFriend"`
	LastActivity                   time.Time `json:"last_activity"`
	LastLogin                      time.Time `json:"last_login"`
	LastPlatform                   string    `json:"last_platform"`
	ObfuscatedEmail                string    `json:"obfuscatedEmail"`
	ObfuscatedPendingEmail         string    `json:"obfuscatedPendingEmail"`
	OculusId                       string    `json:"oculusId"`
	GoogleId                       string    `json:"googleId"`
	PicoId                         string    `json:"picoId"`
	ViveId                         string    `json:"viveId"`
	OfflineFriends                 []string  `json:"offlineFriends"`
	OnlineFriends                  []string  `json:"onlineFriends"`
	PastDisplayNames               []struct {
		DisplayName string    `json:"displayName"`
		UpdatedAt   time.Time `json:"updated_at"`
	} `json:"pastDisplayNames"`
	Presence struct {
		AvatarThumbnail     string   `json:"avatarThumbnail"`
		DisplayName         string   `json:"displayName"`
		Groups              []string `json:"groups"`
		Id                  string   `json:"id"`
		Instance            string   `json:"instance"`
		InstanceType        string   `json:"instanceType"`
		IsRejoining         string   `json:"isRejoining"`
		Platform            string   `json:"platform"`
		ProfilePicOverride  string   `json:"profilePicOverride"`
		Status              string   `json:"status"`
		TravelingToInstance string   `json:"travelingToInstance"`
		TravelingToWorld    string   `json:"travelingToWorld"`
		World               string   `json:"world"`
	} `json:"presence"`
	ProfilePicOverride string   `json:"profilePicOverride"`
	State              string   `json:"state"`
	Status             string   `json:"status"`
	StatusDescription  string   `json:"statusDescription"`
	StatusFirstTime    bool     `json:"statusFirstTime"`
	StatusHistory      []string `json:"statusHistory"`
	SteamDetails       struct {
	} `json:"steamDetails"`
	SteamId                  string    `json:"steamId"`
	Tags                     []string  `json:"tags"`
	TwoFactorAuthEnabled     bool      `json:"twoFactorAuthEnabled"`
	TwoFactorAuthEnabledDate time.Time `json:"twoFactorAuthEnabledDate"`
	Unsubscribe              bool      `json:"unsubscribe"`
	UpdatedAt                time.Time `json:"updated_at"`
	UserIcon                 string    `json:"userIcon"`
}

type Error

type Error struct {
	Error struct {
		Message    string `json:"message"`
		StatusCode int    `json:"status_code"`
	} `json:"error"`
}

type FriendStatus

type FriendStatus struct {
	IsFriend        bool `json:"isFriend"`
	OutgoingRequest bool `json:"outgoingRequest"`
	IncomingRequest bool `json:"incomingRequest"`
}

type InstanceId

type InstanceId struct {
	Name    string
	Privacy Privacy
	Region  Region
	OwnerID string
	UUID    string
}

func (*InstanceId) String

func (i *InstanceId) String() string

type InviteRequest

type InviteRequest struct {
	InstanceId  string `json:"instanceId"`
	MessageSlot int    `json:"messageSlot"`
}

type InviteResponse

type InviteResponse struct {
	MessageSlot int `json:"messageSlot"`
}

type LimitedUser

type LimitedUser struct {
	Bio                            string   `json:"bio"`
	CurrentAvatarImageUrl          string   `json:"currentAvatarImageUrl"`
	CurrentAvatarThumbnailImageUrl string   `json:"currentAvatarThumbnailImageUrl"`
	DeveloperType                  string   `json:"developerType"`
	DisplayName                    string   `json:"displayName"`
	FallbackAvatar                 string   `json:"fallbackAvatar"`
	Id                             string   `json:"id"`
	IsFriend                       bool     `json:"isFriend"`
	LastPlatform                   string   `json:"last_platform"`
	ProfilePicOverride             string   `json:"profilePicOverride"`
	Status                         string   `json:"status"`
	StatusDescription              string   `json:"statusDescription"`
	Tags                           []string `json:"tags"`
	UserIcon                       string   `json:"userIcon"`
	Location                       string   `json:"location"`
	FriendKey                      string   `json:"friendKey"`
}

type Message

type Message struct {
	CanBeUpdated             bool      `json:"canBeUpdated"`
	Id                       string    `json:"id"`
	Message                  string    `json:"message"`
	MessageType              string    `json:"messageType"`
	RemainingCooldownMinutes int       `json:"remainingCooldownMinutes"`
	Slot                     int       `json:"slot"`
	UpdatedAt                time.Time `json:"updatedAt"`
}

type MessageType

type MessageType string
const (
	DefaultMessage  MessageType = "message"
	Response        MessageType = "response"
	Request         MessageType = "request"
	RequestResponse MessageType = "requestResponse"
)

type Notification

type Notification struct {
	Id           string    `json:"id"`
	SenderUserId string    `json:"senderUserId"`
	Type         string    `json:"type"`
	Message      string    `json:"message"`
	Details      string    `json:"details"`
	Seen         bool      `json:"seen"`
	CreatedAt    time.Time `json:"created_at"`
}

type Privacy

type Privacy string
const (
	Public      Privacy = ""
	FriendsPlus Privacy = "~hidden(%s)"
	Friends     Privacy = "~friends(%s)"
	InvitePlus  Privacy = "~private(%s)~canRequestInvite"
	Invite      Privacy = "~private(%s)"
)

type Region

type Region string
const (
	EU  Region = "eu"
	USW Region = "usw"
	USE Region = "us"
	JP  Region = "jp"
)

type RequestInviteRequest

type RequestInviteRequest struct {
	MessageSlot int `json:"messageSlot"`
}

type SentNotification

type SentNotification struct {
	Id             string `json:"id"`
	RecieverUserId string `json:"recieverUserId"`
	SenderUserId   string `json:"senderUserId"`
	Type           string `json:"type"`
	Message        string `json:"message"`
	Details        string `json:"details"`
	CreatedAt      string `json:"created_at"`
}

type Session

type Session struct {
	Client *http.Client
	User   *CurrentUser
}

func New

func New() (*Session, error)

func (*Session) Auth

func (s *Session) Auth(login, password, twoFactorSecret string) error

func (*Session) CheckFriendStatus

func (s *Session) CheckFriendStatus(userId string) (response FriendStatus, err error)

func (*Session) DeleteFriendRequest

func (s *Session) DeleteFriendRequest(userId string) (response Success, err error)

func (*Session) GetInstance

func (s *Session) GetInstance(worldId string, instanceId InstanceId) error

func (*Session) GetInviteMessages

func (s *Session) GetInviteMessages(userId string, messageType MessageType, slot int) (response Message, err error)

func (*Session) GetOwnAvatar

func (s *Session) GetOwnAvatar(userId string) (response *Avatar, err error)

func (*Session) InitUser

func (s *Session) InitUser() error

func (*Session) InstanceLaunch

func (s *Session) InstanceLaunch(worldId string, instanceId InstanceId) error

func (*Session) InviteMySelf

func (s *Session) InviteMySelf(instanceId string) (response SentNotification, err error)

func (*Session) InviteUser

func (s *Session) InviteUser(instanceId, userId string) (response InviteResponse, err error)

func (*Session) ListFriends

func (s *Session) ListFriends(userId string) (response LimitedUser, err error)

func (*Session) ListInviteMessages

func (s *Session) ListInviteMessages(userId string, messageType MessageType) (response []Message, err error)

func (*Session) RequestInvite

func (s *Session) RequestInvite(userId string) (response Notification, err error)

func (*Session) ResetInviteMessage

func (s *Session) ResetInviteMessage(userId string, messageType MessageType, slot int) (response []Message, err error)

func (*Session) RespondInvite

func (s *Session) RespondInvite(notifyId string) (response Notification, err error)

func (*Session) SendFriendRequest

func (s *Session) SendFriendRequest(userId string) (response Notification, err error)

func (*Session) TwoFactorAuth

func (s *Session) TwoFactorAuth(twoFactorSecret string) error

func (*Session) Unfriend

func (s *Session) Unfriend(userId string) (response Success, err error)

func (*Session) UpdateInviteMessage

func (s *Session) UpdateInviteMessage(userId string, messageType MessageType, slot int, message string) (response []Message, err error)

type Success

type Success struct {
	Success struct {
		Message    string `json:"message"`
		StatusCode int    `json:"status_code"`
	} `json:"success"`
}

type TwoFactorAuthCode

type TwoFactorAuthCode struct {
	Code string `json:"code"`
}

type UpdateInviteMessageRequest

type UpdateInviteMessageRequest struct {
	Message string `json:"message"`
}

type Verify2FAResult

type Verify2FAResult struct {
	Verified bool `json:"verified"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL