[GH-ISSUE #5879] [Feature]: API endpoint to get clients by tg ID #4079

Closed
opened 2026-10-31 20:37:00 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @kimfom01 on GitHub (Jul 9, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5879

I am migrating from Remnawave to 3x-ui and I had a telegram bot that used this feature to identify clients based on their telegram ID and process their payments. In the progress of migrating the bot, I realized that the panel API doesn't support this feature hence the request

Describe the solution you'd like

This is an example of how I envision it to be

curl -X 'GET' \
  'https://panel.example.com/admin/panel/api/clients/get/tg/1234567890' \
  -H 'accept: application/json'

Where 1234567890 is the tg ID.

For now I am not sure if tg ID is supposed to be unique per client or multiple clients can share the same tg ID (on Remnawave, it wasn't unique). Which ever the case may be, I need this integration to enable full adoption of 3x-ui.

Thanks for your kind consideration

Alternatives you've considered

No response

Concrete use case

No response

Mockups, screenshots, or examples

No response

Which parts of the panel would this affect?

Backend (API endpoints, login, settings)

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @kimfom01 on GitHub (Jul 9, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5879 ### Is your feature request related to a problem? I am migrating from Remnawave to 3x-ui and I had a telegram bot that used this feature to identify clients based on their telegram ID and process their payments. In the progress of migrating the bot, I realized that the panel API doesn't support this feature hence the request ### Describe the solution you'd like This is an example of how I envision it to be ``` curl -X 'GET' \ 'https://panel.example.com/admin/panel/api/clients/get/tg/1234567890' \ -H 'accept: application/json' ``` Where 1234567890 is the tg ID. For now I am not sure if tg ID is supposed to be unique per client or multiple clients can share the same tg ID (on Remnawave, it wasn't unique). Which ever the case may be, I need this integration to enable full adoption of 3x-ui. Thanks for your kind consideration ### Alternatives you've considered _No response_ ### Concrete use case _No response_ ### Mockups, screenshots, or examples _No response_ ### Which parts of the panel would this affect? Backend (API endpoints, login, settings) ### Are you willing to help? - [x] I'd like to implement this feature myself and open a PR. - [x] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
bsakaguchi 2026-10-31 20:37:00 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jul 9, 2026):

Confirmed: there is currently no REST endpoint to look up clients by Telegram ID. The only place in the codebase that queries clients by tgId is internal to the Telegram bot, not exposed over HTTP.

On uniqueness (your open question): tgId is not enforced as unique, so multiple clients can share the same Telegram ID today. Client.TgID (internal/database/model/model.go:786, JSON key tgId) is stored in the clients table's tg_id column (ClientRecord.TgID, model.go:816) with no unique index or any index at all — unlike Email, which has a uniqueIndex, and I found no migration in internal/database/db.go that adds one later. The codebase already assumes a one-to-many relationship: InboundService.GetClientTrafficTgBot (internal/web/service/inbound_traffic.go:852) scans all inbounds for every client whose tgId matches and returns traffic for all of them, not just one. That function backs the Telegram bot's own "my traffic" commands (internal/web/service/tgbot/) and isn't wired to any controller route.

What the REST API supports today:

  • GET /panel/api/clients/get/:email — full client record, keyed by email only (internal/web/controller/client.go:50).
  • GET /panel/api/clients/list/paged — accepts a hasTgId=yes|no filter, but that only checks whether a Telegram ID is set, not which value (clientMatchesHasTgID, internal/web/service/client_paging.go:420). Its free-text search parameter doesn't match tgId either — only email, subId, comment, uuid, password, and auth are checked (clientMatchesSearch, client_paging.go:283). The slim rows this endpoint returns don't even include tgId in the payload.

So this is a genuine gap rather than something already possible through an undocumented parameter. A new endpoint would need to return a list rather than a single client, given tgId isn't guaranteed unique — worth keeping in mind for whoever implements it. This is a reasonable ask for a bot-driven integration like yours; leaving it for maintainer prioritization.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4925749517 --> @github-actions[bot] commented on GitHub (Jul 9, 2026): Confirmed: there is currently no REST endpoint to look up clients by Telegram ID. The only place in the codebase that queries clients by `tgId` is internal to the Telegram bot, not exposed over HTTP. **On uniqueness (your open question):** `tgId` is not enforced as unique, so multiple clients can share the same Telegram ID today. `Client.TgID` (`internal/database/model/model.go:786`, JSON key `tgId`) is stored in the `clients` table's `tg_id` column (`ClientRecord.TgID`, `model.go:816`) with no unique index or any index at all — unlike `Email`, which has a `uniqueIndex`, and I found no migration in `internal/database/db.go` that adds one later. The codebase already assumes a one-to-many relationship: `InboundService.GetClientTrafficTgBot` (`internal/web/service/inbound_traffic.go:852`) scans all inbounds for every client whose `tgId` matches and returns traffic for all of them, not just one. That function backs the Telegram bot's own "my traffic" commands (`internal/web/service/tgbot/`) and isn't wired to any controller route. **What the REST API supports today:** - `GET /panel/api/clients/get/:email` — full client record, keyed by email only (`internal/web/controller/client.go:50`). - `GET /panel/api/clients/list/paged` — accepts a `hasTgId=yes|no` filter, but that only checks whether a Telegram ID is set, not which value (`clientMatchesHasTgID`, `internal/web/service/client_paging.go:420`). Its free-text `search` parameter doesn't match `tgId` either — only email, subId, comment, uuid, password, and auth are checked (`clientMatchesSearch`, `client_paging.go:283`). The slim rows this endpoint returns don't even include `tgId` in the payload. So this is a genuine gap rather than something already possible through an undocumented parameter. A new endpoint would need to return a list rather than a single client, given `tgId` isn't guaranteed unique — worth keeping in mind for whoever implements it. This is a reasonable ask for a bot-driven integration like yours; leaving it for maintainer prioritization. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@mrnickson-hue commented on GitHub (Jul 12, 2026):

github.com/MHSanaei/3x-ui@ed9686bf

Upgrade to 3.5.0

<!-- gh-comment-id:4952908352 --> @mrnickson-hue commented on GitHub (Jul 12, 2026): https://github.com/MHSanaei/3x-ui/commit/ed9686bf Upgrade to 3.5.0
Author
Owner

@kimfom01 commented on GitHub (Jul 13, 2026):

github.com/MHSanaei/3x-ui@ed9686bf

Upgrade to 3.5.0

That's not it. I'm talking about an endpoint and not using the search bar on the panel. I know the search bar uses the /panel/api/clients/list/paged endpoint, but that one has a lot of noise. What I'm talking about is a dedicated endpoint similar to the /panel/api/clients/get/{email} endpoint

<!-- gh-comment-id:4955184989 --> @kimfom01 commented on GitHub (Jul 13, 2026): > https://github.com/MHSanaei/3x-ui/commit/ed9686bf > > Upgrade to 3.5.0 That's not it. I'm talking about an endpoint and not using the search bar on the panel. I know the search bar uses the `/panel/api/clients/list/paged` endpoint, but that one has a lot of noise. What I'm talking about is a dedicated endpoint similar to the `/panel/api/clients/get/{email}` endpoint
Sign in to join this conversation.
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
MHSanaei/3x-ui#4079
No description provided.