Skip to content

Commit 1ae352e

Browse files
committed
New API Key tutorial section & Updated commit func & Prettier codes
1 parent fbe5e06 commit 1ae352e

File tree

1 file changed

+36
-25
lines changed

1 file changed

+36
-25
lines changed

README.md

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,35 @@
44
$ npm install @squarecloud/api
55
```
66

7+
# **Getting your API Key** | Adquirindo sua chave da API
8+
9+
The **first** thing you have to do is to get your API key.
10+
11+
1. Open the [**SquareCloud Dashboard**](https://squarecloud.app/dashboard/me).
12+
2. Login with your Discord account.
13+
3. Go to `My Account`.
14+
4. And finally click `Regenerate API/CLI Key`.
15+
16+
717
# **Setting Up** | Configurando
818

9-
First create an instance for the API:
19+
Creating an API instance:
1020

1121
```js
12-
const { SquareCloudAPI } = require('@squarecloud/api');
22+
import { SquareCloudAPI } from '@squarecloud/api' // JavaScript: const { SquareCloudAPI } = require('@squarecloud/api')
1323

14-
const api = new SquareCloudAPI('Your API Token');
24+
const api = new SquareCloudAPI('Your API Key')
1525
```
1626

17-
_Get your token at `My Account` in the [SquareCloud Dashboard](https://squarecloud.app/dashboard)._
18-
1927
## **Getting user's informations** | Adquirindo informações de usuários
2028

2129
```js
2230
// If the ID is not provided it will get your own informations
23-
const user = await api.getUser('User Discord ID');
31+
const user = await api.getUser('User Discord ID')
2432

2533
// To get private properties you have to check if you have access:
2634
if (user.hasAccess()) {
27-
console.log(user.applications);
35+
console.log(user.applications)
2836
}
2937
```
3038

@@ -35,82 +43,85 @@ There are two ways for getting applications.
3543
### **First**
3644

3745
```js
38-
const user = await api.getUser();
46+
const user = await api.getUser()
3947

4048
// Through the array from the user (Only available if you have access to it)
41-
const application = user.applications[0];
49+
const application = user.applications[0]
4250
```
4351

4452
### **Second**
4553

4654
```js
4755
// Using the Application ID
48-
const application = await api.getApplication('ID');
56+
const application = await api.getApplication('ID')
4957
```
5058

5159
## **Getting Applications Information** | Adquirindo info de aplicações
5260

5361
### **Status**
5462

5563
```js
56-
const application = await api.getApplication('ID');
64+
const application = await api.getApplication('ID')
5765

5866
// Returns a bunch of info about the current status of the app
59-
console.log(await application.getStatus());
67+
application.getStatus()
6068
```
6169

6270
### **Logs**
6371

6472
```js
65-
const application = await api.getApplication('ID');
73+
const application = await api.getApplication('ID')
6674

6775
// If `true` it will get the full logs url
6876
// If `false` or blank it will get only the recent logs string
69-
console.log(await application.getLogs(true));
77+
application.getLogs(true)
7078
```
7179

7280
## **Managing Applications** | Gerenciando aplicações
7381

7482
### **Start, Stop & Restart**
7583

7684
```js
77-
const application = await api.getApplication('ID');
85+
const application = await api.getApplication('ID')
7886

7987
// Every single method will return `true` if it is successfuly executed
8088

81-
await application.start();
89+
application.start()
8290

83-
await application.stop();
91+
application.stop()
8492

85-
await application.restart();
93+
application.restart()
8694
```
8795

8896
### **Backup**
8997

9098
```js
91-
const application = await api.getApplication('ID');
99+
const application = await api.getApplication('ID')
92100

93101
// Generates a backup and returns its download url
94-
console.log(await application.backup());
102+
application.backup()
95103
```
96104

97105
### **Delete**
98106

99107
```js
100-
const application = await api.getApplication('ID');
108+
const application = await api.getApplication('ID')
101109

102110
// Deletes your whole application
103-
console.log(await application.delete());
111+
application.delete()
104112
```
105113

106114
### **Commit**
107115

108116
```js
109-
import path from 'path'; // JavaScript: const path = require('path')
117+
import path from 'path' // JavaScript: const path = require('path')
110118

111-
const application = await api.getApplication('ID');
119+
const application = await api.getApplication('ID')
112120

113121
// Commits a file change to your application
114122
// You must use the absolute file path with the file extension
115-
console.log(await application.commit(path.join(__dirname, 'index.js')));
123+
application.commit(path.join(__dirname, 'index.js'))
124+
125+
// You can use Buffers too:
126+
application.commit(<Buffer>, 'index', '.js')
116127
```

0 commit comments

Comments
 (0)