mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5879] [Feature]: API endpoint to get clients by tg ID #4079
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4079
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
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?
Before submitting
@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
tgIdis internal to the Telegram bot, not exposed over HTTP.On uniqueness (your open question):
tgIdis not enforced as unique, so multiple clients can share the same Telegram ID today.Client.TgID(internal/database/model/model.go:786, JSON keytgId) is stored in theclientstable'stg_idcolumn (ClientRecord.TgID,model.go:816) with no unique index or any index at all — unlikeEmail, which has auniqueIndex, and I found no migration ininternal/database/db.gothat 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 whosetgIdmatches 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 ahasTgId=yes|nofilter, but that only checks whether a Telegram ID is set, not which value (clientMatchesHasTgID,internal/web/service/client_paging.go:420). Its free-textsearchparameter doesn't matchtgIdeither — only email, subId, comment, uuid, password, and auth are checked (clientMatchesSearch,client_paging.go:283). The slim rows this endpoint returns don't even includetgIdin 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
tgIdisn'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.
@mrnickson-hue commented on GitHub (Jul 12, 2026):
github.com/MHSanaei/3x-ui@ed9686bfUpgrade to 3.5.0
@kimfom01 commented on GitHub (Jul 13, 2026):
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/pagedendpoint, 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