Skip to main content

V2Client - A V2Ray server management for python

Installation

pip install v2client

How Activate gRPC API?

// Add The following json to your config.json file 
{
  "stats": {},
  "api": {
    "tag": "api",
    "services": [
      "StatsService", // For stats
      "HandlerService", // For User and Inbound management
      "LoggerService" // For log management
    ]
  },
  "policy": {
    "levels": {
      "0": {
        "statsUserUplink": true, // User uplink stats
        "statsUserDownlink": true // User downlink stats
      }
    },
    "system": {
      "statsInboundUplink": true,
      "statsInboundDownlink": true,
      "statsOutboundUplink": true,
      "statsOutboundDownlink": true
    }
  }, 
    // and then add the following inbound
  "inbounds": [
      // ... (other inbounds)
      { 
        "listen": "0.0.0.0",
        "port": 8080, // or any other port you want
        "protocol": "dokodemo-door",
        "settings": {
          "address": "0.0.0.0"
        },
        "tag": "api"
      }
  ],
// and then add the following routing rule
  "routing": {
    "rules": [
      // ... (other rules)
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      }
    ],
    "domainStrategy": "AsIs"
  }
}

Usage

from v2client import utils
from v2client import V2RayClient
from v2client import enum as v2types

client = V2RayClient("SERVER_IP_ADDRESS", 8080)
usage = client.get_user_usage("email@gmail.com")
print(f"Download Usage: {usage.download} & Upload Usage: {usage.upload} (in bytes)")

# ADD VLESS USER
client.add_user(
    inbound_tag="inbound_tag",
    proxy_type=v2types.ProxyTypes.VLESS,
    email="email@gmail.com",
    level=0,
    flow=v2types.VLESSFlowTypes.XTLS_RPRX_ORIGIN,  # Only for VLESS
    encryption=v2types.VLESSEncryptionTypes.NONE,  # Only for VLESS
    user_id=utils.random_uuid()
)

# ADD VMESS USER
client.add_user(
    inbound_tag="inbound_tag",
    proxy_type=v2types.ProxyTypes.VMESS,
    email="email@email.com",
    level=0,
    security=v2types.VMessSecurityTypes.AES128_GCM,  # Only for VMESS
    user_id=utils.random_uuid()
)

# Remove User
client.remove_user(inbound_tag="inbound", email="email@gmail.com")

Metadata

Release files for v2client 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for v2client 1.1.1
File Size Uploaded Provenance Actions
v2client-1.1.1.tar.gz 54.6 kB Without provenance Details for v2client-1.1.1.tar.gz

Release files / v2client-1.1.1.tar.gz

Download URL v2client-1.1.1.tar.gz
Size 54.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4c494607a163416837c4fc876972fa2583720373784f8c85b0ce32f9e93ef9a8
BLAKE2b-256 checksum
How to use checksums
7180641f9e64716d342dc426fd73c5321f869286542f5b1537b4cca4b670318a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.8

Security for v2client 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page