{"id":13602255,"url":"https://github.com/alectrocute/wg-api","last_synced_at":"2025-03-22T15:30:59.031Z","repository":{"id":54871610,"uuid":"219634464","full_name":"alectrocute/wg-api","owner":"alectrocute","description":"creates an HTTP endpoint for a Wireguard® VPN server","archived":false,"fork":false,"pushed_at":"2021-01-23T14:52:37.000Z","size":2139,"stargazers_count":72,"open_issues_count":8,"forks_count":24,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-14T22:34:08.770Z","etag":null,"topics":["api","bash","endpoint","http","linux","management","node","qr-encode","rest-api","ubuntu","user","user-management","vpn","wg","wg-quick","wireguard"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/alectrocute.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}},"created_at":"2019-11-05T01:52:22.000Z","updated_at":"2024-11-18T23:24:22.000Z","dependencies_parsed_at":"2022-08-14T05:20:23.077Z","dependency_job_id":null,"html_url":"https://github.com/alectrocute/wg-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alectrocute%2Fwg-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alectrocute%2Fwg-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alectrocute%2Fwg-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alectrocute%2Fwg-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alectrocute","download_url":"https://codeload.github.com/alectrocute/wg-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244978511,"owners_count":20541864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api","bash","endpoint","http","linux","management","node","qr-encode","rest-api","ubuntu","user","user-management","vpn","wg","wg-quick","wireguard"],"created_at":"2024-08-01T18:01:18.022Z","updated_at":"2025-03-22T15:30:58.633Z","avatar_url":"https://github.com/alectrocute.png","language":"Shell","readme":"![logo](https://github.com/alectrocute/wg-api/blob/master/icon.png)\n\nwg-api is an API endpoint for a Wireguard® VPN server. It allows you to make HTTP GET requests with JSON responses, enabling you to create \u0026 revoke peers (eg. clients), access QR/plaintext/JSON config files and receive realtime server info.\n\nIt also currently includes an installer script to configure your Wireguard® interface correctly as per wg-api's construction.\n\nIt's still a baby project but I plan on building it out into a full-featured RESTful API for this amazing VPN software. I would **NOT** use this in production for awhile. It is a very insecure endpoint that could and most likely **will** give an attacker access to your user's keys and full control over your system. The only thing securing it currently is an IP-based whitelist in `config.json`. Seriously, don't even think about exposing this as a public IP and/or port.\n\n## Installation\n\nUse a fresh Ubuntu 18.* install with up-to-date apt dependencies, with Node and NPM installed and Wireguard uninstalled.\n```bash\napt-get install nodejs npm -y\ngit clone https://github.com/alectrocute/wg-api\ncd wg-api\nnpm install fastify fastify-static chalk ini\ncd ./scripts/bash\n./installer.sh\n```\n\nTake time to configure the options in `/wg-api/scripts/data/wg.def` and `/wg-api/config.json`.\n\nThen get your Wireguard® server up and running:\n\n```bash\ncd ./wg-api/scripts/bash\n./wg.sh -i\n```\n\n## Running the server\n\n```bash\nnode server.js\n```\n\n## API endpoints\n\n### GET /interface/info\n\nWill return a JSON object of all Wireguard® interface stats:\n\n```json\n{\n  \"wg0\": {\n    \"privateKey\": \"[hidden]\",\n    \"publicKey\": \"dutH7c8K2VX4OcQ1c/rvIAAFJBRcf2a9ieVmq2GI4UA=\",\n    \"listenPort\": 27953,\n    \"peers\": {\n      \"EobS6jP7+b4jqI1o97PAjp8rhLBpmD9hSbcnhLRqcTQ=\": {\n        \"endpoint\": \"12.34.45.545:21807\",\n        \"latestHandshake\": \"Nov 5, 2019 3:23:3 UTC\",\n        \"transferRx\": \"3.034 MB\",\n        \"transferTx\": \"21.65 MB\",\n        \"allowedIps\": [\n          \"10.9.0.6/32\"\n        ]\n      }\n    }\n  }\n}\n```\n\n### GET /peer/create/[nickname]\n\nWill generate a new peer, assign IP, etc. based on customized template and return JSON of their details:\n\n```json\n{\n  \"code\": 200,\n  \"profile\": {\n    \"Interface\": {\n      \"Address\": \"10.9.0.7/24\",\n      \"PrivateKey\": \"eOksCc/sE+MYmHBlXc9t4ZPpIdBcB94Bgbip12gbEVI=\",\n      \"DNS\": \"1.1.1.1, 1.0.0.1\"\n    },\n    \"Peer\": {\n      \"PublicKey\": \"dutH7c8K2VX4OcQ1c/rvIAAFJBRcf2a9ieVmq2GI4UA=\",\n      \"AllowedIPs\": \"0.0.0.0/0, ::/0\",\n      \"Endpoint\": \"45.76.174.177:27953\",\n      \"PersistentKeepalive\": \"25\"\n    },\n    \"qr\": \"/peer/qr/alec2\"\n  }\n}\n```\n\n### GET /peer/remove/[nickname]\n\nWill revoke a peer, remove all associated files, reload the interface and return a basic message:\n\n```json\n{\n  \"code\": 200,\n  \"profile\": \"Revoked\"\n}\n```\n\n### GET /peer/qr/[nickname]\n\nWill return a PNG image of a Wireguard® peer's QR code.\n\n\n### GET /peer/info/[nickname]\n\nWill return a JSON object of a Wireguard® peer's stats:\n\n```json\n {\n  \"code\": 200,\n  \"profile\": {\n    \"Interface\": {\n      \"Address\": \"10.9.0.6/24\",\n      \"PrivateKey\": \"8PZh0lf2lZ0CB8i585ei2ZYcCBruZGKubiRgt+b3NGA=\",\n      \"DNS\": \"1.1.1.1, 1.0.0.1\"\n    },\n    \"Peer\": {\n      \"PublicKey\": \"dutH7c8K2VX4OcQ1c/rvIAAFJBRcf2a9ieVmq2GI4UA=\",\n      \"AllowedIPs\": \"0.0.0.0/0, ::/0\",\n      \"Endpoint\": \"12.34.56.343:27953\",\n      \"PersistentKeepalive\": \"25\"\n    },\n    \"qr\": \"/peer/qr/alec\"\n  }\n}\n```\n\n### GET /peer/plaintext/[nickname]\n\nWill return a INI-formatted plaintext document of a Wireguard® peer's configuration file:\n\n```ini\n[Interface]\nAddress = 10.9.0.6/24\nPrivateKey = PZh0lf2lZ0CB8i585ei2ZYcCBruZGKubiRgt+b3NGA=\nDNS = 1.1.1.1, 1.0.0.1\n\n[Peer]\nPublicKey = dutH7c8K2VX4OcQ1c/rvIAAFJBRcf2a9ieVmq2GI4UA=\nAllowedIPs = 0.0.0.0/0, ::/0\nEndpoint = 12.34.56.343:27953\nPersistentKeepalive = 25\n```\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n","funding_links":[],"categories":["Shell","bash"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falectrocute%2Fwg-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falectrocute%2Fwg-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falectrocute%2Fwg-api/lists"}