> Searlo API Docs — Autocomplete (Suggestions)
> Source: https://searlo.tech/docs#search-suggestions
> Full docs: https://searlo.tech/docs/full.md

# Autocomplete (Suggestions)

Google Autocomplete: the suggestions Google offers while a query is being typed.

### Endpoint

```
GET /search/suggestions
```

**Credits:** 0.5 per request

### Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `q` | string | Yes | Partial query (1–200 chars) |
| `limit` | number | No | Number of suggestions (1–10, default: 10) |
| `hl` | string | No | Language code (2–5 chars, default: `en`) |

### Response

```json
{
  "success": true,
  "data": {
    "query": "machine lear",
    "suggestions": ["machine learning", "machine learning python", "machine learning course"],
    "source": "searlo.tech(engine)",
    "timestamp": "2026-09-29T10:00:00.000Z"
  },
  "message": "Suggestions retrieved successfully"
}
```

The suggestions are in `data.suggestions`, as plain strings. An upstream failure returns `502` or `503` with `success: false`, and the credits are refunded.

### Trending (not available)

`GET /search/trending` is not available. The route exists but has no data source behind it: it answers `200` with an error object in `data` instead of trending queries. Do not build on it.

## Code Examples

### cURL

```bash
curl "https://api.searlo.tech/api/v1/search/suggestions?q=mach&limit=10&hl=en" \
  -H "x-api-key: sk_your_api_key"
```

### JavaScript

```javascript
async function getSuggestions(query, limit = 10) {
  const params = new URLSearchParams({ q: query, limit: String(limit) });
  const res = await fetch(
    `https://api.searlo.tech/api/v1/search/suggestions?${params}`,
    { headers: { "x-api-key": process.env.SEARLO_API_KEY } }
  );
  const { data } = await res.json();
  return data.suggestions;
}

const suggestions = await getSuggestions("mach");
console.log(suggestions); // ["machine learning", ...]
```

### Python

```python
import os
import requests

def get_suggestions(query, limit=10, hl="en"):
    r = requests.get(
        "https://api.searlo.tech/api/v1/search/suggestions",
        params={"q": query, "limit": limit, "hl": hl},
        headers={"x-api-key": os.environ["SEARLO_API_KEY"]},
    )
    r.raise_for_status()
    return r.json()["data"]["suggestions"]

print(get_suggestions("mach"))
```


---
*From https://searlo.tech/docs — see full docs at https://searlo.tech/docs/full.md*