mirror of
https://github.com/LukeHagar/dub-node.git
synced 2025-12-06 04:19:37 +00:00
425 lines
41 KiB
Markdown
425 lines
41 KiB
Markdown
# Links
|
|
(*links*)
|
|
|
|
### Available Operations
|
|
|
|
* [list](#list) - Retrieve a list of links
|
|
* [create](#create) - Create a new link
|
|
* [count](#count) - Retrieve the number of links
|
|
* [get](#get) - Retrieve a link
|
|
* [delete](#delete) - Delete a link
|
|
* [update](#update) - Update a link
|
|
* [createMany](#createmany) - Bulk create links
|
|
* [upsert](#upsert) - Upsert a link
|
|
|
|
## list
|
|
|
|
Retrieve a list of links for the authenticated workspace. The list will be paginated and the provided query parameters allow filtering the returned links.
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { Dub } from "dub";
|
|
|
|
const dub = new Dub({
|
|
token: "DUB_API_KEY",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await dub.links.list({});
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `request` | [operations.GetLinksRequest](../../models/operations/getlinksrequest.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
|
|
|
|
### Response
|
|
|
|
**Promise\<[components.LinkSchema[]](../../models/.md)\>**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------- | -------------------------- | -------------------------- |
|
|
| errors.BadRequest | 400 | application/json |
|
|
| errors.Unauthorized | 401 | application/json |
|
|
| errors.Forbidden | 403 | application/json |
|
|
| errors.NotFound | 404 | application/json |
|
|
| errors.Conflict | 409 | application/json |
|
|
| errors.InviteExpired | 410 | application/json |
|
|
| errors.UnprocessableEntity | 422 | application/json |
|
|
| errors.RateLimitExceeded | 429 | application/json |
|
|
| errors.InternalServerError | 500 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
## create
|
|
|
|
Create a new link for the authenticated workspace.
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { Dub } from "dub";
|
|
|
|
const dub = new Dub({
|
|
token: "DUB_API_KEY",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await dub.links.create({
|
|
url: "https://google/com",
|
|
});
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `request` | [operations.CreateLinkRequestBody](../../models/operations/createlinkrequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
|
|
|
|
### Response
|
|
|
|
**Promise\<[components.LinkSchema](../../models/components/linkschema.md)\>**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------- | -------------------------- | -------------------------- |
|
|
| errors.BadRequest | 400 | application/json |
|
|
| errors.Unauthorized | 401 | application/json |
|
|
| errors.Forbidden | 403 | application/json |
|
|
| errors.NotFound | 404 | application/json |
|
|
| errors.Conflict | 409 | application/json |
|
|
| errors.InviteExpired | 410 | application/json |
|
|
| errors.UnprocessableEntity | 422 | application/json |
|
|
| errors.RateLimitExceeded | 429 | application/json |
|
|
| errors.InternalServerError | 500 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
## count
|
|
|
|
Retrieve the number of links for the authenticated workspace. The provided query parameters allow filtering the returned links.
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { Dub } from "dub";
|
|
|
|
const dub = new Dub({
|
|
token: "DUB_API_KEY",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await dub.links.count({});
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `request` | [operations.GetLinksCountRequest](../../models/operations/getlinkscountrequest.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
|
|
|
|
### Response
|
|
|
|
**Promise\<[number](../../models/.md)\>**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------- | -------------------------- | -------------------------- |
|
|
| errors.BadRequest | 400 | application/json |
|
|
| errors.Unauthorized | 401 | application/json |
|
|
| errors.Forbidden | 403 | application/json |
|
|
| errors.NotFound | 404 | application/json |
|
|
| errors.Conflict | 409 | application/json |
|
|
| errors.InviteExpired | 410 | application/json |
|
|
| errors.UnprocessableEntity | 422 | application/json |
|
|
| errors.RateLimitExceeded | 429 | application/json |
|
|
| errors.InternalServerError | 500 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
## get
|
|
|
|
Retrieve the info for a link.
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { Dub } from "dub";
|
|
|
|
const dub = new Dub({
|
|
token: "DUB_API_KEY",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await dub.links.get({});
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `request` | [operations.GetLinkInfoRequest](../../models/operations/getlinkinforequest.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
|
|
|
|
### Response
|
|
|
|
**Promise\<[components.LinkSchema](../../models/components/linkschema.md)\>**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------- | -------------------------- | -------------------------- |
|
|
| errors.BadRequest | 400 | application/json |
|
|
| errors.Unauthorized | 401 | application/json |
|
|
| errors.Forbidden | 403 | application/json |
|
|
| errors.NotFound | 404 | application/json |
|
|
| errors.Conflict | 409 | application/json |
|
|
| errors.InviteExpired | 410 | application/json |
|
|
| errors.UnprocessableEntity | 422 | application/json |
|
|
| errors.RateLimitExceeded | 429 | application/json |
|
|
| errors.InternalServerError | 500 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
## delete
|
|
|
|
Delete a link for the authenticated workspace.
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { Dub } from "dub";
|
|
|
|
const dub = new Dub({
|
|
token: "DUB_API_KEY",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await dub.links.delete("<value>");
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `linkId` | *string* | :heavy_check_mark: | The id of the link to delete. You may use either `linkId` (obtained via `/links/info` endpoint) or `externalId` prefixed with `ext_`. |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
|
|
|
|
### Response
|
|
|
|
**Promise\<[operations.DeleteLinkResponseBody](../../models/operations/deletelinkresponsebody.md)\>**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------- | -------------------------- | -------------------------- |
|
|
| errors.BadRequest | 400 | application/json |
|
|
| errors.Unauthorized | 401 | application/json |
|
|
| errors.Forbidden | 403 | application/json |
|
|
| errors.NotFound | 404 | application/json |
|
|
| errors.Conflict | 409 | application/json |
|
|
| errors.InviteExpired | 410 | application/json |
|
|
| errors.UnprocessableEntity | 422 | application/json |
|
|
| errors.RateLimitExceeded | 429 | application/json |
|
|
| errors.InternalServerError | 500 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
## update
|
|
|
|
Update a link for the authenticated workspace. If there's no change, returns it as it is.
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { Dub } from "dub";
|
|
|
|
const dub = new Dub({
|
|
token: "DUB_API_KEY",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await dub.links.update("<value>", {
|
|
url: "https://google/com",
|
|
});
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `linkId` | *string* | :heavy_check_mark: | The id of the link to update. You may use either `linkId` (obtained via `/links/info` endpoint) or `externalId` prefixed with `ext_`. |
|
|
| `requestBody` | [operations.UpdateLinkRequestBody](../../models/operations/updatelinkrequestbody.md) | :heavy_minus_sign: | N/A |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
|
|
|
|
### Response
|
|
|
|
**Promise\<[components.LinkSchema](../../models/components/linkschema.md)\>**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------- | -------------------------- | -------------------------- |
|
|
| errors.BadRequest | 400 | application/json |
|
|
| errors.Unauthorized | 401 | application/json |
|
|
| errors.Forbidden | 403 | application/json |
|
|
| errors.NotFound | 404 | application/json |
|
|
| errors.Conflict | 409 | application/json |
|
|
| errors.InviteExpired | 410 | application/json |
|
|
| errors.UnprocessableEntity | 422 | application/json |
|
|
| errors.RateLimitExceeded | 429 | application/json |
|
|
| errors.InternalServerError | 500 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
## createMany
|
|
|
|
Bulk create up to 100 links for the authenticated workspace.
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { Dub } from "dub";
|
|
|
|
const dub = new Dub({
|
|
token: "DUB_API_KEY",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await dub.links.createMany([
|
|
{
|
|
url: "https://google/com",
|
|
},
|
|
]);
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `request` | [operations.RequestBody[]](../../models/.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
|
|
|
|
### Response
|
|
|
|
**Promise\<[components.LinkSchema[]](../../models/.md)\>**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------- | -------------------------- | -------------------------- |
|
|
| errors.BadRequest | 400 | application/json |
|
|
| errors.Unauthorized | 401 | application/json |
|
|
| errors.Forbidden | 403 | application/json |
|
|
| errors.NotFound | 404 | application/json |
|
|
| errors.Conflict | 409 | application/json |
|
|
| errors.InviteExpired | 410 | application/json |
|
|
| errors.UnprocessableEntity | 422 | application/json |
|
|
| errors.RateLimitExceeded | 429 | application/json |
|
|
| errors.InternalServerError | 500 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
## upsert
|
|
|
|
Upsert a link for the authenticated workspace by its URL. If a link with the same URL already exists, return it (or update it if there are any changes). Otherwise, a new link will be created.
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { Dub } from "dub";
|
|
|
|
const dub = new Dub({
|
|
token: "DUB_API_KEY",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await dub.links.upsert({
|
|
url: "https://google/com",
|
|
});
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `request` | [operations.UpsertLinkRequestBody](../../models/operations/upsertlinkrequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
|
|
|
|
### Response
|
|
|
|
**Promise\<[components.LinkSchema](../../models/components/linkschema.md)\>**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------- | -------------------------- | -------------------------- |
|
|
| errors.BadRequest | 400 | application/json |
|
|
| errors.Unauthorized | 401 | application/json |
|
|
| errors.Forbidden | 403 | application/json |
|
|
| errors.NotFound | 404 | application/json |
|
|
| errors.Conflict | 409 | application/json |
|
|
| errors.InviteExpired | 410 | application/json |
|
|
| errors.UnprocessableEntity | 422 | application/json |
|
|
| errors.RateLimitExceeded | 429 | application/json |
|
|
| errors.InternalServerError | 500 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|