# Code examples

Source: https://grounder.net/docs/api/examples

> A search from Python and from TypeScript.

## Search from Python and TypeScript

Set `GROUNDER_KEY` to a key from [Search keys](https://grounder.net/account/keys).

**search.py** (Python)

```python
import os
import requests

response = requests.post(
    "https://api.grounder.net/v1/search",
    headers={"Authorization": f"Bearer {os.environ['GROUNDER_KEY']}"},
    # context.prompt_content: the user's own message, as they typed it
    json={"query": "How do browsers size a CSS grid?",
          "context": {"prompt_content": "How do browsers size a CSS grid?"}},
    timeout=30,
)
response.raise_for_status()
answer = response.json()
for row in answer["topics"]:
    print(row["name"], row["source"])
for result in answer["results"]:
    print(result["title"], result["url"])
```

**search.ts** (TypeScript)

```typescript
const key = process.env.GROUNDER_KEY
const response = await fetch("https://api.grounder.net/v1/search", {
  method: "POST",
  headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
  body: JSON.stringify({ query: "How do browsers size a CSS grid?", context: { prompt_content: "How do browsers size a CSS grid?" } }),
})
if (!response.ok) throw new Error(await response.text())
const answer = await response.json()
for (const row of answer.topics) console.log(row.name, row.source)
for (const result of answer.results) console.log(result.title, result.url)
```
