-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathneofollower.mjs
More file actions
71 lines (59 loc) · 1.38 KB
/
Copy pathneofollower.mjs
File metadata and controls
71 lines (59 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* Minimal NeoFollower Reseller API example.
*
* Requires Node.js 18+ for built-in fetch.
*
* Run:
* NEOFOLLOWER_API_KEY="YOUR_API_KEY" node neofollower.mjs
*/
const API_URL = "https://panel.neofollower.com/api/v1";
const API_KEY = process.env.NEOFOLLOWER_API_KEY;
if (!API_KEY) {
throw new Error("Set NEOFOLLOWER_API_KEY first.");
}
async function requestApi(payload) {
const body = new URLSearchParams({
...payload,
key: API_KEY,
});
const response = await fetch(API_URL, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Accept: "application/json",
},
body,
});
if (!response.ok) {
throw new Error(`NeoFollower API HTTP error: ${response.status}`);
}
return response.json();
}
export function services() {
return requestApi({ action: "services" });
}
export function addOrder({ service, link, quantity, ...extra }) {
return requestApi({
action: "add",
service: String(service),
link,
quantity: String(quantity),
...extra,
});
}
export function status(orderId) {
return requestApi({
action: "status",
order: String(orderId),
});
}
export function multipleStatus(orderIds) {
return requestApi({
action: "status",
orders: orderIds.join(","),
});
}
export function balance() {
return requestApi({ action: "balance" });
}
console.log(await balance());