From 37a68de68b1c920021070a0bd5db4931b5a459eb Mon Sep 17 00:00:00 2001 From: FTTristan <135572396+Fttristan@users.noreply.github.com> Date: Thu, 25 Sep 2025 12:42:33 -0400 Subject: [PATCH 1/7] Update rest.py --- vrchatapi/rest.py | 318 ++++++++++++++++++++++------------------------ 1 file changed, 150 insertions(+), 168 deletions(-) diff --git a/vrchatapi/rest.py b/vrchatapi/rest.py index 0447f99f..6e128bff 100644 --- a/vrchatapi/rest.py +++ b/vrchatapi/rest.py @@ -1,87 +1,64 @@ # coding: utf-8 """ - VRChat API Documentation - - - The version of the OpenAPI document: 1.20.3 - Contact: vrchatapi.lpv0t@aries.fyi - Generated by: https://openapi-generator.tech +REST client layer for vrchatapi-python, with cookie persistence support. """ - -from __future__ import absolute_import - -import io -import json -import logging import re +import json import ssl - -# python 2 and python 3 compatibility library -import six -from six.moves.urllib.parse import urlencode import urllib3 +from urllib.parse import urlencode +from urllib.request import Request +from http.cookiejar import CookieJar +from http.cookies import SimpleCookie +from requests.cookies import create_cookie -from vrchatapi.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError - - -logger = logging.getLogger(__name__) - - -class RESTResponse(io.IOBase): - - def __init__(self, resp): - self.urllib3_response = resp - self.status = resp.status - self.reason = resp.reason - self.data = resp.data +import six - def getheaders(self): - """Returns a dictionary of the response headers.""" - return self.urllib3_response.getheaders() +from .exceptions import ( + ApiException, + ApiValueError, + UnauthorizedException, + ForbiddenException, + NotFoundException, + ServiceException, +) - def getheader(self, name, default=None): - """Returns a given response header.""" - return self.urllib3_response.getheader(name, default) +# Response wrapper to normalize urllib3 responses +class RESTResponse(object): + def __init__(self, response): + self.status = response.status + self.data = response.data + self.headers = response.headers + self.reason = getattr(response, "reason", None) class RESTClientObject(object): - def __init__(self, configuration, pools_size=4, maxsize=None): - # urllib3.PoolManager will pass all kw parameters to connectionpool - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 - # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 - # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 - - # cert_reqs + # Determine SSL requirement if configuration.verify_ssl: cert_reqs = ssl.CERT_REQUIRED else: cert_reqs = ssl.CERT_NONE - # VRChatAPI: Init global cookie storage - from http.cookiejar import CookieJar + # Initialize cookie storage self.cookie_jar = CookieJar() + # PoolManager arguments addition_pool_args = {} if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 - + addition_pool_args["assert_hostname"] = configuration.assert_hostname if configuration.retries is not None: - addition_pool_args['retries'] = configuration.retries - + addition_pool_args["retries"] = configuration.retries if configuration.socket_options is not None: - addition_pool_args['socket_options'] = configuration.socket_options + addition_pool_args["socket_options"] = configuration.socket_options + # Determine maxsize if maxsize is None: - if configuration.connection_pool_maxsize is not None: - maxsize = configuration.connection_pool_maxsize - else: - maxsize = 4 + maxsize = configuration.connection_pool_maxsize or 4 - # https pool manager + # Create the pool manager (with or without proxy) if configuration.proxy: self.pool_manager = urllib3.ProxyManager( num_pools=pools_size, @@ -105,30 +82,20 @@ def __init__(self, configuration, pools_size=4, maxsize=None): **addition_pool_args ) - def request(self, method, url, query_params=None, headers=None, - body=None, post_params=None, _preload_content=True, - _request_timeout=None): - """Perform requests. - - :param method: http request method - :param url: http request url - :param query_params: query parameters in the url - :param headers: http request headers - :param body: request json body, for `application/json` - :param post_params: request post parameters, - `application/x-www-form-urlencoded` - and `multipart/form-data` - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - """ + def request( + self, + method, + url, + query_params=None, + headers=None, + body=None, + post_params=None, + _preload_content=True, + _request_timeout=None, + ): + """Perform HTTP request, inject and extract cookies automatically.""" method = method.upper() - assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', - 'PATCH', 'OPTIONS'] + assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"] if post_params and body: raise ApiValueError( @@ -138,121 +105,136 @@ def request(self, method, url, query_params=None, headers=None, post_params = post_params or {} headers = headers or {} - # VRChatAPI: Build a mock Request object to work with - from urllib.request import Request - mock_request_object = Request(url=url, method=method, headers=headers) - self.cookie_jar.add_cookie_header(mock_request_object) - if "Cookie" in mock_request_object.unredirected_hdrs: - headers["Cookie"] = mock_request_object.unredirected_hdrs["Cookie"] + # Inject cookies into the outgoing request + mock_req = Request(url=url, method=method, headers=headers) + self.cookie_jar.add_cookie_header(mock_req) + if "Cookie" in mock_req.unredirected_hdrs: + headers["Cookie"] = mock_req.unredirected_hdrs["Cookie"] + # Build timeout object timeout = None - if _request_timeout: - if isinstance(_request_timeout, six.integer_types + (float, )): # noqa: E501,F821 + if _request_timeout is not None: + if isinstance(_request_timeout, six.integer_types + (float,)): timeout = urllib3.Timeout(total=_request_timeout) - elif (isinstance(_request_timeout, tuple) and - len(_request_timeout) == 2): + elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: timeout = urllib3.Timeout( - connect=_request_timeout[0], read=_request_timeout[1]) + connect=_request_timeout[0], read=_request_timeout[1] + ) - if 'Content-Type' not in headers: - headers['Content-Type'] = 'application/json' + # Ensure a default Content-Type + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" try: - # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` - if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + # Write GET/POST/PUT/PATCH/DELETE logic + if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: if query_params: - url += '?' + urlencode(query_params) - if re.search('json', headers['Content-Type'], re.IGNORECASE): - request_body = None - if body is not None: - request_body = json.dumps(body) - r = self.pool_manager.request( - method, url, - body=request_body, + url += "?" + urlencode(query_params) + + if re.search("json", headers["Content-Type"], re.IGNORECASE): + payload = json.dumps(body) if body is not None else None + resp = self.pool_manager.request( + method, + url, + body=payload, preload_content=_preload_content, timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 - r = self.pool_manager.request( - method, url, + headers=headers, + ) + elif headers["Content-Type"] == "application/x-www-form-urlencoded": + resp = self.pool_manager.request( + method, + url, fields=post_params, encode_multipart=False, preload_content=_preload_content, timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'multipart/form-data': - # must del headers['Content-Type'], or the correct - # Content-Type which generated by urllib3 will be - # overwritten. - del headers['Content-Type'] - r = self.pool_manager.request( - method, url, + headers=headers, + ) + elif headers["Content-Type"] == "multipart/form-data": + del headers["Content-Type"] + resp = self.pool_manager.request( + method, + url, fields=post_params, encode_multipart=True, preload_content=_preload_content, timeout=timeout, - headers=headers) - # Pass a `string` parameter directly in the body to support - # other content types than Json when `body` argument is - # provided in serialized form - elif isinstance(body, str) or isinstance(body, bytes): - request_body = body - r = self.pool_manager.request( - method, url, - body=request_body, + headers=headers, + ) + elif isinstance(body, (str, bytes)): + resp = self.pool_manager.request( + method, + url, + body=body, preload_content=_preload_content, timeout=timeout, - headers=headers) + headers=headers, + ) else: - # Cannot generate the request from given parameters - msg = """Cannot prepare a request message for provided - arguments. Please check that your arguments match - declared content type.""" + msg = ( + "Cannot prepare a request message for provided " + "arguments. Please check that your arguments match " + "declared content type." + ) raise ApiException(status=0, reason=msg) - # For `GET`, `HEAD` else: - r = self.pool_manager.request(method, url, - fields=query_params, - preload_content=_preload_content, - timeout=timeout, - headers=headers) + resp = self.pool_manager.request( + method, + url, + fields=query_params, + preload_content=_preload_content, + timeout=timeout, + headers=headers, + ) except urllib3.exceptions.SSLError as e: - msg = "{0}\n{1}".format(type(e).__name__, str(e)) - raise ApiException(status=0, reason=msg) - - - # VRChatAPI: Extract and save cookies for global storage - self.cookie_jar.extract_cookies(r, mock_request_object) - + raise ApiException(status=0, reason=f"{type(e).__name__}\n{e}") + + # Extract Set-Cookie headers + if hasattr(resp, "headers") and "set-cookie" in resp.headers: + cookie = SimpleCookie() + cookie.load(resp.headers["set-cookie"]) + for key, morsel in cookie.items(): + self.cookie_jar.set_cookie( + create_cookie(name=key, value=morsel.value) + ) + + # Wrap response if requested if _preload_content: - r = RESTResponse(r) - - # log response body - logger.debug("response body: %s", r.data) - - if not 200 <= r.status <= 299: - if r.status == 401: - raise UnauthorizedException(http_resp=r) - - if r.status == 403: - raise ForbiddenException(http_resp=r) - - if r.status == 404: - raise NotFoundException(http_resp=r) - - if 500 <= r.status <= 599: - raise ServiceException(http_resp=r) - - raise ApiException(http_resp=r) - - if re.match(b'{"\w{21}":\["totp","otp"]}', r.data) is not None: - r.reason = "2 Factor Authentication verification is required" - raise UnauthorizedException(http_resp=r) - elif re.match(b'{"\w{21}":\["emailOtp"]}', r.data) is not None: - r.reason = "Email 2 Factor Authentication verification is required" - raise UnauthorizedException(http_resp=r) - - return r + resp = RESTResponse(resp) + + # Error handling + if not 200 <= resp.status <= 299: + if resp.status == 401: + raise UnauthorizedException(http_resp=resp) + if resp.status == 403: + raise ForbiddenException(http_resp=resp) + if resp.status == 404: + raise NotFoundException(http_resp=resp) + if 500 <= resp.status <= 599: + raise ServiceException(http_resp=resp) + raise ApiException(http_resp=resp) + + # 2FA enforcement detection + if re.match(b'{"\\w{21}":\\["totp","otp"]}', resp.data): + resp.reason = "2 Factor Authentication verification is required" + raise UnauthorizedException(http_resp=resp) + elif re.match(b'{"\\w{21}":\\["emailOtp"]}', resp.data): + resp.reason = "Email 2 Factor Authentication verification is required" + raise UnauthorizedException(http_resp=resp) + + return resp + + def get_cookie(self, name): + """Return the value of a cookie by name.""" + for c in self.cookie_jar: + if c.name == name: + return c.value + return None + + def get_all_cookies(self): + """Return a dict of all stored cookies.""" + return {c.name: c.value for c in self.cookie_jar} def GET(self, url, headers=None, query_params=None, _preload_content=True, _request_timeout=None): From e4e6068fc2e0cfc85ce9f3f3159b2a16b793161b Mon Sep 17 00:00:00 2001 From: FTTristan <135572396+Fttristan@users.noreply.github.com> Date: Thu, 25 Sep 2025 12:56:16 -0400 Subject: [PATCH 2/7] Update ci.yaml --- .github/workflows/ci.yaml | 97 ++++++++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f2b3bb3a..e825a962 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,54 +1,85 @@ +name: Generate & Publish VRChat API Python SDK + +permissions: + contents: write + on: repository_dispatch: types: [spec_release] workflow_dispatch: -#on: push - -name: Generate VRChat API SDK jobs: - generate: + generate-and-publish: runs-on: ubuntu-latest - name: Generate VRChat API SDK + name: Generate & Publish + steps: - - uses: actions/setup-node@v1 + # 1) Checkout your repo using your PAT (TOKEN_GITHUB) + - name: Checkout code + uses: actions/checkout@v3 with: - node-version: 16 - - uses: actions/checkout@v2 - - name: 'Cache node_modules' - uses: actions/cache@v4 + fetch-depth: 0 + token: ${{ secrets.TOKEN_GITHUB }} + + # 2) Set up Node.js & cache OpenAPI Generator + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Cache node_modules + uses: actions/cache@v3 with: path: node_modules key: ${{ runner.os }}-node-v16-${{ hashFiles('**/generate.sh') }} restore-keys: | ${{ runner.os }}-node-v16 + - name: Install OpenAPI Generator CLI run: npm install @openapitools/openapi-generator-cli - - name: Set OpenAPI Generator version - run: ./node_modules/\@openapitools/openapi-generator-cli/main.js version-manager set 6.2.1 - - name: Set up Python 3.9 - uses: actions/setup-python@v1 - with: - python-version: 3.9 + + - name: Pin OpenAPI Generator version + run: npx @openapitools/openapi-generator-cli version-manager set 6.2.1 + + # 3) Generate the Python client - name: Generate SDK Client run: bash ./generate.sh - - name: Check version number - run: | - echo "spec_version=$(grep "VERSION =" setup.py | cut -d "\"" -f 2)" >> $GITHUB_ENV - - name: Print version number - run: echo ${{ env.spec_version }} - - name: Deploy SDK back into main branch - uses: JamesIves/github-pages-deploy-action@v4 + + # 4) Set up Python & build tools + - name: Setup Python 3.9 + uses: actions/setup-python@v4 with: - branch: main - folder: . - commit-message: "Upgrade Python SDK to spec ${{ env.spec_version }}" - - name: Install pypa/build - run: python -m pip install build --user - - name: Build a binary wheel and a source tarball - run: python -m build --sdist --wheel --outdir dist/ . - - name: Publish SDK 📦 to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + python-version: '3.9' + + - name: Install build & twine + run: python -m pip install --upgrade pip build twine + + # 5) Extract version from setup.py + - name: Extract SDK version + id: get_version + run: | + VERSION=$(grep '^VERSION =' setup.py | cut -d'"' -f2) + echo "SDK_VERSION=$VERSION" >> $GITHUB_ENV + + - name: Show SDK version + run: echo "Releasing SDK version ${{ env.SDK_VERSION }}" + + # 6) Commit generated SDK back to main + - name: Commit generated client to main + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + git diff --quiet || git commit -m "Upgrade Python SDK to spec ${{ env.SDK_VERSION }}" + git push origin main + + # 7) Build distributions + - name: Build distributions + run: python -m build --sdist --wheel --outdir dist/ + + # 8) Publish to PyPI + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@v1 with: - skip_existing: true + user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} From 67c160f78adb60a6e81ef8de6055aba9e30436f9 Mon Sep 17 00:00:00 2001 From: FTTristan <135572396+Fttristan@users.noreply.github.com> Date: Thu, 25 Sep 2025 12:58:08 -0400 Subject: [PATCH 3/7] Update ci.yaml --- .github/workflows/ci.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e825a962..e1f2ebb1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,11 +10,11 @@ on: jobs: generate-and-publish: - runs-on: ubuntu-latest name: Generate & Publish + runs-on: ubuntu-latest steps: - # 1) Checkout your repo using your PAT (TOKEN_GITHUB) + # 1) Checkout the repo with your PAT - name: Checkout code uses: actions/checkout@v3 with: @@ -41,7 +41,7 @@ jobs: - name: Pin OpenAPI Generator version run: npx @openapitools/openapi-generator-cli version-manager set 6.2.1 - # 3) Generate the Python client + # 3) Generate the Python SDK - name: Generate SDK Client run: bash ./generate.sh @@ -54,7 +54,7 @@ jobs: - name: Install build & twine run: python -m pip install --upgrade pip build twine - # 5) Extract version from setup.py + # 5) Extract SDK version - name: Extract SDK version id: get_version run: | @@ -73,13 +73,12 @@ jobs: git diff --quiet || git commit -m "Upgrade Python SDK to spec ${{ env.SDK_VERSION }}" git push origin main - # 7) Build distributions + # 7) Build Python distributions - name: Build distributions run: python -m build --sdist --wheel --outdir dist/ # 8) Publish to PyPI - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1 + uses: pypa/gh-action-pypi-publish@release/v1 with: - user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} From 845bff8f3080ac046bc61548ddd7a944e59382d0 Mon Sep 17 00:00:00 2001 From: FTTristan <135572396+Fttristan@users.noreply.github.com> Date: Thu, 25 Sep 2025 13:04:16 -0400 Subject: [PATCH 4/7] Update setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 935fdb97..f5464ad3 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ First add the package to to your project: ```bash -pip install vrchatapi +pip install vrchat-api-client ``` Below is an example on how to login to the API and fetch your own user information. @@ -91,7 +91,7 @@ from setuptools import setup, find_packages # noqa: H301 -NAME = "vrchatapi" +NAME = "vrchat-api-client" VERSION = "1.20.3" # To install the library, run the following # From 2603fed046bcbc5b27fb633030f82ffc388ee02f Mon Sep 17 00:00:00 2001 From: FTTristan <135572396+Fttristan@users.noreply.github.com> Date: Thu, 25 Sep 2025 13:10:09 -0400 Subject: [PATCH 5/7] Update setup.py --- setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index f5464ad3..ab9a94cc 100644 --- a/setup.py +++ b/setup.py @@ -92,7 +92,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "vrchat-api-client" -VERSION = "1.20.3" +VERSION = "1.20.4" # To install the library, run the following # # python setup.py install @@ -107,9 +107,9 @@ version=VERSION, description="VRChat API Library for Python", author="Unofficial VRChat API Documentation Project", - author_email="vrchatapi.lpv0t@aries.fyi", - url="", - keywords=["vrchat", "vrchatapi", "vrc"], + author_email="webmaster@vrcband.com", + url="https://github.com/VRCband/vrchatapi-python", + keywords=["vrchat", "vrchat-api-client", "vrc"], install_requires=REQUIRES, packages=find_packages(exclude=["test", "tests"]), include_package_data=True, From e7353f9b2e2f27ec4e03ceef03909b0a76e00399 Mon Sep 17 00:00:00 2001 From: FTTristan <135572396+Fttristan@users.noreply.github.com> Date: Thu, 25 Sep 2025 13:16:27 -0400 Subject: [PATCH 6/7] Update ci.yaml --- .github/workflows/ci.yaml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e1f2ebb1..f3471e1b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,7 +1,9 @@ name: Generate & Publish VRChat API Python SDK +# allow pushing back to your repo and/or using OIDC for Trusted Publishing permissions: contents: write + id-token: write # only needed if you ever switch to “trusted publishing” w/o password on: repository_dispatch: @@ -12,16 +14,19 @@ jobs: generate-and-publish: name: Generate & Publish runs-on: ubuntu-latest + permissions: + contents: write + id-token: write steps: - # 1) Checkout the repo with your PAT + # 1) Checkout the repo (with your PAT) - name: Checkout code uses: actions/checkout@v3 with: - fetch-depth: 0 token: ${{ secrets.TOKEN_GITHUB }} + fetch-depth: 0 - # 2) Set up Node.js & cache OpenAPI Generator + # 2) Install & pin OpenAPI Generator - name: Setup Node.js uses: actions/setup-node@v3 with: @@ -41,11 +46,11 @@ jobs: - name: Pin OpenAPI Generator version run: npx @openapitools/openapi-generator-cli version-manager set 6.2.1 - # 3) Generate the Python SDK + # 3) Generate your Python client - name: Generate SDK Client run: bash ./generate.sh - # 4) Set up Python & build tools + # 4) Build & package with Python - name: Setup Python 3.9 uses: actions/setup-python@v4 with: @@ -54,31 +59,31 @@ jobs: - name: Install build & twine run: python -m pip install --upgrade pip build twine - # 5) Extract SDK version - name: Extract SDK version id: get_version run: | + # this reads VERSION from your updated setup.py VERSION=$(grep '^VERSION =' setup.py | cut -d'"' -f2) echo "SDK_VERSION=$VERSION" >> $GITHUB_ENV - name: Show SDK version run: echo "Releasing SDK version ${{ env.SDK_VERSION }}" - # 6) Commit generated SDK back to main + # 5) (Optional) Commit generated client back into main - name: Commit generated client to main run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add . - git diff --quiet || git commit -m "Upgrade Python SDK to spec ${{ env.SDK_VERSION }}" + git diff --quiet || git commit -m "Upgrade vrchat-api-client to spec ${{ env.SDK_VERSION }}" git push origin main - # 7) Build Python distributions - name: Build distributions run: python -m build --sdist --wheel --outdir dist/ - # 8) Publish to PyPI + # 6) Publish to PyPI under the new project name - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: + user: "__token__" password: ${{ secrets.PYPI_API_TOKEN }} From cbe0c0a58190c8d6c19aeaf840744196156644d6 Mon Sep 17 00:00:00 2001 From: FTTristan <135572396+Fttristan@users.noreply.github.com> Date: Thu, 25 Sep 2025 13:29:48 -0400 Subject: [PATCH 7/7] Update setup.py --- setup.py | 94 ++++---------------------------------------------------- 1 file changed, 6 insertions(+), 88 deletions(-) diff --git a/setup.py b/setup.py index ab9a94cc..66f8ea17 100644 --- a/setup.py +++ b/setup.py @@ -93,12 +93,6 @@ NAME = "vrchat-api-client" VERSION = "1.20.4" -# To install the library, run the following -# -# python setup.py install -# -# prerequisite: setuptools -# http://pypi.python.org/pypi/setuptools REQUIRES = ["urllib3 >= 1.25.3", "six >= 1.10", "python-dateutil"] @@ -114,86 +108,10 @@ packages=find_packages(exclude=["test", "tests"]), include_package_data=True, license="MIT", - long_description_content_type='text/markdown', - long_description="""\ + classifiers=[ + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Operating System :: OS Independent", + ], -![](https://github.com/vrchatapi/vrchatapi.github.io/blob/main/static/assets/img/lang/lang_python_banner_1500x300.png?raw=true) - -# VRChat API Library for Python - -A Python client to interact with the unofficial VRChat API. Supports all REST calls specified in the [API specification](https://github.com/vrchatapi/specification). - -## 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. - -## Getting Started - -First add the package to to your project: -```bash -pip install vrchatapi -``` - -Below is an example on how to login to the API and fetch your own user information. - -```python -# Step 1. We begin with creating a Configuration, which contains the username and password for authentication. -import vrchatapi -from vrchatapi.api import authentication_api -from vrchatapi.exceptions import UnauthorizedException -from vrchatapi.models.two_factor_auth_code import TwoFactorAuthCode -from vrchatapi.models.two_factor_email_code import TwoFactorEmailCode - -configuration = vrchatapi.Configuration( - username = 'username', - password = 'password', -) - -# Step 2. VRChat consists of several API's (WorldsApi, UsersApi, FilesApi, NotificationsApi, FriendsApi, etc...) -# Here we enter a context of the API Client and instantiate the Authentication API which is required for logging in. - -# Enter a context with an instance of the API client -with vrchatapi.ApiClient(configuration) as api_client: - # Set our User-Agent as per VRChat Usage Policy - api_client.user_agent = "ExampleProgram/0.0.1 my@email.com" - - # Instantiate instances of API classes - auth_api = authentication_api.AuthenticationApi(api_client) - - try: - # Step 3. Calling getCurrentUser on Authentication API logs you in if the user isn't already logged in. - current_user = auth_api.get_current_user() - except UnauthorizedException as e: - if e.status == 200: - if "Email 2 Factor Authentication" in e.reason: - # Step 3.5. Calling email verify2fa if the account has 2FA disabled - auth_api.verify2_fa_email_code(two_factor_email_code=TwoFactorEmailCode(input("Email 2FA Code: "))) - elif "2 Factor Authentication" in e.reason: - # Step 3.5. Calling verify2fa if the account has 2FA enabled - auth_api.verify2_fa(two_factor_auth_code=TwoFactorAuthCode(input("2FA Code: "))) - current_user = auth_api.get_current_user() - else: - print("Exception when calling API: %s\n", e) - except vrchatapi.ApiException as e: - print("Exception when calling API: %s\n", e) - - print("Logged in as:", current_user.display_name) -``` - -See [Examples](https://github.com/vrchatapi/vrchatapi-python/blob/main/examples/README.md) for more example usage on getting started. - -## Contributing - -Contributions are welcome, but do not add features that should be handled by the OpenAPI specification. - -Join the [Discord server](https://discord.gg/Ge2APMhPfD) to get in touch with us. - """ -)