The Desearch Python SDK provides a seamless way to integrate AI-powered search functionalities into your applications. This guide outlines the installation process, available methods, and example implementations.
To install the desearch-py SDK, use the following command.
Once installed, you can instantiate the Desearch client as follows:
📘 API Keys
Get API Key (Follow link to get your API key) https://console.desearch.ai/api-keys.
The Desearch Python SDK provides the following methods for AI-powered search:
ai_search MethodAI-powered multi-source contextual search. Searches across web, X (Twitter), Reddit, YouTube, HackerNews, Wikipedia, and arXiv and returns results with optional AI-generated summaries. Supports streaming responses.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | str | Yes | — | Search query prompt |
tools | List[str] | Yes | — | List of tools to search with (e.g. web, twitter, reddit, hackernews, youtube, wikipedia, arxiv) |
start_date | Optional[str] | No | None | Start date in UTC (YYYY-MM-DDTHH:MM:SSZ) |
end_date | Optional[str] | No | None | End date in UTC (YYYY-MM-DDTHH:MM:SSZ) |
date_filter | Optional[str] | No | PAST_24_HOURS | Predefined date filter for search results |
result_type | Optional[str] | No | LINKS_WITH_FINAL_SUMMARY | Result type (ONLY_LINKS or LINKS_WITH_FINAL_SUMMARY) |
system_message | Optional[str] | No | None | System message for the search |
scoring_system_message | Optional[str] | No | None | System message for scoring the response |
count | Optional[int] | No | None | Number of results per source (10–200) |
Here are the details of the above response. The return type depends on the result_type parameter:
result_type is LINKS_WITH_FINAL_SUMMARYresult_type is ONLY_LINKSai_web_links_search MethodSearch for raw links across web sources (web, HackerNews, Reddit, Wikipedia, YouTube, arXiv). Returns structured link results without AI summaries.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | str | Yes | — | Search query prompt |
tools | List[str] | Yes | — | List of web tools to search with (e.g. web, hackernews, reddit, wikipedia, youtube, arxiv) |
count | Optional[int] | No | None | Number of results per source (10–200) |
ai_x_links_search MethodSearch for X (Twitter) post links matching a prompt using AI-powered models. Returns tweet objects from the miner network.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | str | Yes | — | Search query prompt |
count | Optional[int] | No | None | Number of results to return (10–200) |
x_search MethodX (Twitter) search with extensive filtering options: date range, user, language, verification status, media type (image/video/quote), and engagement thresholds (min likes, retweets, replies). Sort by Top or Latest.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
query | str | Yes | — | Search query. For syntax, check https://docs.desearch.ai/guides/capabilities/twitter-queries |
sort | Optional[str] | No | Top | Sort by Top or Latest |
user | Optional[str] | No | None | User to search for |
start_date | Optional[str] | No | None | Start date in UTC (YYYY-MM-DD) |
end_date | Optional[str] | No | None | End date in UTC (YYYY-MM-DD) |
lang | Optional[str] | No | None | Language code (e.g. en, es, fr) |
verified | Optional[bool] | No | None | Filter for verified users |
blue_verified | Optional[bool] | No | None | Filter for blue checkmark verified users |
is_quote | Optional[bool] | No | None | Include only tweets with quotes |
is_video | Optional[bool] | No | None | Include only tweets with videos |
is_image | Optional[bool] | No | None | Include only tweets with images |
min_retweets | Optional[Union[int, str]] | No | None | Minimum number of retweets |
min_replies | Optional[Union[int, str]] | No | None | Minimum number of replies |
min_likes | Optional[Union[int, str]] | No | None | Minimum number of likes |
count | Optional[int] | No | 20 | Number of tweets to retrieve (1–100) |
x_posts_by_urls MethodFetch full post data for a list of X (Twitter) post URLs. Returns metadata, content, and engagement metrics for each URL.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
urls | List[str] | Yes | — | List of tweet URLs to retrieve |
x_post_by_id MethodFetch a single X (Twitter) post by its unique ID. Returns metadata, content, and engagement metrics.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id | str | Yes | — | The unique ID of the post |
x_posts_by_user MethodSearch X (Twitter) posts by a specific user, with optional keyword filtering.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
user | str | Yes | — | User to search for |
query | Optional[str] | No | None | Advanced search query |
count | Optional[int] | No | None | Number of tweets to retrieve (1–100) |
x_post_retweeters MethodRetrieve the list of users who retweeted a specific post by its ID. Supports cursor-based pagination.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id | str | Yes | — | The ID of the post to get retweeters for |
cursor | Optional[str] | No | None | Cursor for pagination |
x_user_posts MethodRetrieve a user's timeline posts by their username. Fetches the latest tweets posted by that user. Supports cursor-based pagination.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
username | str | Yes | — | Username to fetch posts for |
cursor | Optional[str] | No | None | Cursor for pagination |
x_user_replies MethodFetch tweets and replies posted by a specific user, with optional keyword filtering.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
user | str | Yes | — | The username of the user to search for |
count | Optional[int] | No | None | The number of tweets to fetch (1–100) |
query | Optional[str] | No | None | Advanced search query |
x_post_replies MethodFetch replies to a specific X (Twitter) post by its post ID.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
post_id | str | Yes | — | The ID of the post to search for |
count | Optional[int] | No | None | The number of tweets to fetch (1–100) |
query | Optional[str] | No | None | Advanced search query |
x_trends MethodRetrieve trending topics on X for a given location using its WOEID (Where On Earth ID).
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
woeid | int | Yes | — | The WOEID of the location (e.g. 23424977 for United States) |
count | Optional[int] | No | None | The number of trends to return (30–100) |
web_search MethodSERP web search. Returns paginated web search results, replicating a typical search engine experience.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
query | str | Yes | — | The search query string |
start | Optional[int] | No | 0 | Number of results to skip for pagination |
web_crawl MethodCrawl a URL and return its content as plain text or HTML.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | str | Yes | — | URL to crawl |
format | Optional[str] | No | text | Format of content (html or text) |