X Post Links Search is a short Python example. It takes a prompt and a count, asks for X posts that match, and prints them. Each post can include text, a URL and engagement counts.
The problem
A keyword search on X returns a timeline. When you want posts for a prompt, with the URL and the counts in one object, a single links call is the smaller tool.
What the app does
- Sends a prompt and a count.
- Prints the posts that came back.
How it works
The file calls ai_x_links_search with prompt and count. It posts to POST /desearch/ai/search/links/twitter.
This is separate from GET /twitter, which takes an X query string, sort and date filters. Use that endpoint when you need operators such as since: or min_faves:.
The code
import asyncio
import os
from desearch_py import Desearch
# Set DESEARCH_API_KEY in your environment to a key from the Desearch console. Do not commit a real key.
API_KEY = os.environ["DESEARCH_API_KEY"]
async def main():
# desearch-py 1.2.1: ai_x_links_search(prompt, count)
# posts to POST /desearch/ai/search/links/twitter.
async with Desearch(api_key=API_KEY) as desearch:
result = await desearch.ai_x_links_search(prompt="Bittensor", count=10)
print(result)
if __name__ == "__main__":
asyncio.run(main())Set DESEARCH_API_KEY in your environment to your API key. Do not commit a real key.
Endpoints
POST /desearch/ai/search/links/twitter
Example output
The script prints the response. The file does not include a saved sample run or a measured cost.
Run it yourself
The file linked above is twitter_links_search.py in the examples repository. Install desearch-py 1.2.1, create a key at console.desearch.ai, and call ai_x_links_search with a prompt and count.
What it costs
This example does not record X-Desearch-Cost-Usd. Current responses include that header. See pricing.
Ideas to extend it
- Write the posts to the CSV exporter's columns.
- Follow the loudest post into the replies example.
- Combine the posts with web links for the same prompt.
