Skip to content

TheGP/vrchat-go-with-proxy

 
 

Repository files navigation

VRChat API Library for Go with proxy & rate limiting

A Go client to interact with VRChat API. Supports all REST calls specified in the API specification.

The *.gen.go files are generated by using mayocream/openapi-codegen.

Disclaimer

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.

Usage

Basic Usage

package main

import (
	"fmt"
	"github.com/TheGP/vrchat-go-with-proxy"
	"time"
)

func main() {
	client := vrchat.NewClient("https://api.vrchat.cloud/api/1", time.Minute*1)

	// Authenticate with custom User-Agent
	userAgent := "my-custom-app/1.0 [email protected]"
	err := client.Authenticate("username", "password", "totp-code", userAgent)
	if err != nil {
		panic(err)
	}

	fmt.Println("Authenticated!")
}

Getting auth cookies

After authenticating, you can get the cookies using the GetCookies method:

// After authenticating:
cookies := client.GetCookies() // []*http.Cookie

To save them for later. If cookie authentication failed, you can clear them using the ClearCookies method:

client.ClearCookies()

You have to do it before authenticating normally.

Authenticate Using Cookies

If you have previously saved authentication cookies, you can authenticate using them:

package main

import (
	"github.com/TheGP/vrchat-go-with-proxy"
	"net/http"
	"time"
)

func main() {
	client := vrchat.NewClient("https://api.vrchat.cloud/api/1", time.Minute*1)

	// Load your cookies (from DB, file, etc)
	var cookies []*http.Cookie
	// ... load cookies ...

	userAgent := "my-custom-app/1.0 [email protected]"
	err := client.AuthenticateWithCookies(cookies, userAgent)
	if err != nil {
		panic(err)
	}

	// Now you can make authenticated requests
}

Using Proxy Support

This fork adds HTTP proxy support to the original VRChat Go client:

package main

import (
	"github.com/TheGP/vrchat-go-with-proxy"
	"time"
)

func main() {
	// Create proxy configuration
	proxyConfig := &vrchat.ProxyConfig{
		Host:     "proxy-host",     // Proxy server hostname or IP
		Port:     "8080",          // Proxy server port
		Username: "proxy-username", // Optional: proxy authentication username
		Password: "proxy-password", // Optional: proxy authentication password
	}

	client := vrchat.NewClientWithProxy("https://api.vrchat.cloud/api/1", proxyConfig, time.Minute*1)

	// Testing proxy
	ip, err := client.TestProxy()
	if err != nil {
		log.Fatalf("Proxy test failed: %v", err)
	}
	fmt.Println("Proxy IP:", ip)

	userAgent := "my-custom-app/1.0 [email protected]"
	err := client.Authenticate("username", "password", "totp-code", userAgent)
	if err != nil {
		panic(err)
	}

	// ...
}

About

VRChat Go OpenAPI client with proxy support & rate limiting

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.9%
  • Shell 0.1%