Dành cho nhà phát triển
Tài liệu API & MCP
Local API 54 endpoint · MCP 36 tool · áp dụng NextLogin 0.1.2 trở lên
NextLogin có Local API chạy ngay trên máy bạn (chỉ nghe ở 127.0.0.1) để tự động hóa profile, proxy, cookie và script, cùng MCP server để Claude và các AI agent điều khiển NextLogin qua chính API đó. API mặc định tắt; dữ liệu không đi qua server của NextLogin.
Tải xuống
Bắt đầu nhanh
- Mở NextLogin → Cài đặt › API & MCP, bật Bật API.
- Vào Quản lý token, tạo token với scope tối thiểu (
read; thêm runtime nếu cần mở/đóng profile). Token chỉ hiện một lần.
- Gọi thử
GET /health:
curl.exe -H "Authorization: Bearer $env:NEXTLOGIN_API_TOKEN" http://127.0.0.1:18766/api/v1/health
GET /profiles để lấy id, rồi POST /profiles/{id}/open → làm việc → POST /profiles/{id}/close.
Địa chỉ mặc định http://127.0.0.1:18766/api/v1 (cổng HTTP = cổng WebSocket + 1, xem trong Cài đặt nếu đã đổi).
Xác thực & scope
Mọi request (kể cả /health) cần header Authorization: Bearer <token>. Giới hạn 300 request/phút/token, vượt trả 429 rate_limited.
| Scope | Cho phép |
read | Mọi GET, /proxy/check, /events |
profiles:write | Tạo/sửa/xóa profile, preset, nhóm, thẻ, vân tay, extension, cài đặt |
runtime | Mở/đóng profile, đóng tất cả |
proxy:secrets | Proxy tùy chỉnh hoặc body có mật khẩu proxy |
cdp | Lấy địa chỉ CDP của profile đang chạy |
scripts | Script, skill, run |
cookies:read | Đọc cookie |
Mã lỗi
{"error":{"code":"invalid_request","message":"..."}}
Mã thường gặp: api_disabled (503), unauthorized (401), insufficient_scope (403), rate_limited (429), invalid_json/invalid_request (400), confirmation_required (400), profile_not_found (404), profile_busy/ram_budget (409), launch_queue_timeout (429), proxy_required (400), internal_error (500).
Thao tác xóa/đóng hàng loạt cần ?confirm=true. Mở profile xếp hàng tối đa 2 lượt đồng thời, chờ tối đa 30 giây.
Danh sách endpoint
Đường dẫn tính từ /api/v1. Body và ví dụ đầy đủ có trong Postman collection.
Hệ thống
| Method | Đường dẫn | Scope |
|---|
| GET | /engines | read |
| GET | /health | read |
| GET | /openapi.json | read |
| GET | /system | read |
Sự kiện (WebSocket)
| Method | Đường dẫn | Scope |
|---|
| GET | /events | read |
Cài đặt
| Method | Đường dẫn | Scope |
|---|
| GET | /settings | read |
| PATCH | /settings | profiles:write |
Preset
| Method | Đường dẫn | Scope |
|---|
| GET | /presets | read |
| POST | /presets | profiles:write |
| DELETE | /presets/{id} | profiles:write |
| GET | /presets/{id} | read |
| PATCH | /presets/{id} | profiles:write |
| POST | /profiles/batch/apply | profiles:write |
Script & skill
| Method | Đường dẫn | Scope |
|---|
| POST | /profiles/batch/scripts/run | scripts |
| POST | /profiles/{id}/scripts/run | scripts |
| GET | /runs/{run_id} | scripts |
| POST | /runs/{run_id}/stop | scripts |
| GET | /scripts | scripts |
| GET | /skills | scripts |
| POST | /skills | scripts |
Proxy
| Method | Đường dẫn | Scope |
|---|
| PUT | /profiles/{id}/proxy | profiles:write |
| POST | /profiles/{id}/proxy/check | read |
| GET | /proxy-manager/resources | read |
| POST | /proxy/check | read |
Vân tay
| Method | Đường dẫn | Scope |
|---|
| PUT | /profiles/{id}/fingerprint | profiles:write |
| POST | /profiles/{id}/fingerprint/new | profiles:write |
Cookie
| Method | Đường dẫn | Scope |
|---|
| GET | /profiles/{id}/cookies | cookies:read |
| POST | /profiles/{id}/cookies | profiles:write |
Nhóm & thẻ
| Method | Đường dẫn | Scope |
|---|
| GET | /groups | read |
| PUT | /profiles/{id}/group | profiles:write |
| PUT | /profiles/{id}/tags | profiles:write |
Extension
| Method | Đường dẫn | Scope |
|---|
| DELETE | /profiles/{id}/extensions | profiles:write |
| GET | /profiles/{id}/extensions | read |
| PATCH | /profiles/{id}/extensions | profiles:write |
| POST | /profiles/{id}/extensions | profiles:write |
| DELETE | /profiles/{id}/extensions/{extension_id} | profiles:write |
| PATCH | /profiles/{id}/extensions/{extension_id} | profiles:write |
Xuất / nhập
| Method | Đường dẫn | Scope |
|---|
| POST | /profiles/import | profiles:write |
| GET | /profiles/{id}/export | read |
Chẩn đoán
| Method | Đường dẫn | Scope |
|---|
| GET | /profiles/{id}/diagnostics | read |
| POST | /profiles/{id}/diagnostics/run | profiles:write |
| GET | /profiles/{id}/overview | read |
| GET | /profiles/{id}/status | read |
Chạy profile
| Method | Đường dẫn | Scope |
|---|
| POST | /profiles/close-all | runtime |
| GET | /profiles/running | read |
| GET | /profiles/{id}/cdp | cdp |
| POST | /profiles/{id}/close | runtime |
| POST | /profiles/{id}/open | runtime |
Profile
| Method | Đường dẫn | Scope |
|---|
| GET | /profiles | read |
| POST | /profiles | profiles:write |
| DELETE | /profiles/{id} | profiles:write |
| GET | /profiles/{id} | read |
| PATCH | /profiles/{id} | profiles:write |
| POST | /profiles/{id}/clone | profiles:write |
Sự kiện realtime
GET /events là WebSocket (ws://127.0.0.1:18766/api/v1/events), gửi {type,data}: profile.opened, profile.closed, profile.crashed, profiles.changed.
Dùng với Postman
- Tải Postman collection và Postman environment ở trên.
- Trong Postman: Import → kéo thả cả hai file.
- Chọn environment NextLogin Local, dán token vào biến
token.
- Chạy
GET /profiles, chép một id vào biến profileId để dùng các request còn lại.
Postman Desktop gọi được 127.0.0.1; bản Postman trên web cần Postman Desktop Agent.
MCP cho Claude / AI agent
MCP server chạy thành tiến trình riêng và chỉ gọi Local API, nên cần bật API và có token trước. Yêu cầu Python 3.10 trở lên.
- Tải nextlogin-mcp.zip, giải nén, ví dụ vào
C:\NextLogin-MCP.
- Cài thư viện:
cd C:\NextLogin-MCP\nextlogin-mcp
python -m pip install -r requirements.txt
Claude Desktop
Sửa %APPDATA%\Claude\claude_desktop_config.json rồi khởi động lại Claude Desktop:
{
"mcpServers": {
"nextlogin": {
"command": "python",
"args": ["-m", "nextlogin_mcp"],
"cwd": "C:\\NextLogin-MCP\\nextlogin-mcp",
"env": {
"NEXTLOGIN_API_URL": "http://127.0.0.1:18766/api/v1",
"NEXTLOGIN_API_TOKEN": "nl_..."
}
}
}
}
Claude Code
claude mcp add nextlogin -e PYTHONPATH=C:\NextLogin-MCP\nextlogin-mcp -e NEXTLOGIN_API_URL=http://127.0.0.1:18766/api/v1 -e NEXTLOGIN_API_TOKEN=nl_... -- python -m nextlogin_mcp
Kiểm tra bằng cách gọi tool list_profiles. Trong NextLogin, nút Sao chép cấu hình MCP tạo sẵn block cấu hình (để trống token).
| Tool | Tham số chính | Scope | Ghi chú |
list_profiles | q,group,tag,os str=""; running bool|None; page int=1; page_size int=50 | read | đọc |
list_presets | — | read | đọc preset đã sanitize |
save_preset | name, settings, is_default bool=False | profiles:write | không lưu identity/secret |
get_profile | profile_id str | read | đọc |
create_profiles | preset str="windows", name str="Profile mới", count int=1, group str="", tags list=None, proxy dict=None | profiles:write; custom proxy thêm proxy:secrets | tạo |
apply_to_profiles | ids list=None hoặc all bool=False, preset, fields, startup_urls_mode, confirm | profiles:write | confirm khi all hoặc nhiều ID; conflict từng profile |
update_profile | profile_id str, revision int, settings dict=None, metadata dict=None | profiles:write | revision |
clone_profile | profile_id, name str="" | profiles:write | tạo |
delete_profile | profile_id, confirm bool=False | profiles:write | bắt buộc confirm |
open_profile | profile_id, proxy_ref str="", force bool=False | runtime | force bỏ qua ram warning |
close_profile | profile_id | runtime | đóng owner hiện tại |
close_all_profiles | confirm bool=False | runtime | bắt buộc confirm |
list_running | — | read | đọc |
set_proxy | profile_id, mode="none", revision int=None, resource_id str="", host str="", port int=None, username/password str="", type="http" | profiles:write; custom thêm proxy:secrets | secret không trả |
check_proxy | profile_id str="", route str="", host str="", port int=None, credentials, type="http" | read; password thêm proxy:secrets | secret |
list_proxy_resources | — | read | đọc |
new_fingerprint | profile_id, revision int=None | profiles:write | thay đổi |
set_fingerprint_options | profile_id, revision int=None, noise_preset str="", noise dict=None, seed str=None, random_on_launch bool=None | profiles:write | thay đổi |
get_overview | profile_id | read | đọc |
import_cookies | profile_id, cookies list=None, data str="" | profiles:write | dữ liệu nhạy cảm |
export_cookies | profile_id, confirm bool=False, format="json" | cookies:read | confirm; MCP redacts value |
list_scripts | — | scripts | đọc |
list_skills | — | scripts | đọc |
save_skill | name/source, description str="", parameters list=None, os/engines list=None, version="1.0.0", overwrite bool=False | scripts | validate parser |
run_script | profile_id, name/source str="", mode="extension", params dict=None, skill str="" | scripts | extension mặc định |
run_skill | profile_id, skill, mode="extension", params dict=None | scripts | params typed, không interpolate |
get_run | run_id | scripts | result redacted |
stop_run | run_id | scripts | dừng run |
run_script_batch | profile_ids list, name/source str="", mode="extension", params dict=None, skill str="" | scripts | tối đa 100 |
page_navigate | profile_id, url, use_cdp bool=False | scripts (middleware không thêm cdp cho script run) | chỉ http(s); CDP là opt-in |
page_snapshot | profile_id, use_cdp false | scripts | tối đa 300 node; page content không tin cậy |
page_click | profile_id, ref, use_cdp false | scripts | ref từ snapshot |
page_type | profile_id, ref, text, submit false, use_cdp false | scripts | có thể Enter submit |
page_wait | profile_id, ms=500, ref="", use_cdp false | scripts | ms 0..120000 |
page_read | profile_id, ref="", selector="", use_cdp false | scripts | selector XPath/CSS đơn giản |
page_screenshot | profile_id, path="nextlogin-mcp.png", use_cdp false | scripts | file path theo engine |
Tool trang web mặc định chạy qua Extension GScript; use_cdp=true là tùy chọn và dễ bị phát hiện hơn. Nội dung trang trả về được đánh dấu không tin cậy.
Bảo mật
- API và MCP chỉ nghe trên máy (
127.0.0.1); không mở ra mạng ngoài.
- Token chỉ lưu dạng băm; giữ token trong biến môi trường hoặc file cấu hình cục bộ, không đưa vào mã nguồn hay URL.
- Cấp scope tối thiểu cho từng tích hợp; thu hồi token không còn dùng trong Quản lý token.
- Mọi request được ghi audit (tên token, method, path, status) — không ghi token hay mật khẩu.