Files
dub-node/docs/sdks/links
2024-04-19 11:28:50 +05:30
..

Links

(links)

Available Operations

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

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
  workspaceId: "<value>",
});

async function run() {
  const result = await dub.links.list({
  tagIds:     [
        "<value>",
      ],
  });

  // Handle the result
  console.log(result)
}

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.

Response

Promise<operations.GetLinksResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

create

Create a new link for the authenticated workspace.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
  workspaceId: "<value>",
});

async function run() {
  const result = await dub.links.create({
    url: "https://google/com",
  tagIds:     [
        "clux0rgak00011...",
      ],
    geo: {},
  });

  // Handle the result
  console.log(result)
}

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.

Response

Promise<operations.CreateLinkResponse>

Errors

Error Object Status Code Content Type
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

import { Dub } from "dub";
import { One } from "dub/models/operations";

const dub = new Dub({
  token: "DUB_API_KEY",
  workspaceId: "<value>",
});

async function run() {
  const result = await dub.links.count({
  tagIds: "<value>",
  groupBy: One.Domain,
  });

  // Handle the result
  console.log(result)
}

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.

Response

Promise<operations.GetLinksCountResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

get

Retrieve the info for a link from their domain and key.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
  workspaceId: "<value>",
});

async function run() {
  const result = await dub.links.get({
    domain: "ringed-blow.name",
    key: "<key>",
  });

  // Handle the result
  console.log(result)
}

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.

Response

Promise<operations.GetLinkInfoResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

update

Edit a link for the authenticated workspace.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
  workspaceId: "<value>",
});

async function run() {
  const linkId = "<value>";
  const requestBody = {
    url: "https://google/com",
  tagIds:     [
        "clux0rgak00011...",
      ],
    geo: {},
  };
  
  const result = await dub.links.update(linkId, requestBody);

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
linkId string ✔️ The id of the link to edit. You can get this via the getLinkInfo endpoint.
requestBody operations.EditLinkRequestBody 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.

Response

Promise<operations.EditLinkResponse>

Errors

Error Object Status Code Content Type
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",
  workspaceId: "<value>",
});

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

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
linkId string ✔️ The id of the link to delete. You can get this via the getLinkInfo endpoint.
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.

Response

Promise<operations.DeleteLinkResponse>

Errors

Error Object Status Code Content Type
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",
  workspaceId: "<value>",
});

async function run() {
  const result = await dub.links.createMany([
    {
      url: "https://google/com",
    tagIds:     [
          "clux0rgak00011...",
        ],
      geo: {},
    },
  ]);

  // Handle the result
  console.log(result)
}

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.

Response

Promise<operations.BulkCreateLinksResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /