Introduction

The Typescript SDK allows for easy interaction with the Linkup API, offering the full range of our search functionality. Easily integrate smart search capabilities into your applications, harnessing Linkup’s powerful search features. You can use our playground to have interactive examples and see how to implement them with the SDK.

Quickstart

Get started with our Typescript SDK in less than 5 minutes!

Get your API key

Create a Linkup account for free to get your API key.

Installation

You can install the Linkup Typescript SDK using the following:

npm i linkup-sdk

Usage

Here is a basic usage showing how to use the Linkup SDK:

import { LinkupClient } from "linkup-sdk";

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

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

askLinkup().then(console.log);

Input Parameters

ParameterTypeDescriptionDefault
querystrThe input query stringRequired
depthstringType of search to perform “standard” or “deep”Required
outputTypestringLinkup response type, can be “sourcedAnswer”, “searchResults”, “structuredOutput”Required
structuredOutputSchemastringThe returned schema from the Linkup API. It should be used only if the outputType is ‘structured’.undefined
includeImagesbooleanTo also return imagesundefined
fromDatedateFrom date to searchundefined
toDatedateTo date to searchundefined

Query

The query parameter is the core input string that defines your search intent. It represents the question or information request that you want Linkup to answer. How you formulate this query significantly impacts the quality and relevance of results.

Effective queries should be:

  • Clear and specific: “What were the key findings of NASA’s James Webb telescope in 2023?” provides better results than “Tell me about space discoveries”
  • Contextually rich: Include relevant context when needed (“What are the environmental impacts of lithium mining for EV batteries?”)
  • Naturally phrased: Write as you would ask a knowledgeable person, not with keywords

For optimal results, consider reviewing our prompting guide, which provides detailed strategies for crafting effective queries.

Depth

The depth field is used to select the type of search you want to perform:

  • standard: the search will be straightforward and fast, suited for relatively simple queries (e.g. “What’s the weather in Paris today?”)
  • 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?”)

Output type

The type of output which is expected:

  • sourcedAnswer: Provides a comprehensive natural language answer to the query along with citations to the source material. Ideal for when you need well-formed responses with verifiable information and transparent sourcing.
  • searchResults: Returns the raw search context data without synthesis, giving you direct access to the underlying information. Useful for custom processing, or when you need to implement your own answer generation logic.
  • structured: Allows you to receive responses in a custom format based on the format provided in structuredOutputSchema. If you want a full guide on how to use it, you check it here

Structured output schema

Linkup’s structured output feature allows you to receive responses in a custom format that you define. This is particularly useful when you need to integrate Linkup’s responses directly into your application’s data structure or when you want to ensure consistency in the response format. To do that, you have to use the structuredOutputSchema field. If you want a full guide on how to use it, you check it here

Include images

The includeImages parameter allows you to receive image results alongside text results in your search responses. When set to true, Linkup will return relevant images related to your query, each with a URL and metadata. This is particularly useful for:

  • Creating visual search experiences
  • Building content that combines text and images
  • Researching topics where visual information is important

Image results are returned with the same structure as text results but with type: "image".

fromDate

The fromDate parameter filters search results to only include content published after the specified date. This helps you:

  • Focus on recent information
  • Exclude outdated content

The date should be a Date type, for example: new Date("2024-01-01").

toDate

The toDate parameter complements fromDate by restricting search results to only include content published or updated before the specified date. This is useful for:

  • Historical research on specific time periods
  • Analyzing content published within a specific date range
  • Avoiding more recent information that might skew results

Like fromDate, the date should be a Date type, for example: new Date("2024-12-31").

When used together, fromDate and toDate create a date range filter for your search results.

Examples

Additional ressources

Prompting guide

We strongly recommend you to read our prompting guide to best prompt the Linkup API and get optimal results. Even small improvements in how you structure your prompts can dramatically enhance the quality of responses and the overall user experience.

Structured output guide

We strongly recommend you to read our structured output guide to ensure consistency in the response format. Mastering structured outputs allows you to fully leverage Linkup’s capabilities while maintaining complete control over how the information is presented and processed in your application.

Tutorials

Don’t hesitate to check our tutorials for other ideas of what to build with Linkup!

And voilà ! You’re now ready to implement the Linkup SDK inside your fabulous project ! 🚀

Facing issues? Reach out to our engineering team at support@linkup.so or via our Discord.