A proxy server that converts You.com Search API responses into ChatWise search extension compatible format.
This project implements a middleware proxy service that:
- Receives standard request format from ChatWise search extension
- Calls You.com Search API to retrieve search results
- Converts results to ChatWise expected response format
- Supports parallel processing of multiple search queries for improved performance
- Backend: Node.js + Express.js
- HTTP Client: Axios
- Deployment: PM2 process management support
- API: RESTful API design
According to ChatWise Custom Search Provider Documentation, the proxy service accepts POST requests in the following format:
{
"queries": ["search query 1", "search query 2"],
"max_results": 10,
"exclude_domains": ["example.com"]
}Note: Current implementation primarily handles the queries parameter. Support for max_results and exclude_domains parameters can be extended in future versions.
The proxy service returns JSON responses compliant with ChatWise specifications:
{
"results": [
{
"query": "search query 1",
"links": [
{
"title": "Search result title",
"url": "https://example.com",
"content": "Search result description or summary content"
}
]
}
]
}This service calls the You.com Search API (https://api.ydc-index.io/v1/search):
- Authentication: API key passed via
X-API-Keyrequest header - Supported Result Types:
webandnewssearch results - Result Merging: Automatically merges and deduplicates multiple types of search results
- Parallel Processing: Uses
Promise.allto process multiple queries in parallel for improved performance
- Node.js: 18.0+ (LTS version recommended)
- You.com API Key: Obtain from You.com API
-
Clone the Repository
git clone https://github.com/hrayleung/You.com2ChatWise_Search cd chatwise-proxy -
Install Dependencies
npm install
-
Configure Environment Variables
# Set You.com API key export YOU_API_KEY=ydc-sk-your-api-key-here
β οΈ Security Warning: Do not commit API keys to version control -
Start the Service
npm start
The service will start at
http://localhost:1999
curl -X POST http://localhost:1999/search \
-H 'Content-Type: application/json' \
-d '{
"queries": ["open source LLMs", "Node.js Express framework"]
}'Expected Response Example:
{
"results": [
{
"query": "open source LLMs",
"links": [
{
"title": "Best Open Source Large Language Models in 2024",
"url": "https://example.com/article1",
"content": "This article provides a comprehensive overview of the most popular open source large language models..."
}
]
},
{
"query": "Node.js Express framework",
"links": [
{
"title": "Express.js Official Documentation",
"url": "https://expressjs.com",
"content": "Express.js is a fast, minimalist web framework for Node.js..."
}
]
}
]
}PM2 is a production process manager for Node.js applications with built-in load balancer.
-
Install PM2 globally
npm install -g pm2
-
Start with PM2
YOU_API_KEY=ydc-sk-your-api-key pm2 start ecosystem.config.js
-
PM2 Management Commands
# View running processes pm2 list # View logs pm2 logs you.com2chatwise_search # Restart the service pm2 restart you.com2chatwise_search # Stop the service pm2 stop you.com2chatwise_search # Auto-start on system reboot pm2 startup pm2 save
The ecosystem.config.js file reads the YOU_API_KEY from the environment at runtime:
module.exports = {
apps: [{
name: 'you.com2chatwise_search',
script: 'server.js',
env: {
NODE_ENV: 'production',
YOU_API_KEY: process.env.YOU_API_KEY
}
}]
};Create a Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 1999
CMD ["npm", "start"]Build and run:
docker build -t chatwise-proxy .
docker run -d -p 1999:1999 -e YOU_API_KEY=ydc-sk-your-key chatwise-proxy| Variable | Required | Description |
|---|---|---|
YOU_API_KEY |
Yes | Your You.com API key (format: ydc-sk-...) |
PORT |
No | Server port (default: 1999) |
NODE_ENV |
No | Environment mode (development/production) |
To change the default port (1999), you can either:
- Set the
PORTenvironment variable:export PORT=3000 - Modify the port directly in
server.js
- API Key Protection: Never commit API keys to version control
- Environment Variables: Use
.envfiles for local development (already in.gitignore) - HTTPS: Use HTTPS in production environments
- Rate Limiting: Consider implementing rate limiting for production use
- Input Validation: The service validates input queries and returns appropriate error responses
-
"API key is not configured" Error
- Ensure
YOU_API_KEYenvironment variable is set - Verify the API key format starts with
ydc-sk- - Check that the environment variable is available in your shell
- Ensure
-
"Failed to fetch from You.com API" Error
- Verify your You.com API key is valid and active
- Check your internet connection
- Ensure You.com API service is accessible
-
Port Already in Use
- Change the port using
PORT=3000 npm start - Kill the process using the port:
lsof -ti:1999 | xargs kill
- Change the port using
-
Empty Results
- Verify that You.com API is returning data for your queries
- Check the API response format matches expectations
- Review server logs for detailed error information
Enable detailed logging by setting:
export NODE_ENV=developmentView real-time logs with PM2:
pm2 logs you.com2chatwise_search --lines 100- Open ChatWise application
- Navigate to Settings β Extensions β Web Search
- Select "Custom Search Provider"
- Configure the following:
- Endpoint URL:
http://your-server:1999/search - Request Method: POST
- Content Type: application/json
- Request Format: Use the JSON format specified in this README
- Endpoint URL:
After setup, test by asking ChatWise to search for information. The queries should be forwarded to your proxy service and return You.com search results.
- Parallel Processing: Multiple queries are processed simultaneously using
Promise.all - Memory Usage: Minimal memory footprint with efficient result processing
- Response Time: Typical response time depends on You.com API latency (usually < 2 seconds)
- Scalability: Can handle multiple concurrent requests; consider load balancing for high traffic
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Commit changes:
git commit -am 'Add new feature' - Push to branch:
git push origin feature/new-feature - Submit a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
- You.com API Documentation
- ChatWise Official Website
- ChatWise Custom Search Documentation
- Express.js Documentation
- PM2 Documentation