insta-checker-sdk 1.0.0 → 1.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 +116 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Insta Checker SDK
|
|
2
|
+
|
|
3
|
+
A Node.js and TypeScript library to check if an Instagram username is available. It handles connection pooling, caching, and retries so you don't have to write that boilerplate yourself.
|
|
4
|
+
|
|
5
|
+
This is useful for Discord bots, web apps, or scripts that need to check a lot of names quickly.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the package via npm:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install insta-checker-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
Here is the simplest way to check one username.
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
const InstaChecker = require('insta-checker-sdk');
|
|
21
|
+
|
|
22
|
+
const checker = new InstaChecker();
|
|
23
|
+
|
|
24
|
+
async function run() {
|
|
25
|
+
const result = await checker.checkUsername('ninja');
|
|
26
|
+
|
|
27
|
+
if (result.available) {
|
|
28
|
+
console.log('The username is free.');
|
|
29
|
+
} else {
|
|
30
|
+
console.log('The username is taken.');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
run();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
* **Connection Pooling**: Reuses HTTP connections to check names faster.
|
|
40
|
+
* **Caching**: Saves results in memory for a set time to avoid checking the same name twice.
|
|
41
|
+
* **Retries**: Automatically tries again if a request times out or fails.
|
|
42
|
+
* **Batch Checking**: Checks multiple names in parallel with a configurable limit.
|
|
43
|
+
* **TypeScript Support**: Included types for full IDE autocomplete.
|
|
44
|
+
|
|
45
|
+
## Basic Usage
|
|
46
|
+
|
|
47
|
+
### Checking a single username
|
|
48
|
+
|
|
49
|
+
The `checkUsername` method returns an object with two properties: `available` (boolean) and `cached` (boolean).
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
const InstaChecker = require('insta-checker-sdk');
|
|
53
|
+
const checker = new InstaChecker({ timeout: 3000 });
|
|
54
|
+
|
|
55
|
+
const result = await checker.checkUsername('apple');
|
|
56
|
+
|
|
57
|
+
console.log(result);
|
|
58
|
+
// Output: { available: false, cached: false }
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Checking multiple usernames
|
|
62
|
+
|
|
63
|
+
Use `checkBatch` to process a list of names. This runs checks in parallel based on your concurrency setting.
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
const usernames = ['john', 'jane', 'doe', 'admin'];
|
|
67
|
+
|
|
68
|
+
const results = await checker.checkBatch(usernames);
|
|
69
|
+
|
|
70
|
+
console.log(results);
|
|
71
|
+
// Output: { john: false, jane: true, doe: true, admin: false }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
You can add a callback to track progress while the batch is running.
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
await checker.checkBatch(usernames, {
|
|
78
|
+
onProgress: (info) => {
|
|
79
|
+
console.log(`Checked ${info.current} of ${info.total}`);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Configuration
|
|
85
|
+
|
|
86
|
+
You can pass an options object to the constructor.
|
|
87
|
+
|
|
88
|
+
| Option | Type | Default | Description |
|
|
89
|
+
| --- | --- | --- | --- |
|
|
90
|
+
| `timeout` | number | 5000 | Time to wait for a response in milliseconds. |
|
|
91
|
+
| `concurrency` | number | 5 | How many requests to send at the same time. |
|
|
92
|
+
| `retries` | number | 2 | How many times to retry a failed request. |
|
|
93
|
+
| `cacheTTL` | number | 300000 | How long to cache results in milliseconds (default 5 mins). |
|
|
94
|
+
| `enableCache` | boolean | true | Turn caching on or off. |
|
|
95
|
+
|
|
96
|
+
Example:
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
const checker = new InstaChecker({
|
|
100
|
+
concurrency: 10, // Check 10 names at once
|
|
101
|
+
timeout: 2000, // Fail fast after 2 seconds
|
|
102
|
+
cacheTTL: 60000 // Keep cache for 1 minute
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Clearing Cache
|
|
107
|
+
|
|
108
|
+
If you want to force a refresh of all names, clear the cache manually.
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
checker.clearCache();
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
MIT
|
package/package.json
CHANGED