Extract URLs of search results
from seltz import Seltz
client = Seltz()
response = client.search("Latest AI news", max_results=10)
# Extract URLs
urls = [doc.url for doc in response.documents]
import { Seltz } from "seltz";
const client = new Seltz();
const response = await client.search({ query: "Latest AI news", maxResults: 10 });
// Extract URLs
const urls = response.documents.map((doc) => doc.url);
curl -s -X POST https://api.seltz.ai/v1/search \
-H "x-api-key: $SELTZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "Latest AI news", "max_results": 10}' \
| jq '[.documents[].url]'
Truncate content for a preview
from seltz import Seltz
client = Seltz()
response = client.search("Latest AI news", max_results=10)
# Truncate content for a preview
for doc in response.documents:
preview = doc.content[:200] + "..." if doc.content and len(doc.content) > 200 else doc.content
print(f"{doc.url}")
print(f" {preview}")
print()
import { Seltz } from "seltz";
const client = new Seltz();
const response = await client.search({ query: "Latest AI news", maxResults: 10 });
// Truncate content for a preview
for (const doc of response.documents) {
const preview = doc.content && doc.content.length > 200 ? `${doc.content.slice(0, 200)}...` : doc.content;
console.log(doc.url);
console.log(` ${preview}`);
console.log();
}
curl -s -X POST https://api.seltz.ai/v1/search \
-H "x-api-key: $SELTZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "Latest AI news", "max_results": 10}' \
| jq '.documents[] | {url, preview: (.content[:200] + "...")}'
This truncates
content on the client. For the document’s actual highest-scoring passages, request the snippets field instead. See Get snippets. To control content length on the server instead of trimming it yourself, see Control content length.Filter documents with URLs
from seltz import Seltz
client = Seltz()
result = client.search("TypeScript tutorial", max_results=10)
with_urls = [doc for doc in result.documents if doc.url]
print(f"Found {len(with_urls)} documents with URLs")
import { Seltz } from "seltz";
const client = new Seltz();
const result = await client.search({ query: "TypeScript tutorial", maxResults: 10 });
const withUrls = result.documents.filter(doc => doc.url);
console.log(`Found ${withUrls.length} documents with URLs`);
curl -s -X POST https://api.seltz.ai/v1/search \
-H "x-api-key: $SELTZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "TypeScript tutorial", "max_results": 10}' \
| jq '[.documents[] | select(.url != null and .url != "")]'
Retrieve a subset of the search results
from seltz import Seltz
client = Seltz()
result = client.search("TypeScript tutorial", max_results=10)
# Get first 3 results
top_results = result.documents[:3]
for i, doc in enumerate(top_results, start=1):
print(f"{i}. {doc.url}")
import { Seltz } from "seltz";
const client = new Seltz();
const result = await client.search({ query: "TypeScript tutorial", maxResults: 10 });
// Get first 3 results
const topResults = result.documents.slice(0, 3);
topResults.forEach((doc, i) => {
console.log(`${i + 1}. ${doc.url}`);
});
curl -s -X POST https://api.seltz.ai/v1/search \
-H "x-api-key: $SELTZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "TypeScript tutorial", "max_results": 10}' \
| jq '.documents[:3] | to_entries[] | "\(.key + 1). \(.value.url)"'