API cục bộ của AirdropLogin

Điều khiển profile, nhóm, proxy, lượt chạy workflow, điện thoại ảo và bảng tính từ script của bạn, qua REST API mà app chạy ngay trên máy.

Bắt đầu

Khi AirdropLogin đang mở, app chạy một REST API ngay trên máy bạn. Mọi việc làm được trong app (profile, proxy, chạy workflow, điện thoại ảo, bảng tính) đều gọi được từ script của bạn, bằng bất kỳ ngôn ngữ nào.

MụcGiá trị
Địa chỉ gốchttp://127.0.0.1:3939/api
Cổng3939; nếu bị chiếm thì 3940–3943. Cổng đang dùng ghi trong %APPDATA%\AirdropLogin\data\port.txt.
Xác thựcKhông cần. API chỉ nghe trên 127.0.0.1, nên chỉ chương trình trên chính máy bạn gọi được.
Định dạngGửi và nhận JSON. Request POST có body thì gửi kèm Content-Type: application/json.
LỗiHTTP 400 kèm { "error": "nội dung lỗi" }. Thao tác không có gì trả về thì trả { "ok": true }.
Chạy workflow cần Key còn hạn. Chưa có Key thì API vẫn trả lời, nhưng POST /api/runs báo lỗi.

Lấy cổng từ script

PORT=$(cat "$APPDATA/AirdropLogin/data/port.txt" 2>/dev/null || echo 3939)
curl http://127.0.0.1:$PORT/api/profiles

Các ví dụ bên dưới dùng hàm call() này.

Profiles

GET/api/profiles
Mọi profile: id, name, account, groups, tags, note, proxy, seed, platform, brand, timezone, lang, acceptLang, createdAt, running.
POST/api/profiles/create
Tạo profile. Body: count (tối đa 500), prefix, group, proxies (mỗi profile một proxy, theo thứ tự), platform, brand, timezone, lang, acceptLang.
POST/api/profiles/:id
Sửa một profile, gửi các trường cần đổi (name, note, proxy, seed, timezone…). seed là số nguyên từ 1 đến 2147483647.
POST/api/profiles/bulk
Sửa nhiều profile: ids, patch (trường cần đặt), addTags, removeTags, addGroups, removeGroups.
POST/api/profiles/:id/open
Mở cửa sổ trình duyệt của profile.
POST/api/profiles/:id/close
Đóng lại.
POST/api/close-all
Đóng mọi profile đang mở.
POST/api/profiles/:id/clone
Tạo profile mới cùng cài đặt fingerprint, trình duyệt sạch.
POST/api/profiles/:id/cookies/export
Xuất cookie, có thể lọc theo domain. Trả về { cookies }.
POST/api/profiles/:id/cookies/import
Nhập cookie: text (JSON hoặc định dạng Netscape), domain, mode.
POST/api/profiles/reset
Làm mới trình duyệt cho ids, giữ ID, tên, nhóm, proxy, tag.
POST/api/profiles/clear-cache
Xoá cache trình duyệt của ids.
POST/api/profiles/delete
Xoá ids cùng dữ liệu trình duyệt. Không khôi phục được.

Ví dụ: tạo 5 profile có proxy rồi mở profile đầu

curl -X POST http://127.0.0.1:3939/api/profiles/create -H "Content-Type: application/json" \
  -d '{"count":5,"prefix":"shop","group":"Shop A","proxies":["1.2.3.4:8000:user:pass","1.2.3.5:8000:user:pass"]}'

curl http://127.0.0.1:3939/api/profiles
curl -X POST http://127.0.0.1:3939/api/profiles/PROFILE_ID/open

Nhóm

GET/api/groups
Danh sách tên nhóm.
POST/api/groups
Thêm nhóm: { "name": "Shop A" } (tối đa 60 ký tự).
POST/api/groups/delete
Xoá nhóm theo name. Profile trong nhóm vẫn giữ nguyên.

Muốn đưa profile vào nhóm, dùng POST /api/profiles/bulk với addGroups / removeGroups.

curl -X POST http://127.0.0.1:3939/api/profiles/bulk -H "Content-Type: application/json" \
  -d '{"ids":["ID1","ID2"],"addGroups":["Shop A"],"addTags":["warmed"]}'

Proxy

POST/api/proxy-check
Kiểm tra một proxy. Trả về IP mà proxy hiện ra với trang web.
GET/api/proxy-pool
Danh sách proxy của trang Proxy và cài đặt kèm theo.
POST/api/proxy-pool/apply
Lưu danh sách và chia cho các profile (xen kẽ hoặc theo khối), như nút Áp dụng.
POST/api/proxy-pool/check
Kiểm tra proxy nào trong danh sách còn sống.
POST/api/profiles/:id
Đặt proxy cho một profile: { "proxy": "socks5://user:pass@host:port" }; chuỗi rỗng là bỏ proxy.

Proxy IPv6

GET/api/ipv6
Trạng thái, cài đặt và các địa chỉ của proxy IPv6 tích hợp.
POST/api/ipv6/create
Tạo địa chỉ IPv6 cho profile (Windows sẽ hỏi quyền Admin).
POST/api/ipv6/rotate
Đổi địa chỉ IPv6 mới cho ids.
POST/api/ipv6/delete
Gỡ địa chỉ của ids, hoặc tất cả với { "all": true }.
POST/api/ipv6/test
Kiểm tra địa chỉ của profile id.

Ví dụ: bỏ proxy chết

curl -X POST http://127.0.0.1:3939/api/proxy-check -H "Content-Type: application/json" -d '{"proxy":"1.2.3.4:8000:user:pass"}'

Chạy workflow

GET/api/workflows
Danh sách workflow (dùng id để chạy).
GET/api/tasks
Các task đã lưu (workflow + profile + cấu hình).
POST/api/runs
Chạy workflow: workflowId, profileIds, tuỳ chọn name, inputVars (biến của workflow) và config. Hoặc chạy task đã lưu với { taskId, profileIds }. Trả về lượt chạy kèm id.
Trường configMặc địnhÝ nghĩa
profileThreads3Số profile chạy cùng lúc
delayOpenProfile2Số giây nghỉ giữa các lần mở profile
headlessfalseChạy không hiện cửa sổ
repeatTimes1Số lần chạy mỗi profile
closeBrowsertrueĐóng trình duyệt khi profile chạy xong
randomProfilefalseXáo trộn thứ tự profile
GET/api/runs
Các lượt chạy gần nhất: status, startedAt, finishedAt và profiles[] gồm status, dòng log cuối, error của từng profile.
GET/api/runs/:id/logs/:profileId
Log đầy đủ của một profile trong lượt chạy.
POST/api/runs/:id/stop
Dừng lượt chạy, hoặc chỉ một profile với { profileId }.
POST/api/runs/:id/retry
Chạy lại profileIds trong cùng lượt.
POST/api/runs/:id/threads
Đổi số profile chạy cùng lúc khi đang chạy: { threads }.
POST/api/runs/delete
Xoá lịch sử: { ids } hoặc { allFinished: true }.

Ví dụ: chạy workflow cho một nhóm và chờ xong

curl -X POST http://127.0.0.1:3939/api/runs -H "Content-Type: application/json" \
  -d '{"workflowId":"WORKFLOW_ID","profileIds":["ID1","ID2"],"config":{"profileThreads":2}}'

curl http://127.0.0.1:3939/api/runs

Điện thoại ảo

ID điện thoại có dạng ph-1, ph-2… và dùng được làm profileIds trong POST /api/runs cho workflow 📱.

GET/api/phones/status
Máy có chạy được điện thoại ảo không và trạng thái bộ chạy.
GET/api/phones/machines
Mọi điện thoại kèm tên, nhóm, trạng thái chạy và cài đặt.
POST/api/phones/create
Tạo điện thoại: count, prefix, group, cpu, memory, resolution.
POST/api/phones/clone
Nhân bản máy from thành count bản.
POST/api/phones/launch
Bật các máy ids chạy nền. Trả về { launched }.
POST/api/phones/quit
Tắt các máy ids; /api/phones/quit-all tắt tất cả.
POST/api/phones/install
Cài file APK file (đường dẫn đầy đủ trên máy) cho ids.
POST/api/phones/remove
Xoá các máy ids.
GET/api/phones/:id/screen
Ảnh chụp màn hình điện thoại (PNG).
POST/api/phones/:id/input
Điều khiển máy: {type:"tap",x,y}, {type:"swipe",x1,y1,x2,y2,ms}, {type:"key",key} (vd KEYCODE_HOME), {type:"text",text}.

Ngoài ra còn /api/phones/proxies, /location, /rename, /modify, /backup, /restore, tương ứng các nút ở trang Điện thoại.

curl -X POST http://127.0.0.1:3939/api/phones/launch -H "Content-Type: application/json" -d '{"ids":["ph-1"]}'
curl -X POST http://127.0.0.1:3939/api/phones/ph-1/input -H "Content-Type: application/json" -d '{"type":"tap","x":540,"y":1200}'
curl -o screen.png http://127.0.0.1:3939/api/phones/ph-1/screen

Bảng tính

Bảng tính là nơi workflow đọc và ghi dữ liệu (các node Spreadsheet).

GET/api/sheets
Mọi bảng: id, tên, kích thước.
GET/api/sheets/:id
Một bảng kèm dữ liệu: cells là mảng các hàng, mỗi hàng là mảng giá trị.
POST/api/sheets
Tạo bảng trống: { name }.
POST/api/sheets/import
Nhập Excel/CSV: { paths: ["C:\\data\\list.xlsx"] }, hoặc { name, data } kèm các hàng.
POST/api/sheets/:id/ops
Sửa ô: { ops: [...] }. Mỗi op là {r, c, v} (ghi hàng r, cột c, đếm từ 0), {op:"insertRows",at,n}, {op:"deleteRows",rows}, {op:"insertCols",at,n} hoặc {op:"deleteCols",cols}.
GET/api/sheets/:id/export
Tải bảng về dạng .xlsx.
POST/api/sheets/:id/delete
Xoá bảng.
curl -X POST http://127.0.0.1:3939/api/sheets -H "Content-Type: application/json" -d '{"name":"accounts"}'
curl -X POST http://127.0.0.1:3939/api/sheets/SHEET_ID/ops -H "Content-Type: application/json" \
  -d '{"ops":[{"r":0,"c":0,"v":"Mail"},{"r":0,"c":1,"v":"Status"},{"r":1,"c":0,"v":"a@example.com"}]}'
curl -o accounts.xlsx http://127.0.0.1:3939/api/sheets/SHEET_ID/export

Puppeteer / Playwright

Profile do app mở đều có cổng Chrome DevTools, nên bạn điều khiển được bằng Puppeteer, Playwright hay công cụ CDP bất kỳ mà vẫn giữ fingerprint và proxy. Khi Chrome mở, nó ghi file DevToolsActivePort trong thư mục profile: dòng 1 là cổng, dòng 2 là đường dẫn WebSocket.

  • Thư mục profile: <profilesRoot>\<account>\<số>_<số>_<id>, với profilesRoot lấy từ GET /api/settings và account lấy từ GET /api/profiles.
  • Dùng connect, đừng dùng launch: trình duyệt do app quản lý. Xong việc thì disconnect() rồi đóng bằng POST /api/profiles/:id/close.
  • Profile mở tay ở chế độ sạch (Cài đặt) không có cổng DevTools, nên script không kết nối được.
import fs from "node:fs";
import path from "node:path";
import puppeteer from "puppeteer-core";

const API = "http://127.0.0.1:3939/api";
const call = (m, r, b) => fetch(API + r, { method: m, headers: { "Content-Type": "application/json" }, body: b && JSON.stringify(b) }).then((x) => x.json());

async function connectProfile(id) {
  const { profilesRoot } = await call("GET", "/settings");
  const p = (await call("GET", "/profiles")).find((x) => x.id === id);
  await call("POST", `/profiles/${id}/open`);
  const base = path.join(profilesRoot, p.account);
  const dir = path.join(base, fs.readdirSync(base).find((d) => d.endsWith("_" + id)));
  const file = path.join(dir, "DevToolsActivePort");
  for (let i = 0; i < 60 && !fs.existsSync(file); i++) await new Promise((ok) => setTimeout(ok, 500));
  const [port, wsPath] = fs.readFileSync(file, "utf8").split(/\r?\n/);
  return puppeteer.connect({ browserWSEndpoint: `ws://127.0.0.1:${port}${wsPath}`, defaultViewport: null });
}

const browser = await connectProfile("PROFILE_ID");
const page = await browser.newPage();
await page.goto("https://example.com");
console.log(await page.title());
await browser.disconnect();