{"id":28273623,"url":"https://github.com/v2rayroot/v2root-api-examples","last_synced_at":"2026-06-19T16:33:51.161Z","repository":{"id":289949957,"uuid":"972917267","full_name":"V2RayRoot/V2Root-API-Examples","owner":"V2RayRoot","description":"A collection of example codes in multiple programming languages (Rust, Go, C++, C) demonstrating how to use the libv2root.so/libv2root.dll library to interact with V2Root. ","archived":false,"fork":false,"pushed_at":"2025-04-25T22:44:16.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-17T22:06:03.488Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/V2RayRoot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-25T22:24:36.000Z","updated_at":"2025-04-26T03:48:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"b2b14feb-a3f3-468a-8e95-10a7a2860c87","html_url":"https://github.com/V2RayRoot/V2Root-API-Examples","commit_stats":null,"previous_names":["v2rayroot/v2root-api-examples"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/V2RayRoot/V2Root-API-Examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/V2RayRoot%2FV2Root-API-Examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/V2RayRoot%2FV2Root-API-Examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/V2RayRoot%2FV2Root-API-Examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/V2RayRoot%2FV2Root-API-Examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/V2RayRoot","download_url":"https://codeload.github.com/V2RayRoot/V2Root-API-Examples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/V2RayRoot%2FV2Root-API-Examples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34539870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-21T00:19:00.971Z","updated_at":"2026-06-19T16:33:51.137Z","avatar_url":"https://github.com/V2RayRoot.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# V2Root-API-Examples\n\nThis repository provides a collection of example codes in multiple programming languages (C, C++, Go, Rust) demonstrating how to interact with the `libv2root` library to manage V2Ray services. The examples cover key functionalities such as initializing V2Ray, parsing configurations, testing connection latency, pinging servers, starting/stopping the V2Ray service, and resetting network proxies. This project is ideal for developers looking to integrate V2Ray into their applications using a C-based API across different programming environments.\n\n## Features\n- **Multi-language Support**: Implementations in C, C++, Go, and Rust, showcasing cross-language compatibility with `libv2root`.\n- **Comprehensive V2Ray Operations**: Initialize V2Ray, parse VLESS configurations, test connections, ping servers, and manage service lifecycle.\n- **Sample Configuration**: Includes a `config.json` file with a VLESS setup for quick testing.\n- **Cross-platform**: Tested on Linux/WSL, with notes for Windows users (use `libv2root.dll` instead of `libv2root.so`).\n\n## Repository Structure\n- `C/`: C implementation with dynamic loading of `libv2root.so`.\n- `Cpp/`: C++ implementation with enhanced error handling and modern C++ features.\n- `Go/`: Go implementation using `cgo` for seamless integration with the C API.\n- `Rust/`: Rust implementation leveraging the `libloading` crate for safe FFI.\n- `config.json`: Sample VLESS configuration file for testing.\n- `.gitignore`: Excludes binary files (`libv2root.so`, `v2ray`, etc.) from version control.\n- `README.md`: This file, providing an overview and setup instructions.\n\nEach language folder contains a `README.md` with specific build and run instructions.\n\n## Getting Started\nTo use these examples, follow these steps:\n\n1. **Clone the Repository**:\n   ```bash\n   git clone https://github.com/V2RayRoot/V2Root-API-Examples.git\n   cd V2Root-API-Examples\n   ```\n\n2. **Prepare Dependencies**:\n   - **Linux/WSL**:\n     Install required libraries:\n     ```bash\n     sudo apt install libjansson4 libssl-dev\n     ```\n   - **Windows**:\n     Use `libv2root.dll` instead of `libv2root.so`. Ensure `libjansson` and `libssl` are available (e.g., via MSYS2 or pre-built binaries).\n\n3. **Place Required Files**:\n   - Copy `libv2root.so` (Linux) or `libv2root.dll` (Windows) and `v2ray` executable to the project root.\n   - The provided `config.json` is pre-configured for a VLESS setup. Modify it if needed.\n\n4. **Build and Run**:\n   Navigate to the desired language folder (e.g., `C/`, `Go/`) and follow the instructions in the respective `README.md` to compile and execute the example.\n\n## Platform Notes\n- **Linux/WSL**:\n  - Ensure `libv2root.so` is in the project root or set `LD_LIBRARY_PATH`:\n    ```bash\n    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.\n    ```\n  - Tested on Ubuntu-based WSL environments.\n\n- **Windows**:\n  - Replace `libv2root.so` with `libv2root.dll` in the code and project directory.\n  - Ensure `libv2root.dll` is in the same directory as the executable or in the system PATH.\n  - Use a compatible build environment (e.g., MSYS2, MinGW, or Visual Studio).\n\n## Example Usage\nEach example performs the following steps:\n1. Initializes V2Ray with `init_v2ray`.\n2. Parses a VLESS configuration using `parse_config_string`.\n3. Tests connection latency with `test_config_connection`.\n4. Pings the server with `ping_server`.\n5. Starts V2Ray service on ports 2300 (HTTP) and 2301 (SOCKS) using `start_v2ray`.\n6. Waits for 20 seconds.\n7. Stops the service with `stop_v2ray`.\n8. Resets network proxies with `reset_network_proxy`.\n\nSee language-specific `README.md` files for detailed build/run commands.\n\n## Contact\nFor questions or feedback, open an issue on GitHub or contact the repository maintainers.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv2rayroot%2Fv2root-api-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fv2rayroot%2Fv2root-api-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv2rayroot%2Fv2root-api-examples/lists"}