Skip to content

Commit 034c00f

Browse files
authored
Merge pull request #163 from CJackHwang/dev
docs: update API documentation, deployment guides, and README with new admin endpoints, compatibility notes, and build instructions
2 parents 390f758 + c3c644f commit 034c00f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1527
-291
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ DS2API_ADMIN_KEY=change-me
1010
DS2API_CONFIG_PATH=/app/config.json
1111
# 2) inline JSON or Base64 JSON
1212
# DS2API_CONFIG_JSON=
13+
# 3) legacy compatibility alias
14+
# CONFIG_JSON=
1315

1416
# Optional: static admin assets path
1517
# DS2API_STATIC_ADMIN_DIR=/app/static/admin

API.en.md

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Use it per deployment mode:
4646

4747
- Local run: read `config.json` directly
4848
- Docker / Vercel: generate Base64 from `config.json`, then set `DS2API_CONFIG_JSON`
49+
- Compatibility note: `DS2API_CONFIG_JSON` may also contain raw JSON directly; `CONFIG_JSON` is the legacy fallback variable
4950

5051
```bash
5152
DS2API_CONFIG_JSON="$(base64 < config.json | tr -d '\n')"
@@ -65,13 +66,15 @@ Two header formats accepted:
6566
| --- | --- |
6667
| Bearer Token | `Authorization: Bearer <token>` |
6768
| API Key Header | `x-api-key: <token>` (no `Bearer` prefix) |
69+
| Gemini-compatible | `x-goog-api-key: <token>` or `?key=<token>` / `?api_key=<token>` |
6870

6971
**Auth behavior**:
7072

7173
- Token is in `config.keys`**Managed account mode**: DS2API auto-selects an account via rotation
7274
- Token is not in `config.keys`**Direct token mode**: treated as a DeepSeek token directly
7375

7476
**Optional header**: `X-Ds2-Target-Account: <email_or_mobile>` — Pin a specific managed account.
77+
Gemini-compatible clients can also send `x-goog-api-key`, `?key=`, or `?api_key=` as the caller credential source.
7578

7679
### Admin Endpoints (`/admin/*`)
7780

@@ -124,13 +127,16 @@ Two header formats accepted:
124127
| GET | `/admin/queue/status` | Admin | Account queue status |
125128
| POST | `/admin/accounts/test` | Admin | Test one account |
126129
| POST | `/admin/accounts/test-all` | Admin | Test all accounts |
130+
| POST | `/admin/accounts/sessions/delete-all` | Admin | Delete all sessions for one account |
127131
| POST | `/admin/import` | Admin | Batch import keys/accounts |
128132
| POST | `/admin/test` | Admin | Test API through service |
129133
| POST | `/admin/vercel/sync` | Admin | Sync config to Vercel |
130134
| GET | `/admin/vercel/status` | Admin | Vercel sync status |
135+
| POST | `/admin/vercel/status` | Admin | Vercel sync status / draft compare |
131136
| GET | `/admin/export` | Admin | Export config JSON/Base64 |
132137
| GET | `/admin/dev/captures` | Admin | Read local packet-capture entries |
133138
| DELETE | `/admin/dev/captures` | Admin | Clear local packet-capture entries |
139+
| GET | `/admin/version` | Admin | Check current version and latest Release |
134140

135141
---
136142

@@ -580,6 +586,7 @@ Returns sanitized config.
580586
```json
581587
{
582588
"keys": ["k1", "k2"],
589+
"env_backed": false,
583590
"accounts": [
584591
{
585592
"identifier": "user@example.com",
@@ -599,7 +606,7 @@ Returns sanitized config.
599606

600607
### `POST /admin/config`
601608

602-
Updatable fields: `keys`, `accounts`, `claude_mapping`.
609+
Only updates `keys`, `accounts`, and `claude_mapping`.
603610

604611
**Request**:
605612

@@ -620,7 +627,8 @@ Updatable fields: `keys`, `accounts`, `claude_mapping`.
620627

621628
Reads runtime settings and status, including:
622629

623-
- `admin` (JWT expiry, default-password warning, etc.)
630+
- `success`
631+
- `admin` (`has_password_hash`, `jwt_expire_hours`, `jwt_valid_after_unix`, `default_password_warning`)
624632
- `runtime` (`account_max_inflight`, `account_max_queue`, `global_max_inflight`)
625633
- `toolcall` / `responses` / `embeddings`
626634
- `auto_delete` (`sessions`)
@@ -650,6 +658,8 @@ Request example:
650658
{"new_password":"your-new-password"}
651659
```
652660

661+
It also accepts `{"password":"your-new-password"}`.
662+
653663
### `POST /admin/config/import`
654664

655665
Imports full config with:
@@ -658,6 +668,8 @@ Imports full config with:
658668
- `mode=replace`
659669

660670
The request can send config directly, or wrapped as `{"config": {...}, "mode":"merge"}`.
671+
Query params `?mode=merge` / `?mode=replace` are also supported.
672+
Import accepts `keys`, `accounts`, `claude_mapping` / `claude_model_mapping`, `model_aliases`, `admin`, `runtime`, `toolcall`, `responses`, `embeddings`, and `auto_delete`.
661673

662674
### `GET /admin/config/export`
663675

@@ -683,6 +695,7 @@ Exports full config in three forms: `config`, `json`, and `base64`.
683695
| --- | --- | --- |
684696
| `page` | `1` | ≥ 1 |
685697
| `page_size` | `10` | 1–100 |
698+
| `q` | empty | Filter by identifier / email / mobile |
686699

687700
**Response**:
688701

@@ -695,7 +708,8 @@ Exports full config in three forms: `config`, `json`, and `base64`.
695708
"mobile": "",
696709
"has_password": true,
697710
"has_token": true,
698-
"token_preview": "abc..."
711+
"token_preview": "abc...",
712+
"test_status": "ok"
699713
}
700714
],
701715
"total": 25,
@@ -705,6 +719,8 @@ Exports full config in three forms: `config`, `json`, and `base64`.
705719
}
706720
```
707721

722+
Returned items also include `test_status`, usually `ok` or `failed`.
723+
708724
### `POST /admin/accounts`
709725

710726
```json
@@ -757,10 +773,14 @@ Exports full config in three forms: `config`, `json`, and `base64`.
757773
"success": true,
758774
"response_time": 1240,
759775
"message": "API test successful (session creation only)",
760-
"model": "deepseek-chat"
776+
"model": "deepseek-chat",
777+
"session_count": 0,
778+
"config_writable": true
761779
}
762780
```
763781

782+
If a `message` is provided, `thinking` may also be included when the upstream response carries reasoning text.
783+
764784
### `POST /admin/accounts/test-all`
765785

766786
Optional request field: `model`.
@@ -774,6 +794,25 @@ Optional request field: `model`.
774794
}
775795
```
776796

797+
The internal concurrency limit is currently fixed at 5.
798+
799+
### `POST /admin/accounts/sessions/delete-all`
800+
801+
Deletes all DeepSeek sessions for a specific account. Request example:
802+
803+
```json
804+
{"identifier":"user@example.com"}
805+
```
806+
807+
Response:
808+
809+
```json
810+
{"success": true, "message": "删除成功"}
811+
```
812+
813+
If the account is missing or deletion fails, `success` becomes `false` and `message` contains the error.
814+
The current handler returns the Chinese literal `删除成功` on success.
815+
777816
### `POST /admin/import`
778817

779818
Batch import keys and accounts.
@@ -851,16 +890,25 @@ Or manual deploy required:
851890
}
852891
```
853892

893+
Failed account checks are returned in `failed_accounts`, and any saved Vercel credentials are returned in `saved_credentials`.
894+
854895
### `GET /admin/vercel/status`
855896

856897
```json
857898
{
858899
"synced": true,
859900
"last_sync_time": 1738400000,
860-
"has_synced_before": true
901+
"has_synced_before": true,
902+
"env_backed": false,
903+
"config_hash": "....",
904+
"last_synced_hash": "....",
905+
"draft_hash": "....",
906+
"draft_differs": false
861907
}
862908
```
863909

910+
`POST /admin/vercel/status` can also accept `config_override` to compare a draft config against the current synced config.
911+
864912
### `GET /admin/export`
865913

866914
```json
@@ -870,6 +918,29 @@ Or manual deploy required:
870918
}
871919
```
872920

921+
This is the same payload as `GET /admin/config/export`, just with a shorter path.
922+
923+
### `GET /admin/version`
924+
925+
Checks the current build version and the latest GitHub Release:
926+
927+
```json
928+
{
929+
"success": true,
930+
"current_version": "2.3.5",
931+
"current_tag": "v2.3.5",
932+
"source": "file:VERSION",
933+
"checked_at": "2026-03-29T00:00:00Z",
934+
"latest_tag": "v2.3.6",
935+
"latest_version": "2.3.6",
936+
"release_url": "https://github.com/CJackHwang/ds2api/releases/tag/v2.3.6",
937+
"published_at": "2026-03-28T12:00:00Z",
938+
"has_update": true
939+
}
940+
```
941+
942+
If GitHub API access fails, the response includes `check_error` while still returning HTTP 200.
943+
873944
### `GET /admin/dev/captures`
874945

875946
Reads local packet-capture status and recent entries (Admin auth required):

0 commit comments

Comments
 (0)