Skip to content

Latest commit

 

History

History
811 lines (608 loc) · 64.3 KB

File metadata and controls

811 lines (608 loc) · 64.3 KB

Links

Overview

Available Operations

list

Retrieve a paginated list of links for the authenticated workspace.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.links.list();

  for await (const page of result) {
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { linksList } from "dub/funcs/linksList.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await linksList(dub);
  if (res.ok) {
    const { value: result } = res;
    for await (const page of result) {
    console.log(page);
  }
  } else {
    console.log("linksList failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetLinksRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit 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.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GetLinksResponse>

Errors

Error Type 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 link for the authenticated workspace.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.links.create();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { linksCreate } from "dub/funcs/linksCreate.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await linksCreate(dub);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("linksCreate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CreateLinkRequestBody ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit 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.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.LinkSchema>

Errors

Error Type 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.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.links.count();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { linksCount } from "dub/funcs/linksCount.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await linksCount(dub);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("linksCount failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetLinksCountRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit 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.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<number>

Errors

Error Type 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

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.links.get();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { linksGet } from "dub/funcs/linksGet.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await linksGet(dub);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("linksGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetLinkInfoRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit 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.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.LinkSchema>

Errors

Error Type 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

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.links.delete("<id>");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { linksDelete } from "dub/funcs/linksDelete.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await linksDelete(dub, "<id>");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("linksDelete failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
linkId string ✔️ The id of the link to delete. You may use either linkId (obtained via /links/info endpoint) or externalId prefixed with ext_.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit 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.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.DeleteLinkResponseBody>

Errors

Error Type 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

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.links.update("<id>");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { linksUpdate } from "dub/funcs/linksUpdate.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await linksUpdate(dub, "<id>");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("linksUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
linkId string ✔️ 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 N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit 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.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.LinkSchema>

Errors

Error Type 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

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.links.createMany();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { linksCreateMany } from "dub/funcs/linksCreateMany.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await linksCreateMany(dub);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("linksCreateMany failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.RequestBody[] ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit 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.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ResponseBody[]>

Errors

Error Type 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 */*

deleteMany

Bulk delete up to 100 links for the authenticated workspace.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.links.deleteMany({
    linkIds: [
      "clux0rgak00011...",
      "clux0rgak00022...",
    ],
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { linksDeleteMany } from "dub/funcs/linksDeleteMany.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await linksDeleteMany(dub, {
    linkIds: [
      "clux0rgak00011...",
      "clux0rgak00022...",
    ],
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("linksDeleteMany failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.BulkDeleteLinksRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit 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.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.BulkDeleteLinksResponseBody>

Errors

Error Type 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 */*

updateMany

Bulk update up to 100 links with the same data for the authenticated workspace.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.links.updateMany();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { linksUpdateMany } from "dub/funcs/linksUpdateMany.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await linksUpdateMany(dub);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("linksUpdateMany failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.BulkUpdateLinksRequestBody ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit 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.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.LinkSchema[]>

Errors

Error Type 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

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.links.upsert();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { linksUpsert } from "dub/funcs/linksUpsert.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await linksUpsert(dub);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("linksUpsert failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.UpsertLinkRequestBody ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit 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.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.LinkSchema>

Errors

Error Type 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 */*