Skip to content

Commit 1af26ab

Browse files
committed
Update README.md
1 parent f7e7c92 commit 1af26ab

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ Cat as a service API wrapper for Javascript and Typescript.
44

55
> Cat as a service is a REST API to spread peace and love (or not) thanks to cats.
66
7+
## Install
8+
9+
`npm install --save cataas-api`
10+
711
## Examples
812

913
`constructor()`
1014

1115
```JS
16+
var Cataas = require('cataas-api')
17+
var cataas = new Cataas()
1218
var gif = {
1319
Gif: true,
1420
Size: 'md',
@@ -21,28 +27,25 @@ var resized = {
2127
Width: 300,
2228
Height: 200,
2329
}
24-
var cataas = new Cataas(gif)
30+
cataas.options = gif
2531
cataas.options = resized
2632
```
2733

2834
`encode()`
2935

3036
```JS
31-
var cataas = new Cataas()
3237
var encodedUrl = cataas.encode()
3338
```
3439

3540
`encodeById(id)`
3641

3742
```JS
38-
var cataas = new Cataas()
3943
var encodedUrl = cataas.encodeById('[ID]')
4044
```
4145

4246
`async get()`
4347

4448
```JS
45-
var cataas = new Cataas()
4649
cataas.encode()
4750
cataas.get()
4851
.then(readable => {
@@ -55,7 +58,6 @@ cataas.get()
5558
`async download(path)`
5659

5760
```JS
58-
var cataas = new Cataas()
5961
cataas.encode()
6062
cataas.download('cat.png')
6163
.then(successful => {
@@ -69,7 +71,6 @@ cataas.download('cat.png')
6971
`async getAllTags()`
7072

7173
```JS
72-
const cataas = new Cataas()
7374
cataas.encode()
7475
cataas.getAllTags()
7576
.then(tags => {
@@ -81,14 +82,30 @@ cataas.getAllTags()
8182
`async getCats(tags, options)`
8283

8384
```JS
84-
var cataas = new Cataas()
8585
cataas.encode()
8686
cataas.getCats(['cute'])
8787
.then(cats => console.log('Results length:', cats.length))
8888
.catch(e => console.error(e))
8989
```
9090

91-
#### Tips:
91+
### Typescript example
92+
93+
```TS
94+
import Cataas from 'cataas-api';
95+
96+
const cataas = new Cataas()
97+
cataas.options.Filter = "pixel"
98+
cataas.encode()
99+
cataas.getCats(['cute'], { Limit: 5 })
100+
.then(cats => {
101+
cats.forEach(cat => {
102+
console.log(`${cat.id}: ${cat.tags}`))
103+
}
104+
})
105+
.catch(e => console.error(e))
106+
```
107+
108+
#### Tips
92109
93110
+ After setting `Gif: true` in options, `Tag` is ignored
94111
+ Don't forget to `encode()` | `encodeById` before `get()` | `download()`

0 commit comments

Comments
 (0)