Skip to content

LinkupPlatform/linkup-js-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

65 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Linkup JS/TS SDK

npm package License: MIT downloads

A JS/TS SDK for the Linkup API, allowing easy integration with Linkup's services.

🌟 Features

  • βœ… Simple and intuitive API client.
  • πŸ” Supports both standard and deep search queries.
  • 🧠 Supports asynchronous research tasks and batched task workflows.
  • πŸ”’ Handles authentication and request management.

πŸ“¦ Installation

Requires Node.js >= 22

Simply install the Linkup JS SDK using npm or any other package manager:

npm i linkup-sdk

πŸ“š Documentation

Find the complete documentation here.

πŸ› οΈ Usage

Setting Up Your Environment

1. πŸ”‘ Obtain an API Key:

Sign up on Linkup to get your API key.

2. βš™οΈ Set-up the API Key:

Pass the Linkup API key to the Linkup Client when creating it.

import { LinkupClient } from 'linkup-sdk';

const client = new LinkupClient({
  apiKey: '<YOUR API KEY>',
});

πŸ“‹ Search Endpoint

All search queries can be used with two very different modes:

  • with standard depth, the search will be straightforward and fast, suited for relatively simple queries (e.g. "What's the weather in Paris today?")
  • with deep depth, the search will use an agentic workflow, which makes it in general slower, but it will be able to solve more complex queries (e.g. "What is the company profile of LangChain accross the last few years, and how does it compare to its concurrents?")

πŸ“ Example standard search query

import { LinkupClient } from 'linkup-sdk';

const client = new LinkupClient({
  apiKey: '<YOUR API KEY>',
});

const askLinkup = () => client.search({
  query: 'Can you tell me which women were awared the Physics Nobel Prize',
  depth: 'standard',
  outputType: 'sourcedAnswer',
});

askLinkup()
  .then(console.log)
  .catch(console.error);

⬇️ Fetch Endpoint

You can use the fetch endpoint to retrieve the content of a given URL in clean markdown format.

Use renderJs to execute the JavaScript code of the page before returning the content.

Use includeRawHtml to get the raw HTML of the page.

Use extractImages to get an extracted list of images from the page.

πŸ“ Example

import { LinkupClient } from 'linkup-sdk';

const client = new LinkupClient({
  apiKey: '<YOUR API KEY>',
});

const fetchLinkup = async () => client.fetch({
  url: 'https://docs.linkup.so',
  renderJs: true,
});

fetchLinkup()
  .then(console.log)
  .catch(console.error);

🧠 Research Endpoint

Use research to create an asynchronous research task, then poll it later or list recent runs.

import { LinkupClient } from 'linkup-sdk';

const client = new LinkupClient({
  apiKey: '<YOUR API KEY>',
});

const task = await client.research({
  query: 'Research the current state of the semiconductor market, covering key market dynamics, major industry players and their strategic positioning, recent analyst sentiment, and the main bull and bear cases for the sector. Ground the report in sourced, factual information.',
  outputType: 'sourcedAnswer',
});

const latest = await client.getResearch(task.id);

πŸ—‚οΈ Tasks Endpoint

Use createTasks to submit mixed search, fetch, and research jobs in one batch, then inspect them through listTasks or getTask.

import { LinkupClient } from 'linkup-sdk';

const client = new LinkupClient({
  apiKey: '<YOUR API KEY>',
});

const tasks = await client.createTasks([
  {
    type: 'search',
    input: {
      query: 'Linkup latest product updates',
      depth: 'deep',
      outputType: 'sourcedAnswer',
    },
  },
  {
    type: 'fetch',
    input: {
      url: 'https://docs.linkup.so',
    },
  },
]);

console.log(tasks.map(task => task.id));

πŸ’³ X402 Payment Protocol

The SDK supports the X402 payment protocol, allowing you to pay for API calls with on-chain transactions instead of an API key.

Prerequisites

Install the required peer dependencies:

npm i viem @x402/core @x402/evm

πŸ“ Example

Create a viem LocalAccount compatible with Base (Ethereum):

import { privateKeyToAccount } from 'viem/accounts';

const account = privateKeyToAccount('<YOUR WALLET PRIVATE KEY>');
import { mnemonicToAccount } from 'viem/accounts';

const account = mnemonicToAccount('<YOUR MNEMONIC PHRASE>');

Then pass it to createX402Signer and use the Linkup client:

import { LinkupClient } from 'linkup-sdk';
import { createX402Signer } from 'linkup-sdk/x402';

const signer = createX402Signer(account);
const client = new LinkupClient({ signer });

const response = await client.search({
  query: 'What is the X402 payment protocol?',
  depth: 'standard',
  outputType: 'sourcedAnswer',
});

About

A Javascript SDK for the Linkup API

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors