The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add go docs
Kiran Kdc65ae51e7f1
diff --git a/apps/docs/quickstart/express.mdx b/apps/docs/quickstart/express.mdxindex e041b266e4..496e457677 100644--- a/apps/docs/quickstart/express.mdx+++ b/apps/docs/quickstart/express.mdx@@ -16,7 +16,7 @@ import Install from "/snippets/sdk-install-nodejs.mdx";Create a dub instance using the Dub Node.js SDK.-```typescript+```typescript dub.tsimport { Dub } from "dub";export const dub = new Dub({@@ -29,7 +29,10 @@ export const dub = new Dub({Let's create a short link using the Dub Node.js SDK.-```typescript create-link.ts+```typescript index.ts+import express, { Request, Response } from "express";+import { dub } from "./dub";+app.get("/create-link", async (req: Request, res: Response) => {try {const result = await dub.links.create({@@ -47,7 +50,7 @@ app.get("/create-link", async (req: Request, res: Response) => {Dub Node.js SDK provides a method to create or update a link so you don't have to worry about checking if the link already exists.-```typescript upsert-link.ts+```typescript index.tsapp.get("/upsert-link", async (req: Request, res: Response) => {try {// Update the link if same URL already exists or create a new link@@ -67,10 +70,10 @@ app.get("/upsert-link", async (req: Request, res: Response) => {Let's update an existing link using the Dub Node.js SDK.-```typescript update-link.ts+```typescript index.tsapp.get("/update-link", async (req: Request, res: Response) => {try {- const result = await dub.links.create({+ const result = await dub.links.update("LINK_ID OR EXTERNAL_ID", {url: "https://www.google.us",});@@ -81,19 +84,16 @@ app.get("/update-link", async (req: Request, res: Response) => {});```-Both `upsert` and `update` methods accept the same parameters.-## 6. Retrieve analytics for linkDub allows you to retrieve analytics for a link using the Dub Node.js SDK.-```typescript get-analytics.ts+```typescript index.tsapp.get("/analytics", async (req: Request, res: Response) => {try {- // Retrieve the timeseries analytics for the last 7 days for the link with the key "dummy"+ // Retrieve the timeseries analytics for the last 7 days for a linkconst result = await dub.analytics.retrieve({- key: "dummy",- domain: "dub.sh",+ linkId: "LINK_ID",interval: "7d",event: "clicks",groupBy: "timeseries",@@ -112,7 +112,7 @@ app.get("/analytics", async (req: Request, res: Response) => {<Cardtitle="Express Example"icon="arrow-up-right-from-square"- href="https://github.com/dubinc/examples"+ href="https://github.com/dubinc/examples/tree/main/node/express">See the full example on GitHub.</Card>diff --git a/apps/docs/quickstart/go.mdx b/apps/docs/quickstart/go.mdxindex e9bc04212c..546b8b7f20 100644--- a/apps/docs/quickstart/go.mdx+++ b/apps/docs/quickstart/go.mdx@@ -5,7 +5,6 @@ description: "Learn how to create a short link using the Dub Go SDK."import Prerequisites from "/snippets/sdk-prerequisites.mdx";-## 1. Prerequisites<Prerequisites />@@ -20,20 +19,114 @@ go get github.com/dubinc/dub-go## 3. Create link+Let's create a short link using the Dub Go SDK.++```go main.go+package main++import (+ "log"+ "os"++ dub "github.com/dubinc/dub-go"+)++func main() {+ d := dub.New(+ dub.WithSecurity(os.Getenv("DUB_API_KEY")),+ dub.WithWorkspaceID(os.Getenv("DUB_WORKSPACE_ID")),+ )++ request := &operations.CreateLinkRequestBody{+ URL: "https://google.com",+ }++ ctx := context.Background()+ res, err := d.Links.Create(ctx, request)+ if err != nil {+ log.Fatal(err)+ }+ if res.LinkSchema != nil {+ fmt.Println(res.LinkSchema.ShortLink)+ }+}+```+## 4. Upsert link+Dub Go SDK provides a method to create or update a link so you don't have to worry about checking if the link already exists.++```go main.go+func main() {+ d := dub.New(+ dub.WithSecurity(os.Getenv("DUB_API_KEY")),+ dub.WithWorkspaceID(os.Getenv("DUB_WORKSPACE_ID")),+ )++ request := &operations.UpsertLinkRequestBody{+ URL: "https://google.com",+ }++ ctx := context.Background()+ res, err := d.Links.Upsert(ctx, request)+ if err != nil {+ log.Fatal(err)+ }+ if res.LinkSchema != nil {+ fmt.Println(res.LinkSchema.ShortLink)+ }+}+```+## 5. Update link+Let's update an existing link using the Dub Go SDK.++```go main.go+func main() {+ d := dub.New(+ dub.WithSecurity(os.Getenv("DUB_API_KEY")),+ dub.WithWorkspaceID(os.Getenv("DUB_WORKSPACE_ID")),+ )++ request := &operations.UpdateLinkRequestBody{+ URL: "https://google.us",+ }++ ctx := context.Background()+ res, err := d.Links.Update(ctx, "LINK_ID", request)+ if err != nil {+ log.Fatal(err)+ }+ if res.LinkSchema != nil {+ fmt.Println(res.LinkSchema.ShortLink)+ }+}+```+## 6. Retrieve analytics for link+Let's retrieve analytics for a link using the Dub Go SDK.++```go main.go+func main() {+ d := dub.New(+ dub.WithSecurity(os.Getenv("DUB_API_KEY")),+ dub.WithWorkspaceID(os.Getenv("DUB_WORKSPACE_ID")),+ )++ // Retrieve the timeseries analytics for the last 7 days for a link+}+```+## 7. Examples<CardGroup cols={2}><Cardtitle="Go Example"icon="arrow-up-right-from-square"- href="https://github.com/dubinc/examples"+ href="https://github.com/dubinc/examples/tree/main/go">See the full example on GitHub.</Card>-</CardGroup>\ No newline at end of file+</CardGroup>diff --git a/apps/docs/quickstart/nextjs.mdx b/apps/docs/quickstart/nextjs.mdxindex c5b1495025..f3ff4245ee 100644--- a/apps/docs/quickstart/nextjs.mdx+++ b/apps/docs/quickstart/nextjs.mdx@@ -76,8 +76,6 @@ export async function PATCH() {}```-Both `upsert` and `update` methods accept the same parameters.-## 6. Retrieve analytics for linkDub allows you to retrieve analytics for a link using the Dub Node.js SDK.diff --git a/apps/docs/quickstart/nodejs.mdx b/apps/docs/quickstart/nodejs.mdxindex 50a0f7f8f9..8b890ec559 100644--- a/apps/docs/quickstart/nodejs.mdx+++ b/apps/docs/quickstart/nodejs.mdx@@ -61,8 +61,6 @@ await dub.links.update("ext_123", {});```-Both `upsert` and `update` methods accept the same parameters.-## 6. Retrieve analytics for linkDub allows you to retrieve analytics for a link using the Dub Node.js SDK.diff --git a/apps/docs/quickstart/nuxt.mdx b/apps/docs/quickstart/nuxt.mdxindex 49d11d87e3..7a913b997f 100644--- a/apps/docs/quickstart/nuxt.mdx+++ b/apps/docs/quickstart/nuxt.mdx@@ -38,8 +38,6 @@ Let's update an existing link using the Dub Node.js SDK.```-Both `upsert` and `update` methods accept the same parameters.-## 6. Retrieve analytics for linkDub allows you to retrieve analytics for a link using the Dub Node.js SDK.diff --git a/apps/docs/quickstart/remix.mdx b/apps/docs/quickstart/remix.mdxindex c3927e2183..214b6373e7 100644--- a/apps/docs/quickstart/remix.mdx+++ b/apps/docs/quickstart/remix.mdx@@ -14,38 +14,108 @@ import Install from "/snippets/sdk-install-nodejs.mdx";<Install />+Create a dub instance using the Dub Node.js SDK.++```typescript dub.ts+import { Dub } from "dub";++export const dub = new Dub({+ token: process.env.DUB_API_KEY,+ workspaceId: process.env.DUB_WORKSPACE_ID,+});+```+## 3. Create linkLet's create a short link using the Dub Node.js SDK.-```typescript create-link.ts-+```typescript app/routes/create-link.ts+import { json } from "@remix-run/node";+import { dub } from "~/dub";++export const loader = async () => {+ try {+ const result = await dub.links.create({+ url: "https://www.google.com",+ });++ return json(result, 200);+ } catch (error: any) {+ console.error(error);+ return json(error, 400);+ }+};```## 4. Upsert linkDub Node.js SDK provides a method to create or update a link so you don't have to worry about checking if the link already exists.-```typescript upsert-link.ts-+```typescript app/routes/upsert-link.ts+import { json } from "@remix-run/node";+import { dub } from "~/dub";++export const loader = async () => {+ try {+ const result = await dub.links.upsert({+ url: "https://www.google.com",+ externalId: "my-link-id",+ });++ return json(result, 200);+ } catch (error: any) {+ console.error(error);+ return json(error, 400);+ }+};```## 5. Update linkLet's update an existing link using the Dub Node.js SDK.-```typescript update-link.ts-+```typescript app/routes/update-link.ts+import { json } from "@remix-run/node";+import { dub } from "~/dub";++export const loader = async () => {+ try {+ const result = await dub.links.update("LINK_ID", {+ url: "https://www.google.us",+ });++ return json(result, 200);+ } catch (error: any) {+ console.error(error);+ return json(error, 400);+ }+};```-Both `upsert` and `update` methods accept the same parameters.-## 6. Retrieve analytics for linkDub allows you to retrieve analytics for a link using the Dub Node.js SDK.-```typescript get-analytics.ts-+```typescript app/routes/analytics.ts+import { json } from "@remix-run/node";+import { dub } from "~/dub";++export const loader = async () => {+ try {+ // Retrieve the timeseries analytics for the last 7 days for a link+ const result = await dub.analytics.retrieve({+ linkId: "LINK_ID",+ interval: "7d",+ event: "clicks",+ groupBy: "timeseries",+ });++ return json(result, 200);+ } catch (error: any) {+ console.error(error);+ return json(error, 400);+ }+};```## 7. Examples@@ -54,7 +124,7 @@ Dub allows you to retrieve analytics for a link using the Dub Node.js SDK.<Cardtitle="Remix Example"icon="arrow-up-right-from-square"- href="https://github.com/dubinc/examples"+ href="https://github.com/dubinc/examples/tree/main/node/remix">See the full example on GitHub.</Card>