Introduction
The Python 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 Python 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 Python SDK as any Python package, for instance usingpip
:
Usage
Here is a basic usage example showing how to use the Linkup Python SDK:Search parameters
Parameter | Type | Description | Default |
---|---|---|---|
query | str | The input query | Required |
depth | typing.Literal["standard", "deep"] | The depth of the search | Required |
output_type | typing.Literal["searchResults", "sourcedAnswer", "structured"] | The desired output type | Required |
structured_output_schema | pydantic.BaseModel , str or None | The desired schema for the output, if output_type is structured | None |
include_images | datetime.bool or None | Whether to include images in the search | None |
from_date | datetime.date or None | The date from which the search results should be considered | None |
to_date | datetime.date or None | The date until which the search results should be considered | None |
exclude_domains | list[str] or None | The domains to exclude from the search | None |
include_domains | list[str] or None | The domains to restrict the search with | None |
include_inline_citations | bool or None | Whether to include inline citations in the answer, if output_type is sourcedAnswer | None |
include_sources | bool or None | Whether to include the sources, if output_type is structured (modifies the schema of the output) | None |
Query
Thequery
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
Depth
Thedepth
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
structured_output_schema
. 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 thestructured_output_schema
field. Supported formats are a pydantic.BaseModel or a string representing a valid object JSON schema.
If you want a full guide on how to use it, you check it here
Include images
Theinclude_images
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
type: "image"
.
From date
Thefrom_date
parameter filters search results to only include content published after the specified date. This helps you:
- Focus on recent information
- Exclude outdated content
datetime.date
type, for example: datetime.date(2025, 3, 1)
.
To date
Theto_date
parameter complements from_date
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
from_date
, the date should be a datetime.date
type, for example: date(2025, 3, 15)
.
When used together, from_date
and to_date
create a date range filter for your search results.
Exclude domains
Theexclude_domains
parameter allows you to specify a list of domains that should be excluded from the search results. This is useful for:
- Filtering out unwanted sources
- Avoiding results from specific domains that may not be relevant or trustworthy.
Include domains
Theinclude_domains
parameter allows you to specify a list of domains that must be included in the search results. This is useful for:
- focus on specific sources
- ensure that results come from trusted domains.
Include inline citations
Theinclude_inline_citations
parameter is specifically designed for use with the sourcedAnswer
output type. When enabled, it embeds citations directly within the answer text, making it easier to identify which parts of the response correspond to specific sources. This is particularly useful for:
- Academic or research applications where source attribution is critical
- Creating content that needs verifiable claims with clear sourcing
- Building applications where users need to quickly verify information
include_inline_citations
is set to True
, the answer will contain inline references like [1], [2] that correspond to the sources in the response.
Include sources
Theinclude_sources
parameter is specifically designed for use with the structured
output type. When enabled, it modifies the schema of the structured response to include source information alongside your custom data structure. This is particularly useful for:
- Applications that need both structured data and source attribution
- Building systems that require traceability of information
- Creating responses where you want to maintain both custom format and source verification
include_sources
is set to True
, the response will be wrapped in a LinkupSearchStructuredResponse
object containing both your structured data and source information.
Fetch parameters
Parameter | Type | Description | Default |
---|---|---|---|
url | str | The URL of the web page to fetch | Required |
include_raw_html | bool or None | Whether to include the raw HTML in the response | None |
render_js | bool or None | Whether the API should render JavaScript on the page | None |
URL
Theurl
parameter specifies the web page URL that you want to fetch content from. This should be a fully qualified URL including the protocol (http:// or https://). The fetch endpoint will retrieve the page content and return it in a cleaned up mardown, making it easy to process the web page by AI agents or other applications.
Include raw HTML
Theinclude_raw_html
parameter controls whether the raw HTML source code of the web page is included in the response alongside the cleaned up markdown content. This is useful for applications that need to perform custom HTML parsing, preserve specific formatting, or access elements that might be filtered out during the standard content extraction process.
Render JS
Therender_js
parameter determines whether JavaScript should be executed when fetching the web page. When set to True
, the API will render the page in a browser-like environment, executing JavaScript code and waiting for dynamic content to load before extracting the content. This is essential for modern web applications that rely heavily on JavaScript for content generation, such as single-page applications (SPAs) or pages with dynamically loaded content, but induces additional latency.
Examples
Last Formula 1 race
Standard example
Last Formula 1 race
Standard example
This example show you how to combine the standard search with a sourced answer
Company Revenue
Deep + structured output
Company Revenue
Deep + structured output
This example shows you how to use the deep with a relative complexe structured output:
Latest politic news
Search results as outputType
Latest politic news
Search results as outputType
This example shows you how to use the standard with a search results:
Amazon deforestation
IncludeImages filter
Amazon deforestation
IncludeImages filter
This example return text and images sources
AI Avancements
Dates filtering
AI Avancements
Dates filtering
This example shows you how to use the dates filter:
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 or book a 15 minutes call with a member of our technical team.