mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4973] [Feature]: Add a parameter of the used traffic in API #3493
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#3493
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 @moonshinem on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4973
Is your feature request related to a problem?
When viewing the panel, you can find out how many GB of traffic is used out of the limit. At the same time, the API returns only the limit, without the amount of traffic spent.
Describe the solution you'd like
Client information API returns this:
{
"success": true,
"msg": "",
"obj": {
"client": {
"totalGB": 132070244352,
"usedGB": 2147483648,
}
Alternatives you've considered
Concrete use case
I need to transmit the values of the used traffic and the traffic limit in the Happ subscription, but I can't receive it correctly from the API because the API doesn't transmit it.
Mockups, screenshots, or examples
Current api returns:
And you can add the usedGB option:
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 (Jun 5, 2026):
Thanks for the clear write-up and example JSON!
Workaround available right now
There is already a dedicated endpoint that returns the traffic counters for a client:
It returns a
ClientTrafficobject with these fields (all byte values):Used traffic in bytes =
up + down.(Note:
totalGBin the/getresponse andtotalhere are both stored in bytes despite thetotalGBfield name.)The enhancement
The feature request here is to fold those traffic counters into the
GET /panel/api/clients/get/:emailresponse so one call returns everything. That is a reasonable convenience improvement — right now you need two calls: one to/get/:emailfor configuration and one to/traffic/:emailfor usage stats.Concretely, what would need to change:
web/controller/client.go→gethandler: after fetching theClientRecord, also callinboundService.GetClientTrafficByEmail(email)and include the result (or just the computed sumup+down) in the response object.ClientRecordmodel itself (indatabase/model/model.go) does not store traffic — it would be enriched at the handler level, similar to howinboundIdsis already appended to the same response today.If you'd like to open a PR, the relevant handler is at
web/controller/client.golines 103–122.@MHSanaei commented on GitHub (Jun 12, 2026):
Implemented in
d1a13844. The client-get endpoint now returns the consumed bytes alongside the record:usedTrafficis up+down in bytes (same unit as totalGB) and includes cross-node usage in multi-node setups, so you can pair it directly with the quota for the Happ subscription headers. It''s a sibling key rather than a field insideclientto keep the stored model unchanged. Will be in the next release.