Bỏ qua tới nội dung
Tài liệu NextCore homestaynextcore.org

Local API của NextCore Browser

Điều khiển profile bằng script chạy trên cùng máy — tạo, mở, lấy cổng CDP, xếp cửa sổ, sao lưu, khôi phục.

Bật và lấy token

Cài đặt › Local API: bật Bật Local API, đặt Cổng (mặc định 19880), bấm Hiện để xem Token.

curl -H "Authorization: Bearer $NCB_TOKEN" http://127.0.0.1:19880/api/v1/status

Endpoint

Phương thức Đường dẫn Thân yêu cầu Trả về
GET /api/v1/status phiên bản app, engine
GET /api/v1/profiles?group=&q= danh sách profile (không có mật khẩu proxy)
POST /api/v1/profiles { name?, group?, proxy?, tags?, note?, startUrl?, extensionIds?, engineId? } profile mới (để trống name ⇒ NEXTCORE BROWSER NN)
GET /api/v1/profiles/:id một profile
PATCH /api/v1/profiles/:id các trường cần đổi profile
DELETE /api/v1/profiles/:id chuyển vào thùng rác
POST /api/v1/profiles/:id/start { pid, debugPort, wsEndpoint }
POST /api/v1/profiles/:id/stop
GET /api/v1/running các profile đang mở
POST /api/v1/arrange { ids?, rows?, cols?, gap?, displayId? } { arranged, failed }
GET /api/v1/engines trình duyệt trên máy + engine mặc định
GET/POST /api/v1/extensions POST: { path, isDefault? } thư viện tiện ích
POST /api/v1/profiles/:id/backup { password (≥ 8 ký tự), dest? } đường dẫn tệp .ncbak
POST /api/v1/backups/restore { file, password, onConflict?: 'skip'|'replace'|'keepBoth' } kết quả khôi phục (mặc định skip)

proxy nhận đúng các định dạng như giao diện. rows và cols phải đi cùng nhau; bỏ cả hai ⇒ lưới tự động. Profile chạy Firefox trả debugPort/wsEndpoint là null và không xếp được.

Mã Khi nào
401 thiếu / sai token
403 yêu cầu có header Origin
404 không có profile
409 profile đang mở / đang đóng dở

Điều khiển profile bằng Playwright

import { chromium } from 'playwright'

const API = 'http://127.0.0.1:19880/api/v1'
const H = { Authorization: `Bearer ${process.env.NCB_TOKEN}`, 'Content-Type': 'application/json' }

const p = await (await fetch(`${API}/profiles`, { method: 'POST', headers: H, body: JSON.stringify({ group: 'Farm máy 1' }) })).json()
const run = await (await fetch(`${API}/profiles/${p.id}/start`, { method: 'POST', headers: H })).json()

const browser = await chromium.connectOverCDP(run.wsEndpoint)
const page = browser.contexts()[0].pages()[0] ?? (await browser.contexts()[0].newPage())
await page.goto('https://homestaynextcore.org')
console.log(await page.title())

await browser.close() // ngắt kết nối CDP, profile vẫn mở
await fetch(`${API}/profiles/${p.id}/stop`, { method: 'POST', headers: H })

Puppeteer: puppeteer.connect({ browserWSEndpoint: run.wsEndpoint }).

Lưu ý Script chỉ điều khiển được profile khi app đang chạy và đã đăng nhập. Giữ token như mật khẩu — ai có token và chạy được code trên máy bạn là điều khiển được mọi profile.