• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
dl4senses

dl4senses

grok_user_search

Public
Like
grok_user_search
Home
Code
13
.claude
1
.vtignore
AGENTS.md
DEPLOYMENT.md
README.md
TROUBLESHOOTING.md
deno.json
grok_client.ts
index.html
H
main.ts
schema.ts
H
test_example.ts
types.ts
Branches
1
Pull requests
Remixes
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
…
README.md

Grok X User Search

A Val Town application that uses xAI's Grok API to search and retrieve information from X (Twitter) users.

Features

  • 🌐 Web Interface: User-friendly HTML frontend
  • πŸ” Natural Language Search: Query X posts using conversational language
  • πŸ‘₯ Target Users: Focus on specific users or general searches
  • πŸ“… Date Filtering: Search within specific time ranges
  • πŸ–ΌοΈ Media Analysis: Include image and video analysis
  • πŸ”— Citations: Get source links for all results
  • πŸš€ Fast API: Direct JSON API for programmatic access

Usage

Web Interface (Recommended)

Simply visit your val's URL in a web browser:

https://your-val-url.web.val.run

The web interface provides:

  • Intuitive form with all search options
  • Real-time loading states
  • Formatted result display
  • Example search buttons
  • Mobile-responsive design

API Endpoint

Send POST requests to the val's URL:

curl -X POST https://your-val-url.web.val.run \ -H "Content-Type: application/json" \ -d '{ "query": "find all the latest prompts mentioned", "targetUser": "dl4senses" }'

Request Parameters

  • query (required): Natural language search query
  • targetUser (optional): Specific X handle to search (without @)
  • dateRange (optional): Object with from and to dates (ISO8601 format)
  • includeMedia (optional): Enable image/video analysis (default: false)
  • maxResults (optional): Limit number of results

Example Requests

Search specific user for prompts

{ "query": "find all the latest prompts mentioned", "targetUser": "dl4senses", "includeMedia": true }

General search with date range

{ "query": "latest AI developments and machine learning breakthroughs", "dateRange": { "from": "2025-01-01", "to": "2025-01-15" } }

Search without media analysis

{ "query": "popular coding tutorials", "maxResults": 10 }

Response Format

{ "success": true, "data": { "summary": "Comprehensive answer to your query...", "posts": [ { "id": "1234567890", "text": "Post content...", "author": "username", "timestamp": "2025-01-01T12:00:00Z", "url": "https://x.com/username/status/1234567890" } ], "citations": [ "https://x.com/username/status/1234567890" ], "metadata": { "model": "grok-4-fast", "usage": { "prompt_tokens": 100, "completion_tokens": 200, "total_tokens": 300 }, "searchTime": 2500 } } }

Setup

Environment Variables

Set the following environment variable in your Val Town dashboard:

  • XAI_API_KEY: Your xAI API key (required)

Deployment

  1. Create a new val in Val Town
  2. Upload the files from this directory
  3. Set the XAI_API_KEY environment variable
  4. Test with the example requests above

API Details

This application uses:

  • Model: grok-4-fast - Fast reasoning model optimized for search
  • Tools: X Search with optional web search
  • Rate Limits: Respects xAI API rate limits

Error Handling

The application returns appropriate HTTP status codes and error messages:

  • 400: Bad request (invalid parameters)
  • 405: Method not allowed (non-POST requests)
  • 500: Internal server error (API failures)

Security

  • Input validation and sanitization
  • Secure API key handling via environment variables
  • CORS headers for browser compatibility
  • Request logging for debugging

Limitations

  • Dependent on xAI API availability and rate limits
  • Search results limited by X's data retention policies
  • Media analysis increases token usage and response time

Examples

Find Latest Prompts by @dl4senses

curl -X POST https://your-val-url.web.val.run \ -H "Content-Type: application/json" \ -d '{ "query": "find all the latest prompts mentioned by @dl4senses", "targetUser": "dl4senses", "includeMedia": true, "dateRange": { "from": "2025-01-01" } }'

Search for AI News

curl -X POST https://your-val-url.web.val.run \ -H "Content-Type: application/json" \ -d '{ "query": "latest artificial intelligence news and breakthroughs", "dateRange": { "from": "2025-01-01" }, "maxResults": 15 }'

Development

To extend this application:

  1. Add new search parameters in types.ts
  2. Implement additional parsing logic in grok_client.ts
  3. Add new endpoint handlers in main.ts

Support

For issues related to:

  • API functionality: Check xAI documentation
  • Val Town deployment: Review Val Town docs
  • Application bugs: Create an issue in the repository
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2025 Val Town, Inc.