silent-akinator-pro 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,18 +1,52 @@
1
- # 🧞 SILENT-AKINATOR PRO 🧞
2
- ### BY SILENT TECH
1
+ # silent-akinator-pro
3
2
 
4
- The most reliable Akinator API for developers.
3
+ > **Silent Tech** — a modern, working Akinator API wrapper for Node.js.
5
4
 
6
- ## 🚀 INSTALL
7
- `npm install silent-akinator-pro`
5
+ [![npm](https://img.shields.io/npm/v/silent-akinator-pro.svg)](https://www.npmjs.com/package/silent-akinator-pro)
8
6
 
9
- ## 💻 USAGE
10
- ```javascript
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install silent-akinator-pro
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```js
11
16
  const { Akinator } = require('silent-akinator-pro');
12
- const api = new Akinator({ region: 'en', childMode: false });
13
17
 
14
18
  (async () => {
15
- await api.start();
16
- console.log(api.question);
19
+ const aki = new Akinator({ region: 'en', childMode: false });
20
+ await aki.start();
21
+
22
+ console.log(aki.question);
23
+ await aki.answer('y'); // y / n / idk / p / pn
24
+ console.log(aki.question);
25
+
26
+ // ...keep answering until aki.guessed === true
27
+ if (aki.guess) {
28
+ console.log('Akinator thinks of:', aki.guess.name);
29
+ }
17
30
  })();
18
31
  ```
32
+
33
+ ## API
34
+
35
+ ### `new Akinator({ region, childMode })`
36
+ - `region` — `en`, `ar`, `cn`, `de`, `es`, `fr`, `il`, `it`, `jp`, `kr`, `nl`, `pl`, `pt`, `ru`, `tr`, `id`
37
+ - `childMode` — boolean, filters adult content
38
+
39
+ ### Methods
40
+ | Method | Description |
41
+ |--------|-------------|
42
+ | `start()` | Begin a new game |
43
+ | `answer(a)` | `y` / `n` / `idk` / `p` / `pn` (or 0-4) |
44
+ | `back()` | Undo the previous answer |
45
+ | `continue()` | Reject the current guess and keep playing |
46
+ | `win()` | Confirm the guess and end the game |
47
+
48
+ ### Properties
49
+ `question`, `step`, `progression`, `guess`, `guessed`, `finished`.
50
+
51
+ ## License
52
+ MIT © Silent Tech
package/package.json CHANGED
@@ -1,12 +1,34 @@
1
1
  {
2
2
  "name": "silent-akinator-pro",
3
- "version": "2.0.0",
4
- "description": "Standalone High-Speed Akinator SDK. Bypasses Cloudflare using Mobile-Handshake logic. No dependencies required.",
5
- "main": "index.js",
6
- "keywords": ["akinator", "aki", "silent-tech", "baileys", "wa-bot", "cloudflare-bypass"],
3
+ "version": "2.0.1",
4
+ "description": "Silent Tech \u2014 A modern, working Akinator API wrapper for Node.js. Play the genie game programmatically.",
5
+ "main": "src/index.js",
6
+ "types": "src/index.d.ts",
7
+ "scripts": {
8
+ "test": "node examples/basic.js"
9
+ },
10
+ "keywords": [
11
+ "akinator",
12
+ "silent",
13
+ "silent-tech",
14
+ "silent-akinator",
15
+ "game",
16
+ "genie",
17
+ "api",
18
+ "wrapper"
19
+ ],
7
20
  "author": "Silent Tech",
8
21
  "license": "MIT",
9
22
  "dependencies": {
10
- "axios": "^1.6.0"
11
- }
12
- }
23
+ "axios": "^1.7.7",
24
+ "cheerio": "^1.0.0"
25
+ },
26
+ "engines": {
27
+ "node": ">=14"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/silent-tech/silent-akinator-pro"
32
+ },
33
+ "homepage": "https://www.npmjs.com/package/silent-akinator-pro"
34
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,33 @@
1
+
2
+ export interface AkinatorOptions {
3
+ region?: 'en'|'ar'|'cn'|'de'|'es'|'fr'|'il'|'it'|'jp'|'kr'|'nl'|'pl'|'pt'|'ru'|'tr'|'id';
4
+ childMode?: boolean;
5
+ }
6
+ export interface Guess {
7
+ id: string;
8
+ name: string;
9
+ description: string;
10
+ image: string;
11
+ }
12
+ export type AnswerInput = 'y'|'n'|'idk'|'p'|'pn'|0|1|2|3|4|string|number;
13
+
14
+ export class Akinator {
15
+ constructor(options?: AkinatorOptions);
16
+ region: string;
17
+ childMode: boolean;
18
+ session: string | null;
19
+ signature: string | null;
20
+ step: number;
21
+ progression: string;
22
+ question: string | null;
23
+ guess: Guess | null;
24
+ guessed: boolean;
25
+ finished: boolean;
26
+ start(): Promise<{ question: string; step: number; progression: string }>;
27
+ answer(ans: AnswerInput): Promise<{ question?: string; step?: number; progression?: string; guess?: Guess }>;
28
+ back(): Promise<{ question: string; step: number; progression: string }>;
29
+ continue(): Promise<{ question: string; step: number; progression: string }>;
30
+ win(): Promise<{ winner: Guess | null }>;
31
+ }
32
+ export const REGIONS: string[];
33
+ export default Akinator;
package/src/index.js ADDED
@@ -0,0 +1,244 @@
1
+
2
+ /**
3
+ * silent-akinator-pro
4
+ * Silent Tech — Working Akinator API wrapper.
5
+ *
6
+ * Usage:
7
+ * const { Akinator } = require('silent-akinator-pro');
8
+ * const aki = new Akinator({ region: 'en', childMode: false });
9
+ * await aki.start();
10
+ * console.log(aki.question);
11
+ * await aki.answer('y'); // y / n / idk / p / pn
12
+ * if (aki.guess) console.log(aki.guess);
13
+ */
14
+
15
+ const axios = require('axios');
16
+ const cheerio = require('cheerio');
17
+
18
+ const REGIONS = ['en','ar','cn','de','es','fr','il','it','jp','kr','nl','pl','pt','ru','tr','id'];
19
+
20
+ const ANSWER_MAP = {
21
+ // yes
22
+ 'y': 0, 'yes': 0, 'oui': 0, '0': 0,
23
+ // no
24
+ 'n': 1, 'no': 1, 'non': 1, '1': 1,
25
+ // don't know
26
+ 'idk': 2, 'dk': 2, "don't know": 2, 'dont know': 2, '2': 2,
27
+ // probably
28
+ 'p': 3, 'probably': 3, '3': 3,
29
+ // probably not
30
+ 'pn': 4, 'probably not': 4, '4': 4
31
+ };
32
+
33
+ class Akinator {
34
+ constructor({ region = 'en', childMode = false } = {}) {
35
+ if (!REGIONS.includes(region)) {
36
+ throw new Error(`Invalid region "${region}". Use one of: ${REGIONS.join(', ')}`);
37
+ }
38
+ this.region = region;
39
+ this.childMode = !!childMode;
40
+ this.baseURL = `https://${region}.akinator.com`;
41
+ this.session = null;
42
+ this.signature = null;
43
+ this.step = 0;
44
+ this.progression = '0.00000';
45
+ this.question = null;
46
+ this.guess = null; // { name, description, image, id }
47
+ this.guessed = false;
48
+ this.finished = false;
49
+ this._client = axios.create({
50
+ baseURL: this.baseURL,
51
+ headers: {
52
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 SilentTech/1.0',
53
+ 'Accept-Language': 'en-US,en;q=0.9',
54
+ 'Origin': this.baseURL,
55
+ 'Referer': `${this.baseURL}/game`,
56
+ 'X-Requested-With': 'XMLHttpRequest'
57
+ },
58
+ timeout: 20000,
59
+ validateStatus: () => true
60
+ });
61
+ }
62
+
63
+ /** Begin a new game session. */
64
+ async start() {
65
+ const body = new URLSearchParams({
66
+ sid: '1',
67
+ cm: this.childMode ? 'true' : 'false'
68
+ }).toString();
69
+
70
+ const res = await this._client.post('/game', body, {
71
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
72
+ });
73
+
74
+ if (res.status >= 400) {
75
+ throw new Error(`Failed to start game (HTTP ${res.status})`);
76
+ }
77
+
78
+ const html = res.data;
79
+ const $ = cheerio.load(html);
80
+
81
+ // session + signature live in inline JS / hidden inputs
82
+ const sessionMatch = html.match(/#session['"]?\s*\)\s*\.val\(\s*['"]?(\d+)['"]?\s*\)/)
83
+ || html.match(/name=['"]session['"][^>]*value=['"](\d+)['"]/);
84
+ const signatureMatch = html.match(/#signature['"]?\s*\)\s*\.val\(\s*['"]?(\d+)['"]?\s*\)/)
85
+ || html.match(/name=['"]signature['"][^>]*value=['"](\d+)['"]/);
86
+
87
+ if (!sessionMatch || !signatureMatch) {
88
+ throw new Error('Akinator did not return a valid session. The site layout may have changed.');
89
+ }
90
+
91
+ this.session = sessionMatch[1];
92
+ this.signature = signatureMatch[1];
93
+ this.step = 0;
94
+ this.progression = '0.00000';
95
+ this.guess = null;
96
+ this.guessed = false;
97
+ this.finished = false;
98
+
99
+ const q = $('#question-label').text().trim() || $('.question-text').text().trim();
100
+ this.question = q || null;
101
+ return { question: this.question, step: this.step, progression: this.progression };
102
+ }
103
+
104
+ _normalizeAnswer(a) {
105
+ if (typeof a === 'number') {
106
+ if (a < 0 || a > 4) throw new Error('Answer must be 0-4');
107
+ return a;
108
+ }
109
+ const k = String(a).toLowerCase().trim();
110
+ if (!(k in ANSWER_MAP)) {
111
+ throw new Error(`Unknown answer "${a}". Use y / n / idk / p / pn or 0-4.`);
112
+ }
113
+ return ANSWER_MAP[k];
114
+ }
115
+
116
+ /** Answer the current question. */
117
+ async answer(ans) {
118
+ if (!this.session) throw new Error('Call start() first.');
119
+ if (this.finished) throw new Error('Game already finished.');
120
+
121
+ const answer = this._normalizeAnswer(ans);
122
+
123
+ const body = new URLSearchParams({
124
+ step: String(this.step),
125
+ progression: String(this.progression),
126
+ sid: '1',
127
+ cm: this.childMode ? 'true' : 'false',
128
+ answer: String(answer),
129
+ step_last_proposition: '',
130
+ session: this.session,
131
+ signature: this.signature
132
+ }).toString();
133
+
134
+ const res = await this._client.post('/answer', body, {
135
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
136
+ });
137
+
138
+ if (res.status >= 400) {
139
+ throw new Error(`Answer failed (HTTP ${res.status})`);
140
+ }
141
+
142
+ const data = typeof res.data === 'string' ? safeJSON(res.data) : res.data;
143
+ if (!data) throw new Error('Invalid response from Akinator.');
144
+
145
+ // Akinator decided to guess
146
+ if (data.id_proposition || data.id_base_proposition) {
147
+ this.guess = {
148
+ id: data.id_proposition || data.id_base_proposition,
149
+ name: data.name_proposition,
150
+ description: data.description_proposition,
151
+ image: data.photo
152
+ };
153
+ this.guessed = true;
154
+ return { guess: this.guess };
155
+ }
156
+
157
+ this.step = parseInt(data.step ?? this.step + 1, 10);
158
+ this.progression = String(data.progression ?? this.progression);
159
+ this.question = data.question || null;
160
+
161
+ return {
162
+ question: this.question,
163
+ step: this.step,
164
+ progression: this.progression
165
+ };
166
+ }
167
+
168
+ /** Undo the last answer. */
169
+ async back() {
170
+ if (!this.session) throw new Error('Call start() first.');
171
+ if (this.step <= 0) throw new Error('No previous question.');
172
+
173
+ const body = new URLSearchParams({
174
+ step: String(this.step),
175
+ progression: String(this.progression),
176
+ sid: '1',
177
+ cm: this.childMode ? 'true' : 'false',
178
+ session: this.session,
179
+ signature: this.signature
180
+ }).toString();
181
+
182
+ const res = await this._client.post('/cancel_answer', body, {
183
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
184
+ });
185
+
186
+ const data = typeof res.data === 'string' ? safeJSON(res.data) : res.data;
187
+ if (!data) throw new Error('Invalid response from Akinator.');
188
+
189
+ this.step = parseInt(data.step ?? Math.max(0, this.step - 1), 10);
190
+ this.progression = String(data.progression ?? this.progression);
191
+ this.question = data.question || this.question;
192
+
193
+ return {
194
+ question: this.question,
195
+ step: this.step,
196
+ progression: this.progression
197
+ };
198
+ }
199
+
200
+ /** Tell Akinator the guess was wrong and continue playing. */
201
+ async continue() {
202
+ if (!this.guessed) throw new Error('No active guess to reject.');
203
+ const body = new URLSearchParams({
204
+ step: String(this.step),
205
+ progression: String(this.progression),
206
+ sid: '1',
207
+ cm: this.childMode ? 'true' : 'false',
208
+ session: this.session,
209
+ signature: this.signature
210
+ }).toString();
211
+
212
+ const res = await this._client.post('/exclude', body, {
213
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
214
+ });
215
+
216
+ const data = typeof res.data === 'string' ? safeJSON(res.data) : res.data;
217
+ if (!data) throw new Error('Invalid response from Akinator.');
218
+
219
+ this.guess = null;
220
+ this.guessed = false;
221
+ this.step = parseInt(data.step ?? this.step + 1, 10);
222
+ this.progression = String(data.progression ?? this.progression);
223
+ this.question = data.question || null;
224
+
225
+ return {
226
+ question: this.question,
227
+ step: this.step,
228
+ progression: this.progression
229
+ };
230
+ }
231
+
232
+ /** Confirm the guess was correct (ends the game). */
233
+ async win() {
234
+ this.finished = true;
235
+ return { winner: this.guess };
236
+ }
237
+ }
238
+
239
+ function safeJSON(s) {
240
+ try { return JSON.parse(s); } catch { return null; }
241
+ }
242
+
243
+ module.exports = { Akinator, REGIONS, ANSWER_MAP };
244
+ module.exports.default = Akinator;
package/index.js DELETED
@@ -1,86 +0,0 @@
1
- const axios = require('axios');
2
-
3
- class Akinator {
4
- constructor(config = { region: 'en', childMode: false }) {
5
- this.region = config.region || 'en';
6
- this.childMode = config.childMode || false;
7
- this.baseUrl = `https://${this.region}.akinator.com`;
8
- this.session = null;
9
- this.signature = null;
10
- this.step = 0;
11
- this.progress = 0;
12
- this.question = null;
13
- this.isWin = false;
14
- this.sugestion_name = null;
15
- this.sugestion_desc = null;
16
- this.sugestion_photo = null;
17
-
18
- // 🚀 MOBILE SPOOFING HEADERS
19
- this.headers = {
20
- 'User-Agent': 'Akinator/1.2.3 (Android; 13; Scale/2.0)',
21
- 'X-Requested-With': 'com.digidust.akinator.freemium',
22
- 'Accept': 'application/json',
23
- 'Referer': `https://${this.region}.akinator.com/`
24
- };
25
- }
26
-
27
- async start() {
28
- console.log("💀 SILENT TECH ENGINE v2.0: BOOTING...");
29
- try {
30
- const res = await axios.get(`${this.baseUrl}/new_session`, {
31
- params: { childMod: this.childMode, player: 'website-desktop' },
32
- headers: this.headers
33
- });
34
- const data = res.data.parameters;
35
- this.session = data.identification.session;
36
- this.signature = data.identification.signature;
37
- this.question = data.step_information.question;
38
- console.log("✅ SILENT TECH: Handshake Successful.");
39
- return this;
40
- } catch (e) {
41
- throw new Error("Cloudflare Block: Akinator rejected the connection.");
42
- }
43
- }
44
-
45
- async answer(ansId) {
46
- try {
47
- const res = await axios.get(`${this.baseUrl}/answer`, {
48
- params: {
49
- session: this.session,
50
- signature: this.signature,
51
- step: this.step,
52
- answer: ansId
53
- },
54
- headers: this.headers
55
- });
56
- const data = res.data.parameters;
57
- this.step++;
58
- this.progress = parseFloat(data.progression);
59
- this.question = data.question;
60
-
61
- if (this.progress >= 95) {
62
- await this.getWinner();
63
- }
64
- return this;
65
- } catch (e) {
66
- throw new Error("Lost connection to Akinator servers.");
67
- }
68
- }
69
-
70
- async getWinner() {
71
- const res = await axios.get(`${this.baseUrl}/list`, {
72
- params: { session: this.session, signature: this.signature, step: this.step },
73
- headers: this.headers
74
- });
75
- const elements = res.data.parameters.elements;
76
- if (elements && elements.length > 0) {
77
- this.isWin = true;
78
- const char = elements[0].element;
79
- this.sugestion_name = char.name;
80
- this.sugestion_desc = char.description;
81
- this.sugestion_photo = char.absolute_picture_path;
82
- }
83
- }
84
- }
85
-
86
- module.exports = { Akinator };