1. Prerequisites
To follow this guide, you will need to:2. Install and initialize the Pearset TypeScript SDK
Install
Install the Pearset TypeScript SDK using your preferred package manager:
- npm
- yarn
- pnpm
3. Create link
Let’s create a short link using the Pearset TypeScript SDK.server/api/links.post.ts
externalId field which is a unique identifier for the link in your own database to associate it with the link in Pearset’s system.
server/api/links.post.ts
externalId instead of the Pearset linkId.
4. Upsert link
Pearset TypeScript SDK provides a method to upsert a link – where an existing link is updated if it exists, or a new link is created if it doesn’t. so you don’t have to worry about checking if the link already exists.server/api/links.put.ts
5. Update link
Let’s update an existing link using the Pearset TypeScript SDK. You can do that in two ways:- Using the link’s
linkIdin Pearset’s system. - Using the link’s
externalIdin your own database (prefixed withext_).
server/api/links.patch.ts
6. Retrieve analytics for link
Pearset allows you to retrieve analytics for a link using the Pearset TypeScript SDK.server/api/analytics.get.ts
externalId field.
server/api/analytics.get.ts
7. Examples
Nuxt.js Example
See the full example on GitHub.