mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6908] [MERGED] feat(api): add client lookup by subscription ID #6514
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#6514
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6908
Author: @Maximora-byte
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @MHSanaei
Base:
main← Head:feat/api-client-by-subid📝 Commits (3)
c7fc398feat(api): add client lookup by subscription ID8372cb1fix(api): allow null in subscription lookup response schemab61de2aMerge remote-tracking branch 'origin/main' into pr/6908📊 Changes
6 files changed (+369 additions, -1 deletions)
View changed files
📝
docs/content/docs/en/reference/api/clients.mdx(+13 -1)📝
docs/public/openapi.json(+75 -0)📝
frontend/public/openapi.json(+75 -0)📝
frontend/src/pages/api-docs/endpoints.ts(+29 -0)📝
internal/web/controller/client.go(+23 -0)➕
internal/web/controller/client_lookup_test.go(+154 -0)📄 Description
Summary
Add
GET /panel/api/clients/get/subId/:subIdto retrieve full client records directly from an exact subscription ID. The response includes the same client, inbound IDs, external links, traffic usage and tunnel addresses as the existing email lookup.Why
Closes #6792.
The requested
/links/:subIdpath would collide with/links/:email, so this follows the existing/get/tgId/:tgIdlayout. It reusesGetRecordsBySubIDandbuildClientPayload.The response is an array, including disabled, expired and unattached records, ordered by client ID. The existing schema and lookup service explicitly support shared subscription IDs, and inbound synchronization can preserve them; returning only the first record would lose clients. An unknown ID uses the email lookup's HTTP 200
success:false,obj:null, record-not-found convention. The OpenAPI response object is nullable to cover that error envelope.The route remains behind the existing session/admin-token authentication. Monitor, node-sync and node-admin tokens cannot retrieve these credentials. No migration or runtime dispatch change is needed.
Type of change
Areas affected
How was this tested?
TestClientGetBySubIDHTTPreturned 404 against the original router, then passed after the route was implemented.%/_, shared and single IDs, partial/wildcard/missing IDs, disabled orphans, inbound/flow/traffic payloads, and anonymous/admin/restricted-token access.go test -p 4 -shuffle=on -count=1 ./...(50 packages with tests passed),go build -p 4 ./..., and golangci-lint 2.15.0 (0 issues).TestRouteRegistryContractpassed. Regenerated Go schemas/examples/types/Zod match the committed files. Both OpenAPI copies and the client API MDX were regenerated.obj:null) and an array response validate, while a string response is rejected.pnpm install --frozen-lockfile; codegen, typecheck, lint, format check, tests (12 files, 107 tests) and production build passed. The build used an HTTP proxy to fetch the site's existing Google Fonts.Go validation ran in Linux. The Go suite's opt-in live PostgreSQL, Xray gRPC, master/node and scale tests were not enabled.
Screenshots / recordings
Not applicable: API and reference-documentation change; no panel controls or layout changes.
Breaking changes
None. Existing lookup and link routes are unchanged.
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.