@short.io/client-node 1.1.0 → 2.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 +29 -39
- package/package.json +21 -11
- package/src/index.ts +3 -830
- package/src/sdk.gen.ts +688 -0
- package/src/types.gen.ts +4560 -0
- package/tsconfig.json +4 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -3
- package/dist/index.d.ts +0 -54
- package/dist/index.js +0 -438
- package/dist/index.js.map +0 -1
- package/dist/types/common.d.ts +0 -9
- package/dist/types/common.js +0 -2
- package/dist/types/common.js.map +0 -1
- package/dist/types/domain.d.ts +0 -43
- package/dist/types/domain.js +0 -2
- package/dist/types/domain.js.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.js +0 -5
- package/dist/types/index.js.map +0 -1
- package/dist/types/link.d.ts +0 -131
- package/dist/types/link.js +0 -2
- package/dist/types/link.js.map +0 -1
- package/dist/types/statistics.d.ts +0 -199
- package/dist/types/statistics.js +0 -2
- package/dist/types/statistics.js.map +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/src/types/common.ts +0 -11
- package/src/types/domain.ts +0 -44
- package/src/types/index.ts +0 -4
- package/src/types/link.ts +0 -159
- package/src/types/statistics.ts +0 -242
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Short.io Node.js SDK
|
|
2
2
|
|
|
3
3
|
The Short.io Node.js official SDK client is a library that allows you to integrate [short.io](https://short.io) URL shortening and link management API with your Node.js application in an easy and elegant way.
|
|
4
|
+
This SDK contains methods for working with links and domains.
|
|
4
5
|
|
|
5
6
|
## API reference
|
|
6
7
|
|
|
@@ -8,7 +9,7 @@ See the [API docs](https://developers.short.io/reference) for more information.
|
|
|
8
9
|
|
|
9
10
|
## Installing
|
|
10
11
|
|
|
11
|
-
To install
|
|
12
|
+
To install the SDK, run:
|
|
12
13
|
|
|
13
14
|
```sh
|
|
14
15
|
npm i @short.io/client-node
|
|
@@ -17,59 +18,48 @@ npm i @short.io/client-node
|
|
|
17
18
|
## Getting Started
|
|
18
19
|
|
|
19
20
|
First you need to get your API key from the Short.io dashboard in the [Integrations & API](https://app.short.io/settings/integrations/api-key) section.
|
|
20
|
-
|
|
21
|
+
Then you need to set the configuration for the client:
|
|
21
22
|
|
|
22
23
|
```js
|
|
23
|
-
import {
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Usage
|
|
27
|
-
|
|
28
|
-
Then create an instance of the Shortio class, and pass your API key as the first parameter:
|
|
24
|
+
import { client } from "@short.io/client-node";
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
client.setConfig({
|
|
27
|
+
baseUrl: "https://api.short.io",
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: "YOUR_API_KEY",
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```js
|
|
37
|
-
const domains = await shortio.domain.list();
|
|
38
|
-
```
|
|
34
|
+
## Usage
|
|
39
35
|
|
|
40
|
-
|
|
36
|
+
Import the needed methods from the SDK and use them in your code:
|
|
41
37
|
|
|
42
38
|
```js
|
|
43
|
-
|
|
39
|
+
import {
|
|
40
|
+
client,
|
|
41
|
+
getApiDomains,
|
|
42
|
+
getLinksExpand,
|
|
43
|
+
// and other needed methods
|
|
44
|
+
} from "@short.io/client-node";
|
|
44
45
|
```
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
Pass created client to the methods:
|
|
47
48
|
|
|
48
49
|
```js
|
|
49
|
-
const
|
|
50
|
+
const domainsResp = await getApiDomains({ client });
|
|
50
51
|
```
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
`domainsResp.data` will contain the list of domains.
|
|
53
54
|
|
|
54
55
|
```js
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
const linkResp = await getLinksExpand({
|
|
57
|
+
client,
|
|
58
|
+
query: {
|
|
59
|
+
domain: "your_domain.com",
|
|
60
|
+
path: "lnk_abc123_abcde12345,
|
|
61
|
+
},
|
|
59
62
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const publicLink = await shortio.link.createPublic({
|
|
63
|
-
domain: "link.example.com",
|
|
64
|
-
originalURL: "https://example.com",
|
|
65
|
-
publicAPIKey: "PUBLIC_API_KEY",
|
|
66
|
-
});
|
|
67
|
-
console.log(publicLink.shortURL); // https://link.example.com/a83t48
|
|
63
|
+
```
|
|
68
64
|
|
|
69
|
-
|
|
70
|
-
domain: "link.example.com",
|
|
71
|
-
publicAPIKey: "PUBLIC_API_KEY",
|
|
72
|
-
originalURL: "https://example.com",
|
|
73
|
-
});
|
|
74
|
-
console.log(secureLink.shortURL); // https://link.example.com/a83t48#ta95me8
|
|
75
|
-
```
|
|
65
|
+
`linkResp.data` will contain the expanded link.
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@short.io/client-node",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"prepare": "npm run compile"
|
|
13
|
-
"prepublishOnly": "npm run format"
|
|
10
|
+
"generate": "node --experimental-strip-types openapi/fetch.ts && openapi-ts -f openapi/config.ts",
|
|
11
|
+
"compile": "tsc && tsc-alias",
|
|
12
|
+
"prepare": "npm run compile"
|
|
14
13
|
},
|
|
15
14
|
"repository": {
|
|
16
15
|
"type": "git",
|
|
@@ -18,7 +17,10 @@
|
|
|
18
17
|
},
|
|
19
18
|
"keywords": [
|
|
20
19
|
"short.io",
|
|
21
|
-
"api"
|
|
20
|
+
"api",
|
|
21
|
+
"client",
|
|
22
|
+
"node",
|
|
23
|
+
"sdk"
|
|
22
24
|
],
|
|
23
25
|
"author": "",
|
|
24
26
|
"license": "ISC",
|
|
@@ -28,9 +30,17 @@
|
|
|
28
30
|
"homepage": "https://github.com/Short-io/client-node#readme",
|
|
29
31
|
"prettier": "@short.io/eslint-config/prettier",
|
|
30
32
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
33
|
+
"@eslint/js": "^9.16.0",
|
|
34
|
+
"@hey-api/openapi-ts": "^0.58.0",
|
|
35
|
+
"@types/node": "^22.10.1",
|
|
36
|
+
"eslint": "^9.16.0",
|
|
37
|
+
"globals": "^15.13.0",
|
|
38
|
+
"tsc-alias": "^1.8.10",
|
|
39
|
+
"typescript": "^5.7.2",
|
|
40
|
+
"typescript-eslint": "^8.17.0"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@hey-api/client-fetch": "^0.5.0"
|
|
44
|
+
},
|
|
45
|
+
"packageManager": "yarn@1.22.22+sha256.c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca"
|
|
36
46
|
}
|