/* * VRChat API Documentation * * ![VRChat API Banner](https://raw.githubusercontent.com/vrchatapi/vrchatapi.github.io/master/assets/apibanner.png) # VRChat API Documentation This project is an [OPEN Open Source Project](https://openopensource.org) Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. ## Disclaimer This is the official response of the VRChat Team (from Tupper more specifically) on the usage of the VRChat API. > **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. As stated, this documentation was not created with the help of the official VRChat team. Therefore this documentation is not an official documentation of the VRChat API and may not be always up to date with the latest versions. If you find that a page or endpoint is not longer valid please create an issue and tell us so we can fix it. ## Get in touch with us! [https://discord.gg/qjZE9C9fkB#vrchat-api](https://discord.gg/qjZE9C9fkB) * * The version of the OpenAPI document: 1.0.0 * Contact: me@ruby.js.org * Generated by: https://openapi-generator.tech */ use reqwest; use crate::apis::ResponseContent; use super::{Error, configuration}; /// struct for typed errors of method `create_file` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CreateFileError { UnknownValue(serde_json::Value), } /// struct for typed errors of method `create_file_version` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum CreateFileVersionError { UnknownValue(serde_json::Value), } /// struct for typed errors of method `delete_file` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteFileError { Status404(crate::models::Error), UnknownValue(serde_json::Value), } /// struct for typed errors of method `delete_file_version` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteFileVersionError { Status400(crate::models::Error), Status500(crate::models::Error), UnknownValue(serde_json::Value), } /// struct for typed errors of method `download_file_version` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum DownloadFileVersionError { UnknownValue(serde_json::Value), } /// struct for typed errors of method `finish_file_data_upload` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum FinishFileDataUploadError { UnknownValue(serde_json::Value), } /// struct for typed errors of method `get_file` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetFileError { Status404(crate::models::Error), UnknownValue(serde_json::Value), } /// struct for typed errors of method `get_file_data_upload_status` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetFileDataUploadStatusError { UnknownValue(serde_json::Value), } /// struct for typed errors of method `get_files` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetFilesError { UnknownValue(serde_json::Value), } /// struct for typed errors of method `start_file_data_upload` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum StartFileDataUploadError { Status400(crate::models::Error), UnknownValue(serde_json::Value), } /// Creates a new File object pub fn create_file(configuration: &configuration::Configuration, inline_object3: Option) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/file", configuration.base_path); let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } local_var_req_builder = local_var_req_builder.json(&inline_object3); let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } /// Creates a new FileVersion. Once a Version has been created, proceed to the `/file/{fileId}/{versionId}/file/start` endpoint to start a file upload. pub fn create_file_version(configuration: &configuration::Configuration, file_id: &str) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/file/{fileId}", configuration.base_path, fileId=crate::apis::urlencode(file_id)); let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } /// Deletes a File object. pub fn delete_file(configuration: &configuration::Configuration, file_id: &str) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/file/{fileId}", configuration.base_path, fileId=crate::apis::urlencode(file_id)); let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } /// Delete a specific version of a file. You can only delete the latest version. pub fn delete_file_version(configuration: &configuration::Configuration, file_id: &str, version_id: i32) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/file/{fileId}/{versionId}", configuration.base_path, fileId=crate::apis::urlencode(file_id), versionId=version_id); let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } /// Downloads the file with the provided version number. **Version Note:** Version 0 is always when the file was created. The real data is usually always located in version 1 and up. **Extension Note:** Files are not guaranteed to have a file extensions. UnityPackage files tends to have it, images through this endpoint do not. You are responsible for appending file extension from the `extension` field when neccesary. pub fn download_file_version(configuration: &configuration::Configuration, file_id: &str, version_id: i32) -> Result<(), Error> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/file/{fileId}/{versionId}", configuration.base_path, fileId=crate::apis::urlencode(file_id), versionId=version_id); let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } /// Finish an upload of a FileData. This will mark it as \"complete\". After uploading the `file` for Avatars and Worlds you then have to upload a `signature` file. pub fn finish_file_data_upload(configuration: &configuration::Configuration, file_id: &str, version_id: i32, file_type: &str, inline_object4: Option) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/file/{fileId}/{versionId}/{fileType}/finish", configuration.base_path, fileId=crate::apis::urlencode(file_id), versionId=version_id, fileType=crate::apis::urlencode(file_type)); let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } local_var_req_builder = local_var_req_builder.json(&inline_object4); let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } /// Shows general information about the \"File\" object. Each File can have several \"Version\"'s, and each Version can have multiple real files or \"Data\" blobs. pub fn get_file(configuration: &configuration::Configuration, file_id: &str) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/file/{fileId}", configuration.base_path, fileId=crate::apis::urlencode(file_id)); let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } /// Retrieves the upload status for file upload. Can currently only be accessed when `status` is `waiting`. Trying to access it on a file version already uploaded currently times out. pub fn get_file_data_upload_status(configuration: &configuration::Configuration, file_id: &str, version_id: i32, file_type: &str) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/file/{fileId}/{versionId}/{fileType}/status", configuration.base_path, fileId=crate::apis::urlencode(file_id), versionId=version_id, fileType=crate::apis::urlencode(file_type)); let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } /// Returns a list of files pub fn get_files(configuration: &configuration::Configuration, tag: Option<&str>, user_id: Option<&str>, n: Option, offset: Option) -> Result, Error> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/files", configuration.base_path); let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); if let Some(ref local_var_str) = tag { local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]); } if let Some(ref local_var_str) = user_id { local_var_req_builder = local_var_req_builder.query(&[("userId", &local_var_str.to_string())]); } if let Some(ref local_var_str) = n { local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); } if let Some(ref local_var_str) = offset { local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); } if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } /// Starts an upload of a specific FilePart. This endpoint will return an AWS URL which you can PUT data to. You need to call this and receive a new AWS API URL for each `partNumber`. Please see AWS's REST documentation on \"PUT Object to S3\" on how to upload. Once all parts has been uploaded, proceed to `/finish` endpoint. **Note:** `nextPartNumber` seems like it is always ignored. Despite it returning 0, first partNumber is always 1. pub fn start_file_data_upload(configuration: &configuration::Configuration, file_id: &str, version_id: i32, file_type: &str, part_number: i32) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/file/{fileId}/{versionId}/{fileType}/start", configuration.base_path, fileId=crate::apis::urlencode(file_id), versionId=version_id, fileType=crate::apis::urlencode(file_type)); let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); local_var_req_builder = local_var_req_builder.query(&[("partNumber", &part_number.to_string())]); if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } }