devworldbr-api 0.0.0-stage → 1.0.0
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 +7 -2
- package/config/config.json +6 -0
- package/index.js +45 -0
- package/package.json +19 -4
package/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# devworldbr-api 🚀
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SDK Oficial Node.js para integrar os serviços e ferramentas da **DevWorld BR APIs** na sua aplicação ou Bot de WhatsApp/Telegram.
|
|
4
|
+
|
|
5
|
+
## 📦 Instalação
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install devworldbr-api
|
package/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const axios = require('axios');
|
|
4
|
+
const config = JSON.parse(fs.readFileSync('./config/config.json', 'utf-8'));
|
|
5
|
+
|
|
6
|
+
class DevWorldBR {
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.baseURL = config.baseURL || 'https://api.devworldbr.site';
|
|
9
|
+
this.apiKey = options.apiKey;
|
|
10
|
+
|
|
11
|
+
if (!this.apiKey) {
|
|
12
|
+
throw new Error('[DevWorldBR] Você precisa fornecer uma chave de API (apiKey)!');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
this.client = axios.create({
|
|
16
|
+
baseURL: this.baseURL,
|
|
17
|
+
timeout: 60000
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async _get(endpoint, params = {}, responseType = 'json') {
|
|
22
|
+
try {
|
|
23
|
+
const response = await this.client.get(endpoint, {
|
|
24
|
+
params: { ...params, chave_key: this.apiKey },
|
|
25
|
+
responseType
|
|
26
|
+
});
|
|
27
|
+
return response.data;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
throw new Error(`[DevWorldBR Erro]: ${error.response?.data?.msg || error.message}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async playVideo(query) {
|
|
34
|
+
if (!query) throw new Error('O parâmetro "query" é obrigatório.');
|
|
35
|
+
return await this._get('/api/downloads/youtube/play/video/v1', { query }, 'arraybuffer');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async shazam(audioUrl) {
|
|
39
|
+
return await this._get('/api/ferramentas/shazam/v1', { url: audioUrl });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = DevWorldBR;
|
|
45
|
+
export default DevWorldBR;
|
package/package.json
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devworldbr-api",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SDK oficial para consumo rápido das APIs DevWorld BR",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"devworldbr",
|
|
11
|
+
"whatsapp-bot",
|
|
12
|
+
"baileys",
|
|
13
|
+
"api",
|
|
14
|
+
"youtube-downloader"
|
|
15
|
+
],
|
|
16
|
+
"author": "DevWorld BR",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"axios": "^1.6.0"
|
|
20
|
+
}
|
|
21
|
+
}
|