Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Gs redirect #68

Merged
merged 6 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Archive/ModerationAPI/Against.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://api.vrchat.cloud/api/1/auth/user/playermoderated


## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
18 changes: 0 additions & 18 deletions Authorization.md

This file was deleted.

2 changes: 1 addition & 1 deletion AvatarAPI/ChooseAvatar.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://api.vrchat.cloud/api/1/avatars/[ID]/select
ID - the avatar id

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
2 changes: 1 addition & 1 deletion AvatarAPI/DeleteAvatar.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ https://api.vrchat.cloud/api/1/avatars/[ID]
ID - the avatar id

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
2 changes: 1 addition & 1 deletion AvatarAPI/GetByID.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ https://api.vrchat.cloud/api/1/avatars/[ID]
ID - the avatar id

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
2 changes: 1 addition & 1 deletion AvatarAPI/ListAvatars.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GET
https://api.vrchat.cloud/api/1/avatars

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Parameters

Expand Down
2 changes: 1 addition & 1 deletion AvatarAPI/SaveAvatar.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ID - the user id
Any field in the [avatar](/AvatarAPI/GetByID.md) object

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
2 changes: 1 addition & 1 deletion FavoritesAPI/AddFavorite.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ POST
https://api.vrchat.cloud/api/1/favorites

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Parameters

Expand Down
2 changes: 1 addition & 1 deletion FavoritesAPI/DeleteFavorite.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ https://api.vrchat.cloud/api/1/favorites/[ID]
ID - The Favorite Id

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
2 changes: 1 addition & 1 deletion FavoritesAPI/GetFavorite.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ https://api.vrchat.cloud/api/1/favorites/[ID]
ID - The Favorite Id

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
2 changes: 1 addition & 1 deletion FavoritesAPI/ListAllFavorites.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GET
https://api.vrchat.cloud/api/1/favorites/

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Parameters

Expand Down
2 changes: 1 addition & 1 deletion FeedbackAPI/GetWorldFeedback.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ WORLDID - The world id you want to fetch info about
WORLDREVISION - The revision of the world you want to fetch info about.

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
2 changes: 1 addition & 1 deletion FileAPI/CreateFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ POST
https://api.vrchat.cloud/api/1/file

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Parameters

Expand Down
2 changes: 1 addition & 1 deletion FileAPI/CreateNewVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fileMd5 | base64 string | file md5 checksum
fileSizeInBytes | long | file size in bytes

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
2 changes: 1 addition & 1 deletion FileAPI/DeleteFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ https://api.vrchat.cloud/api/1/file/[FILEID]
FILEID - the file id

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
2 changes: 1 addition & 1 deletion FileAPI/FinishUpload.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ type - the file type
- signature

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns
2 changes: 1 addition & 1 deletion FileAPI/GetFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ https://api.vrchat.cloud/api/1/file/[FILEID]
fileId - the file id

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
2 changes: 1 addition & 1 deletion FileAPI/StartUpload.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ partNumber - optional, for larger files it allows to do a multiplart upload
- signature

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns
2 changes: 1 addition & 1 deletion FileAPI/UploadStatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GET
https://api.vrchat.cloud/api/1/file/[ID]/[VERSION]/[TYPE]/status

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns
unknown - currently it keep sending back server error
54 changes: 0 additions & 54 deletions GettingStarted.md

This file was deleted.

71 changes: 71 additions & 0 deletions GettingStarted/Examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Examples

## Updating your bio with curl

For updating our own social status we will be using the [Update User Info](/UserAPI/UpdateInfo) endpoint, which is a "PUT request". HTTP has various method types to indicate the intent of the request. The ones used with VRChat are as following:

* **GET** - For fetching information
* **POST** - For submitting **new** information
* **PUT** - For updating existing information
* **DELETE** - For deleting the targeted resource

GET requests does not have a message body, and can only carry arguments as parameters. This means arguments such as userId or search parameters are provided inside the URL.

```
https://example.com/some/path/<userId>?searchName=<serach>&condensed=true
```

POST and PUT requests carry a JSON-encoded message body, except for file-uploads which instead uses `multipart/form-data`.
As we in this case will send a PUT request we have to encode it as a JSON payload.

In this case we will use curl to send a "PUT" request to *update* your bio. In the following command we begin with specifying `-b cookiejar.txt` to use the authentication cookies aquired previously [during Authentication](/GettingStarted/QuickStart?id=authorization), `-X PUT` to make it a PUT request, `-A "My User Agent` to ethically identify yourself (this is needed for the firewall, give your app a unique agent name), `-H "Content-Type: application/json'` to tell the API we are sending a JSON payload, `-d '{"bio":"Hello API!"}'` which is the JSON payload itself, and finally the target URL to `api.vrchat.cloud`.

```bash
curl -b cookiejar.txt -X PUT -A "My User Agent" -H "Content-Type: application/json" -d '{"bio":"Hello API!"}' https://api.vrchat.cloud/api/1/users/<userId>
```

After successful query you should get an entire [`Current User object`](/Objects/User.md#current-user-object) back. This is a large JSON object representing the state of your entire account. By looking through this data we can see - close to the top - your bio has changed to "Hello API".

## Updating your bio with Insomnia

This tutorial asumes you already have [Insomnia](https://insomnia.rest/download) downloaded and installed. We will begin with creating a new "Request Collection" and name it "VRChat".

![Create a Collection](../assets/examples_insomnia1.png)

We will now create our first Request in order to authenticate with the API. Click "New Request" (cyan rectangle) and name it "Authenticate". We will let it be of type GET and click Create.

![Create first Request](../assets/examples_insomnia2.png)

Select `Basic > "Basic Auth"` and enter your VRChat username and password. The target URL should be set to `https://api.vrchat.cloud/api/1/auth/user` and click Send.

![Set username/password](../assets/examples_insomnia3.png)

!> **Ethical practice!** Make sure to always set a custom `User-Agent` under Headers, to properly identify your requests. <!-- Intentional two spaces for newlines -->
Good-practice is to set a short unique name for your application, as well as a contact method such as Discord. <!-- Intentional two spaces for newlines -->
![Set a User-Agent header](../assets/examples_insomnia7.png)

If successful then we should have gotten 3 new cookies, as indicated by the cyan rectangle below. In the future you can click "Cookies" **top-left** (pink rectangle) to see your cookies. We can also see in the response body our **userId** (yellow rectangle), it is important to keep this as we will need it for the next request.

![Successful authentication](../assets/examples_insomnia4.png)

Next we will create our second Request to update our Biography, click "New Request" indicated by the purple rectangle. We will name this one "Update Bio", we will set it to method type **PUT** and of body type **JSON**:

![Create second Request](../assets/examples_insomnia5.png)

Set the `User-Agent` again, although this time it is **important NOT to** set Auth again. Entering your username/password again will make you constantly request new session tokens, depleting your pool of available sessions and getting you rate-limited until the previous ones expire. Instead we will automatically authenticate with the cookies aquired in the previous Authentication request.

To finally update the Bio we set the URL to `https://api.vrchat.cloud/api/1/users/<userId>` where `<userId>` is **your** userId found in the previous request, and the message body set to the following:

```json
{
"bio": "Hello API!"
}
```

Click "Send" and we can see in the bottom right the Bio has now been updated to the new text:

![Update the Bio](../assets/examples_insomnia6.png)

?> **Congratulations!** You have now ready to explore the API. Please keep in mind the strict rate-limit, and that any abuse can lead to permanent account termination.

See [`Current User object`](/Objects/User.md#current-user-object) for a full list of values possible to set. Note some values such as `date_joined`, `last_login` and `friends` are either system-generated and not possible to change, or values which you change through other endpoints (such as adding friends through the Friends API).
78 changes: 78 additions & 0 deletions GettingStarted/QuickStart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Quick Start

!> **Super Important!** Usege of the API is **NOT** allowed for malicious purposes. Abuse of the API may result in account termination! Please read the [Disclaimer](/README?id=disclaimer) before getting started!

The VRChat API (application programming interface) can be used to programatically retrive or update information regarding your profile, friends, avatars and worlds. The API consists of two parts, "Photon" which is only used in-game, and the "Web API" which is used by both the game and the website, and which is the focus of this documentation.

The Web API operates over the HTTP protocol and transmits data in JSON format. It is what is called [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete), meaning it is stateless, requiring no information of the current state or the request sent previously, and the type of operation is determined by the HTTP method. Almost all API calls also require you to be be authenticated and to abide by the rate-limit.

## Documentation notes

?> These docs are for Unity SDK version `2018.4.20f1` and build tag `master-build-2021-03-26`.

Sections of the documentation labeled **Outdated** means the article or endpoint is no longer supported or that the documentation is out-of-date. Sections labeled **Soon** are work in progress articles, while sections labeled **Beta** are endpoints found in the beta client, and are not yet released into production.

## API Libraries

There are various pre-written libraries which can be used to interact with the API. Depending on the programming languages these libraries are mantained to varying degree, and while most have basic functionality they can lack more unusual endpoitns or not be updated in terms of recent changes to the API.

1. VRCpy (Python) https://github.com/VRChatAPI/VRChatPython

2. ~~VRChat.Net (C#) https://github.com/VRChatAPI/VRChat.Net~~ (outdated)

3. ~~VRChatJava (Java) https://github.com/VRChatAPI/VRChatJava~~ (outdated)

Out of these the Python library is the one most updated, and therefore the most recommended. For other languages it is possible to use a generic HTTP client, such as [Axios](https://github.com/axios/axios) for NodeJS or the new [HttpClient](https://dzone.com/articles/java-11-standardized-http-client-api) in Java 11. There are also graphical API clients such as [Postman](https://www.postman.com/downloads/) and [Insomnia](https://insomnia.rest/download).

This documentation will show examples using curl, a command-line client allowing you to test various endpoints directly without writing a program. Curl can be [downloadable for Windows](https://curl.se/windows/) and installed with `sudo apt-get install curl` on Linux or `brew install curl` on MacOS.

```bash
$ curl https://api.vrchat.cloud/api/1/health
{
"ok": true,
"serverName": "prod-api-blue-power-0by",
"buildVersionTag": "master-build-2021-04-22-ben-bearcrayon"
}
```

## Client API Key

Every API requires you to give a special API key. To get it simply call the [Remote Config](/SystemAPI/Config.md) endpoint. The API key can be passed in either a query parameter named `apiKey` or by setting a cookie with the name.

?> The last known key is `JlE5Jldo5Jibnk5O5hTx6XVqsJu4WJ26`

```bash
$ curl https://vrchat.com/api/1/users
{"error":{"message":"\"No API Key provided!\"","status_code":401}}
# FAIL: Missing apiKey, as this is a GET request we will provide it as a URL parameter.

$ curl https://vrchat.com/api/1/users?apiKey=JlE5Jldo5Jibnk5O5hTx6XVqsJu4WJ26
{"error":{"message":"\"Missing Credentials\"","status_code":401}}
# SUCCESS: We will now proced to authenticating.
```

## Authorization

!> **Session Limit**: Each authentication with login credentials counts as a separate session, out of which you have a limited amount. Make sure to save and reuse the authcookie whenever you can, and avoid sending the Authorization header unless strictly neccesary.

Most of the APIs require you to be authenticated, and VRChat does authorization using the [`Authorization header`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization). The username and password are encoded using base64, and then sent to the API endpoint `/api/1/auth/user`.

After authenticating against the API it is **critical** to save and reuse the returned `auth` cookie. Each authentication with login credentials counts as a separate "session", out of which you have a limited amount. Authorization tokens expire either by not using them for a certain period of time, or by using the [`Logout endpoint`](/UserAPI/Logout.md).

```bash
# Windows (using Powershell)
$ [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes('username:password'))
dXNlcm5hbWU6cGFzc3dvcmQ=

# Linux / MacOS
$ echo -n "username:password" | base64
dXNlcm5hbWU6cGFzc3dvcmQ=

# Request an authcookie
# The 'auth' cookie is saved to "cookiejar.txt", this makes it easier to re-use in future commands.
# Replace the base64-encoded string "Rm9vcmFjazptYXhmYXgyNTI1ISE" with the one generated in one of the previous commands.
# Also replace "My User Agent" with a custom and unique agent name to identify yourself!
$ curl -c cookiejar.txt -A "My User Agent" -H "Authorization: Basic Rm9vcmFjazptYXhmYXgyNTI1ISE=" https://api.vrchat.cloud/api/1/auth/user
```

For this we will first encode the username and password as base64. We will then authenticate against the API and save the resulting `apiKey` and `auth` cookies to `cookiejar.txt`. We will be using this file in future commands when interacting with the API. In case the auth token expires, simply delete the file and run the command again.
4 changes: 0 additions & 4 deletions ModerationAPI/Against.md

This file was deleted.

2 changes: 1 addition & 1 deletion ModerationAPI/ClearModerations.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ https://api.vrchat.cloud/api/1/user/[ID]/moderations
ID - the id of the user

## Requires Authentication
Yes (See [here](/Authorization.md) for details)
Yes (See [here](/GettingStarted/QuickStart?id=authorization) for details)

## Returns

Expand Down
Loading