Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

add usag examples for the links methods

Kiran K8234b226d6ed
diff --git a/apps/docs/mint.json b/apps/docs/mint.json
index 2a0cbe521a..71ce648450 100644
--- a/apps/docs/mint.json
+++ b/apps/docs/mint.json
@@ -136,7 +136,7 @@
"sdks/typescript/links/delete",
"sdks/typescript/links/list",
"sdks/typescript/links/count",
- "sdks/typescript/links/createMany"
+ "sdks/typescript/links/create-many"
]
},
{
diff --git a/apps/docs/sdks/typescript/links/count.mdx b/apps/docs/sdks/typescript/links/count.mdx
index 58599687d4..109230f8ef 100644
--- a/apps/docs/sdks/typescript/links/count.mdx
+++ b/apps/docs/sdks/typescript/links/count.mdx
@@ -3,3 +3,27 @@ title: "Count"
"og:title": "Retrieve the number of links - TypeScript SDK"
description: "Retrieve the number of links for the authenticated workspace. The provided query parameters allow filtering the returned links."
---
+
+<RequestExample>
+
+```ts
+// Count links by domain
+await dub.links.count({
+ domain: "dub.sh",
+});
+
+// Count links by tagIds
+await dub.links.count({
+ tagIds: ["clv3mewk30001mq0rxl3j3frn"],
+});
+```
+
+</RequestExample>
+
+<ResponseExample>
+
+```ts
+2
+```
+
+</ResponseExample>
diff --git a/apps/docs/sdks/typescript/links/create-many.mdx b/apps/docs/sdks/typescript/links/create-many.mdx
new file mode 100644
index 0000000000..d6c3ea8b2b
--- /dev/null
+++ b/apps/docs/sdks/typescript/links/create-many.mdx
@@ -0,0 +1,67 @@
+---
+title: "CreateMany"
+"og:title": "Bulk create links - TypeScript SDK"
+description: "Bulk create up to 100 links for the authenticated workspace."
+---
+
+<RequestExample>
+
+```ts
+await dub.links.createMany([
+ {
+ url: "https://www.google.com",
+ },
+ {
+ url: "https://github.com",
+ },
+]);
+```
+
+</RequestExample>
+
+<ResponseExample>
+
+```ts
+[
+ {
+ id: "clv3u86ej0008y9nm1f1yto2w",
+ domain: "dub.sh",
+ key: "FTC1AXj",
+ url: "https://www.google.com",
+ archived: false,
+ expiresAt: null,
+ expiredUrl: null,
+ password: null,
+ proxy: false,
+ title: null,
+ description: null,
+ image: null,
+ rewrite: false,
+ ios: null,
+ android: null,
+ geo: null,
+ ...
+ },
+ {
+ id: "clv3u86ej000ay9nm55qgbh5r",
+ domain: "dub.sh",
+ key: "B6qpMch",
+ url: "https://github.com",
+ archived: false,
+ expiresAt: null,
+ expiredUrl: null,
+ password: null,
+ proxy: false,
+ title: null,
+ description: null,
+ image: null,
+ rewrite: false,
+ ios: null,
+ android: null,
+ geo: null,
+ ...
+ },
+];
+```
+
+</ResponseExample>
diff --git a/apps/docs/sdks/typescript/links/createMany b/apps/docs/sdks/typescript/links/createMany
deleted file mode 100644
index 4f0d09d0ad..0000000000
--- a/apps/docs/sdks/typescript/links/createMany
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: "CreateMany"
-"og:title": "Bulk create links - TypeScript SDK"
-description: "Bulk create up to 100 links for the authenticated workspace."
----
diff --git a/apps/docs/sdks/typescript/links/delete.mdx b/apps/docs/sdks/typescript/links/delete.mdx
index 4b12d70c17..1bd95b6e45 100644
--- a/apps/docs/sdks/typescript/links/delete.mdx
+++ b/apps/docs/sdks/typescript/links/delete.mdx
@@ -3,3 +3,21 @@ title: "Delete"
"og:title": "Delete a link - TypeScript SDK"
description: "Delete a link for the authenticated workspace."
---
+
+<RequestExample>
+
+```ts
+await dub.links.delete("clv3o9p9q000au1h0mc7r6l63");
+```
+
+</RequestExample>
+
+<ResponseExample>
+
+```ts
+{
+ id: "clv3o9p9q000au1h0mc7r6l63";
+}
+```
+
+</ResponseExample>
diff --git a/apps/docs/sdks/typescript/links/list.mdx b/apps/docs/sdks/typescript/links/list.mdx
index 00d2356acb..e5741cb617 100644
--- a/apps/docs/sdks/typescript/links/list.mdx
+++ b/apps/docs/sdks/typescript/links/list.mdx
@@ -3,3 +3,64 @@ title: "List"
"og:title": "Retrieve a list of links - TypeScript SDK"
description: "Retrieve a list of links for the authenticated workspace. The list will be paginated and the provided query parameters allow filtering the returned links."
---
+
+<RequestExample>
+
+```ts
+// Find links by domain
+await dub.links.list({
+ domain: "dub.sh",
+});
+
+// Find links by tagIds
+await dub.links.list({
+ tagIds: ["clv3mewk30001mq0rxl3j3frn"],
+});
+```
+
+</RequestExample>
+
+<ResponseExample>
+
+```ts
+[
+ {
+ id: "clv3o9p9q000au1h0mc7r6l63",
+ domain: "dub.sh",
+ key: "e7qzMuI",
+ url: "https://www.google.com",
+ archived: false,
+ expiresAt: null,
+ expiredUrl: null,
+ password: null,
+ proxy: false,
+ title: null,
+ description: null,
+ image: null,
+ rewrite: false,
+ ios: null,
+ android: null,
+ geo: null,
+ publicStats: false,
+ tagId: null,
+ tags: [],
+ comments: null,
+ shortLink: "https://dub.sh/e7qzMuI",
+ qrCode: "https://api.dub.co/qr?url=https://dub.sh/e7qzMuI?qr=1",
+ utmSource: null,
+ utmMedium: null,
+ utmCampaign: null,
+ utmTerm: null,
+ utmContent: null,
+ userId: "cludszk1h0000wmd2e0ea2b0p",
+ workspaceId: "ws_clugls3tn000lwfotbpy30304",
+ clicks: 0,
+ lastClicked: null,
+ createdAt: "2024-04-17T10:31:00.398Z",
+ updatedAt: "2024-04-17T10:31:00.398Z",
+ projectId: "clugls3tn000lwfotbpy30304",
+ },
+];
+```
+
+</ResponseExample>
diff --git a/apps/docs/sdks/typescript/links/update.mdx b/apps/docs/sdks/typescript/links/update.mdx
index 33fc3bd907..eea8d35006 100644
--- a/apps/docs/sdks/typescript/links/update.mdx
+++ b/apps/docs/sdks/typescript/links/update.mdx
@@ -7,9 +7,8 @@ description: "Edit a link for the authenticated workspace."
<RequestExample>
```ts
-await dub.links.get({
- domain: "dub.sh",
- key: "e7qzMuI",
+await dub.links.update("clv3o9p9q000au1h0mc7r6l63", {
+ tagIds: ["clv3j1h7o00032u1ngo8luv84"],
});
```
@@ -36,8 +35,14 @@ await dub.links.get({
android: null,
geo: null,
publicStats: false,
- tagId: null,
- tags: [],
+ tagId: 'clv3j1h7o00032u1ngo8luv84',
+ tags: [
+ {
+ id: 'clv3j1h7o00032u1ngo8luv84',
+ name: 'news',
+ color: 'blue'
+ }
+ ],
comments: null,
shortLink: 'https://dub.sh/e7qzMuI',
qrCode: 'https://api.dub.co/qr?url=https://dub.sh/e7qzMuI?qr=1',