57 lines
1.3 KiB
Markdown
57 lines
1.3 KiB
Markdown
# Search API
|
|
|
|
Simple HTTP search endpoints. Returns JSON.
|
|
|
|
## Endpoints
|
|
|
|
| Service | URL |
|
|
|---------|-----|
|
|
| Google | `http://192.168.8.128:3001/search` |
|
|
| DuckDuckGo | `http://192.168.8.128:3002/search` |
|
|
|
|
## Usage
|
|
|
|
```
|
|
GET /search?q=your+query&num=5
|
|
```
|
|
|
|
**Params:**
|
|
- `q` (required) — search query
|
|
- `num` (optional) — max results, default 10, max 20
|
|
|
|
## Example
|
|
|
|
```bash
|
|
curl "http://192.168.8.128:3001/search?q=Python+async+best+practices&num=5"
|
|
```
|
|
|
|
**Response:**
|
|
```json
|
|
{
|
|
"query": "Python async best practices",
|
|
"results": [
|
|
{
|
|
"title": "Python asyncio documentation",
|
|
"url": "https://docs.python.org/3/library/asyncio.html",
|
|
"snippet": "The asyncio library provides infrastructure for writing concurrent code..."
|
|
},
|
|
{
|
|
"title": "Best Practices for asyncio - Real Python",
|
|
"url": "https://realpython.com/async-io-python/",
|
|
"snippet": "When working with asyncio, follow these patterns for clean concurrent code..."
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
## Rate Limits
|
|
|
|
- Google: 5s between requests
|
|
- DuckDuckGo: 3s between requests
|
|
|
|
## Tips
|
|
|
|
- Use Google (`:3001`) for general web search
|
|
- Use DuckDuckGo (`:3002`) for different ranking or privacy-focused results
|
|
- Keep queries concise (2-5 words)
|
|
- If one engine returns poor results, try the other |