[GH-ISSUE #1017] Specification and implementation of api_endpoint /api/v1/request/awg #332

Open
opened 2026-10-13 20:19:12 +00:00 by bsakaguchi · 6 comments
Owner

Originally created by @atomlab on GitHub (Aug 27, 2024).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/1017

AmneziaVPN provides parameters for API requests to obtain configuration in vpn:// format through a Telegram bot. To decode these parameters, you can use the decoder code (https://github.com/andr13/amnezia-config-decoder).

python3 ./amnezia-config-decoder.py vpn://eyJjb25maWd...Y4UEgifQ==

As a result, you will get the following:

{
    "config_version": 1.0,
    "api_endpoint": "https://<server_ip>/api/v1/request/awg/",
    "protocol": "awg",
    "name": "AmneziaFree RU",
    "description": "AmneziaFree for Russia",
    "api_key": "<api_key>"
}

Please indicate where I can find the API specifications and implementation at the endpoint /api/v1/request/awg, so I can set up my own API server.

Note that API support is present in the file amnezia-client/client/core/controllers/apiController.cpp:

github.com/amnezia-vpn/amnezia-client@3458ed78d7/client/core/controllers/apiController.cpp (L23)

Originally created by @atomlab on GitHub (Aug 27, 2024). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/1017 AmneziaVPN provides parameters for API requests to obtain configuration in **vpn://** format through a Telegram bot. To decode these parameters, you can use the decoder code (https://github.com/andr13/amnezia-config-decoder). ```bash python3 ./amnezia-config-decoder.py vpn://eyJjb25maWd...Y4UEgifQ== ``` As a result, you will get the following: ```json { "config_version": 1.0, "api_endpoint": "https://<server_ip>/api/v1/request/awg/", "protocol": "awg", "name": "AmneziaFree RU", "description": "AmneziaFree for Russia", "api_key": "<api_key>" } ``` Please indicate where I can find the API specifications and implementation at the endpoint `/api/v1/request/awg`, so I can set up my own API server. Note that API support is present in the file `amnezia-client/client/core/controllers/apiController.cpp`: https://github.com/amnezia-vpn/amnezia-client/blob/3458ed78d7d3f80a7b0b11f33462b355db93668f/client/core/controllers/apiController.cpp#L23
Author
Owner

@AndreyDemenenko commented on GitHub (Nov 4, 2024):

@atomlab Didn't find where the API specification is?

<!-- gh-comment-id:2455544726 --> @AndreyDemenenko commented on GitHub (Nov 4, 2024): @atomlab Didn't find where the API specification is?
Author
Owner

@atomlab commented on GitHub (Nov 7, 2024):

folez

Unfortunately, I did not find any open implementation of the Amnezia API. In order to create my own implementation, it is necessary to find out what actions are performed on the server in Docker containers to generate configuration files and send them to the client. While studying the process, I found that the client sends a public key, which is then integrated into the main configuration file wg.conf on the server.

I hope that the developers will soon publish their API implementation. This would be preferable, as the API should evolve with the changes occurring in each new release to ensure compatibility.

<!-- gh-comment-id:2461739852 --> @atomlab commented on GitHub (Nov 7, 2024): > folez Unfortunately, I did not find any open implementation of the Amnezia API. In order to create my own implementation, it is necessary to find out what actions are performed on the server in Docker containers to generate configuration files and send them to the client. While studying the process, I found that the client sends a public key, which is then integrated into the main configuration file wg.conf on the server. I hope that the developers will soon publish their API implementation. This would be preferable, as the API should evolve with the changes occurring in each new release to ensure compatibility.
Author
Owner

@thepeshka commented on GitHub (Dec 28, 2024):

Hi! I think they don't bother publishing the specs because it's fairly straightforward. It's done on the client, so we have the whole process of acquiring the config. After couple of hours staring at C++ code (python developer here) I think I have a working solution:

  1. Generate X25519 keypair
  2. Decode Amnezia VPN key: URL-safe base64 -> strip first 4 bytes -> zlib -> json. We get api_endpoint and api_key
  3. Send POST request to api_endpoint with header Authorization: Api-Key <api_key> and body:
{
  "public_key": "<YOUR_PUBLIC_KEY_HERE>",
  "os_version": "android",  // https://doc.qt.io/qt-6/qsysinfo.html#productType
  "app_version": "4.8.2.3",  // https://github.com/amnezia-vpn/amnezia-client/releases/
  "uuid": "e906c42d-5795-454b-b19e-d20427a3ae6d"  // any uuid
}
  1. Decode Amnezia VPN key received in config field of the response
  2. Decode JSON at $.containers[0].awg.last_conifg and get config field from it
  3. Replace $WIREGUARD_CLIENT_PRIVATE_KEY in resulting config with your private key

So thats it! In terms of API we don't need anything except this one request

And of course there is gist in python

<!-- gh-comment-id:2564436890 --> @thepeshka commented on GitHub (Dec 28, 2024): Hi! I think they don't bother publishing the specs because it's fairly straightforward. It's done on the client, so we have the whole process of acquiring the config. After couple of hours staring at C++ code (python developer here) I think I have a working solution: 1. Generate X25519 keypair 2. Decode Amnezia VPN key: URL-safe base64 -> strip first 4 bytes -> zlib -> json. We get `api_endpoint` and `api_key` 3. Send POST request to `api_endpoint` with header `Authorization: Api-Key <api_key>` and body: ```javascript { "public_key": "<YOUR_PUBLIC_KEY_HERE>", "os_version": "android", // https://doc.qt.io/qt-6/qsysinfo.html#productType "app_version": "4.8.2.3", // https://github.com/amnezia-vpn/amnezia-client/releases/ "uuid": "e906c42d-5795-454b-b19e-d20427a3ae6d" // any uuid } ``` 4. Decode Amnezia VPN key received in `config` field of the response 5. Decode JSON at `$.containers[0].awg.last_conifg` and get `config` field from it 6. Replace `$WIREGUARD_CLIENT_PRIVATE_KEY` in resulting config with your private key So thats it! In terms of API we don't need anything except this one request And of course there is [gist](https://gist.github.com/thepeshka/acf79e62c60e10b0b44b83d7567aeccc) in python
Author
Owner

@ablagovestnov commented on GitHub (Mar 19, 2025):

2. Amnezia VPN key

Hello! It look like Amnezia VPN key doesn't contain api_endpoint

Where should i get proper api key?

(i have self hosted vpn )

<!-- gh-comment-id:2736567310 --> @ablagovestnov commented on GitHub (Mar 19, 2025): > 2\. Amnezia VPN key Hello! It look like Amnezia VPN key doesn't contain **api_endpoint** Where should i get proper api key? (i have self hosted vpn )
Author
Owner

@thepeshka commented on GitHub (Mar 20, 2025):

@ablagovestnov Hi. I don't have a self-hosted VPN, but I'm guessing that you have base64-encoded AWG config instead of VPN key. VPN keys is for free and premium Amnezia servers.

<!-- gh-comment-id:2741828319 --> @thepeshka commented on GitHub (Mar 20, 2025): @ablagovestnov Hi. I don't have a self-hosted VPN, but I'm guessing that you have base64-encoded AWG config instead of VPN key. VPN keys is for free and premium Amnezia servers.
Author
Owner

@kramber1024 commented on GitHub (Apr 11, 2025):

2. Amnezia VPN key

Hello! It look like Amnezia VPN key doesn't contain api_endpoint

Where should i get proper api key?

(i have self hosted vpn )

Hi, any progress?

<!-- gh-comment-id:2797508591 --> @kramber1024 commented on GitHub (Apr 11, 2025): > > 2\. Amnezia VPN key > > Hello! It look like Amnezia VPN key doesn't contain **api_endpoint** > > Where should i get proper api key? > > (i have self hosted vpn ) Hi, any progress?
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#332
No description provided.