Search content
curl --request GET \
--url https://{churchShortname}.thehaystack.ai/api/haystack/searchimport requests
url = "https://{churchShortname}.thehaystack.ai/api/haystack/search"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://{churchShortname}.thehaystack.ai/api/haystack/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{churchShortname}.thehaystack.ai/api/haystack/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{churchShortname}.thehaystack.ai/api/haystack/search"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{churchShortname}.thehaystack.ai/api/haystack/search")
.asString();require 'uri'
require 'net/http'
url = URI("https://{churchShortname}.thehaystack.ai/api/haystack/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"query": "<string>",
"queryAnalyticsId": "<string>",
"items": [
{
"item": {
"id": 123,
"title": "The Power of Prayer",
"subTitle": "<string>",
"description": "<string>",
"shortDescription": "<string>",
"date": "2025-01-15",
"collectionId": 123,
"seriesId": 123,
"orderInSeries": 123,
"urlSlug": "<string>",
"durationSecs": 123,
"publishedDate": "2023-11-07T05:31:56Z",
"autoPublish": true,
"squareImgUrl": "<string>",
"wideImgUrl": "<string>",
"ultraWideImgUrl": "<string>",
"verticalImgUrl": "<string>",
"entryDate": "2023-11-07T05:31:56Z",
"collection": {
"id": 1,
"name": "Sunday Sermons",
"fullService": false,
"variantTypes": [
{
"id": 123,
"name": "Sermon Video",
"indexable": true,
"displayOrder": 123,
"collectionId": 123
}
]
},
"series": {
"id": 123,
"title": "The Gospel of John",
"subTitle": "<string>",
"collectionId": 123,
"description": "<string>",
"shortDescription": "<string>",
"sortOrder": 123,
"itemSortDirection": "DESC",
"showItemOrderInSeries": true,
"urlSlug": "<string>",
"colorHex": "#FF5733",
"squareImgUrl": "<string>",
"wideImgUrl": "<string>",
"ultraWideImgUrl": "<string>",
"published": true,
"verticalImgUrl": "<string>",
"squareImgMetadata": {},
"wideImgMetadata": {},
"ultraWideImgMetadata": {},
"verticalImgMetadata": {},
"items": "<array>",
"collection": {
"id": 1,
"name": "Sunday Sermons",
"fullService": false,
"variantTypes": [
{
"id": 123,
"name": "Sermon Video",
"indexable": true,
"displayOrder": 123,
"collectionId": 123
}
]
}
},
"speakers": [
{
"id": 123,
"name": "Pastor John Smith",
"bio": "<string>",
"imageUrl": "<string>",
"imageFilename": "<string>",
"itemCount": 123
}
],
"scriptures": [
{
"id": 123,
"itemId": 123,
"book": "<string>",
"bookName": "Matthew",
"chapter": 123,
"verseStart": 123,
"verseEnd": 123,
"keyVerse": true,
"suggested": true,
"accepted": true,
"displayOrder": 123,
"citation": "Matthew 5:1-12",
"hidden": true
}
],
"mediaAssets": [
{
"id": 123,
"itemId": 123,
"item": "<unknown>",
"mimeType": "<string>",
"variantTypeId": 123,
"variantType": {
"id": 123,
"name": "Sermon Video",
"indexable": true,
"displayOrder": 123,
"collectionId": 123
},
"fileSizeBytes": 123,
"durationSecs": 123,
"bitrate": 123,
"videoWidth": 123,
"videoHeight": 123,
"filename": "<string>",
"originalFilename": "<string>",
"externalPlatformId": "<string>",
"muxAssetId": "<string>",
"muxPlaybackId": "<string>",
"url": "<string>",
"downloadUrl": "<string>",
"chapters": [
{
"id": 123,
"itemId": 123,
"mediaAssetId": 123,
"title": "Introduction",
"startMs": 123,
"suggested": true,
"accepted": true,
"hidden": true
}
],
"entryDate": "2023-11-07T05:31:56Z"
}
],
"resources": [
{
"id": 123,
"itemId": 123,
"title": "<string>",
"subTitle": "<string>",
"description": "<string>",
"resourceTypeId": 123,
"displayOrder": 123,
"fileMimeType": "<string>",
"fileSizeBytes": 123,
"externalPlatformId": "<string>",
"thumbnailImgUrl": "<string>",
"url": "<string>",
"resourceType": {
"id": 123,
"name": "<string>"
},
"linkTarget": "<string>"
}
],
"suggestedDescription": "<string>",
"suggestedShortDescription": "<string>",
"errorMessage": "<string>",
"indexedMediaAssetId": 123,
"autoAcceptScriptures": true,
"autoAcceptMediaChapters": true,
"transcriptUrl": "<string>",
"topics": [
{
"id": 123,
"name": "<string>",
"itemCount": 123
}
],
"squareImgMetadata": {},
"wideImgMetadata": {},
"ultraWideImgMetadata": {},
"verticalImgMetadata": {}
},
"score": 123,
"highlights": [
{
"transcript": "<string>",
"startMs": 123,
"endMs": 123,
"score": 123,
"thumbnailUrl": "<string>"
}
]
}
],
"scriptures": [
{
"book": "matthew",
"bookName": "Matthew",
"chapter": 123,
"numItems": 123
}
],
"series": [
{
"series": {
"id": 123,
"title": "The Gospel of John",
"subTitle": "<string>",
"collectionId": 123,
"description": "<string>",
"shortDescription": "<string>",
"sortOrder": 123,
"itemSortDirection": "DESC",
"showItemOrderInSeries": true,
"urlSlug": "<string>",
"colorHex": "#FF5733",
"squareImgUrl": "<string>",
"wideImgUrl": "<string>",
"ultraWideImgUrl": "<string>",
"published": true,
"verticalImgUrl": "<string>",
"squareImgMetadata": {},
"wideImgMetadata": {},
"ultraWideImgMetadata": {},
"verticalImgMetadata": {},
"items": "<array>",
"collection": {
"id": 1,
"name": "Sunday Sermons",
"fullService": false,
"variantTypes": [
{
"id": 123,
"name": "Sermon Video",
"indexable": true,
"displayOrder": 123,
"collectionId": 123
}
]
}
},
"numItems": 123,
"linkedItemUrlSlug": "<string>"
}
]
}Search
Search Content
Semantic search across sermons, scriptures, and series. By default returns all results in a single JSON response. When stream=true, returns a text/event-stream with these message types:
results— full results payload (same shape as the non-stream response)headline— streaming AI headline ({headline: string}appended incrementally)overview— streaming AI overview ({overview: string}appended incrementally)complete— final message; stream closeserror— error event; stream closes
GET
/
search
Search content
curl --request GET \
--url https://{churchShortname}.thehaystack.ai/api/haystack/searchimport requests
url = "https://{churchShortname}.thehaystack.ai/api/haystack/search"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://{churchShortname}.thehaystack.ai/api/haystack/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{churchShortname}.thehaystack.ai/api/haystack/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{churchShortname}.thehaystack.ai/api/haystack/search"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{churchShortname}.thehaystack.ai/api/haystack/search")
.asString();require 'uri'
require 'net/http'
url = URI("https://{churchShortname}.thehaystack.ai/api/haystack/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"query": "<string>",
"queryAnalyticsId": "<string>",
"items": [
{
"item": {
"id": 123,
"title": "The Power of Prayer",
"subTitle": "<string>",
"description": "<string>",
"shortDescription": "<string>",
"date": "2025-01-15",
"collectionId": 123,
"seriesId": 123,
"orderInSeries": 123,
"urlSlug": "<string>",
"durationSecs": 123,
"publishedDate": "2023-11-07T05:31:56Z",
"autoPublish": true,
"squareImgUrl": "<string>",
"wideImgUrl": "<string>",
"ultraWideImgUrl": "<string>",
"verticalImgUrl": "<string>",
"entryDate": "2023-11-07T05:31:56Z",
"collection": {
"id": 1,
"name": "Sunday Sermons",
"fullService": false,
"variantTypes": [
{
"id": 123,
"name": "Sermon Video",
"indexable": true,
"displayOrder": 123,
"collectionId": 123
}
]
},
"series": {
"id": 123,
"title": "The Gospel of John",
"subTitle": "<string>",
"collectionId": 123,
"description": "<string>",
"shortDescription": "<string>",
"sortOrder": 123,
"itemSortDirection": "DESC",
"showItemOrderInSeries": true,
"urlSlug": "<string>",
"colorHex": "#FF5733",
"squareImgUrl": "<string>",
"wideImgUrl": "<string>",
"ultraWideImgUrl": "<string>",
"published": true,
"verticalImgUrl": "<string>",
"squareImgMetadata": {},
"wideImgMetadata": {},
"ultraWideImgMetadata": {},
"verticalImgMetadata": {},
"items": "<array>",
"collection": {
"id": 1,
"name": "Sunday Sermons",
"fullService": false,
"variantTypes": [
{
"id": 123,
"name": "Sermon Video",
"indexable": true,
"displayOrder": 123,
"collectionId": 123
}
]
}
},
"speakers": [
{
"id": 123,
"name": "Pastor John Smith",
"bio": "<string>",
"imageUrl": "<string>",
"imageFilename": "<string>",
"itemCount": 123
}
],
"scriptures": [
{
"id": 123,
"itemId": 123,
"book": "<string>",
"bookName": "Matthew",
"chapter": 123,
"verseStart": 123,
"verseEnd": 123,
"keyVerse": true,
"suggested": true,
"accepted": true,
"displayOrder": 123,
"citation": "Matthew 5:1-12",
"hidden": true
}
],
"mediaAssets": [
{
"id": 123,
"itemId": 123,
"item": "<unknown>",
"mimeType": "<string>",
"variantTypeId": 123,
"variantType": {
"id": 123,
"name": "Sermon Video",
"indexable": true,
"displayOrder": 123,
"collectionId": 123
},
"fileSizeBytes": 123,
"durationSecs": 123,
"bitrate": 123,
"videoWidth": 123,
"videoHeight": 123,
"filename": "<string>",
"originalFilename": "<string>",
"externalPlatformId": "<string>",
"muxAssetId": "<string>",
"muxPlaybackId": "<string>",
"url": "<string>",
"downloadUrl": "<string>",
"chapters": [
{
"id": 123,
"itemId": 123,
"mediaAssetId": 123,
"title": "Introduction",
"startMs": 123,
"suggested": true,
"accepted": true,
"hidden": true
}
],
"entryDate": "2023-11-07T05:31:56Z"
}
],
"resources": [
{
"id": 123,
"itemId": 123,
"title": "<string>",
"subTitle": "<string>",
"description": "<string>",
"resourceTypeId": 123,
"displayOrder": 123,
"fileMimeType": "<string>",
"fileSizeBytes": 123,
"externalPlatformId": "<string>",
"thumbnailImgUrl": "<string>",
"url": "<string>",
"resourceType": {
"id": 123,
"name": "<string>"
},
"linkTarget": "<string>"
}
],
"suggestedDescription": "<string>",
"suggestedShortDescription": "<string>",
"errorMessage": "<string>",
"indexedMediaAssetId": 123,
"autoAcceptScriptures": true,
"autoAcceptMediaChapters": true,
"transcriptUrl": "<string>",
"topics": [
{
"id": 123,
"name": "<string>",
"itemCount": 123
}
],
"squareImgMetadata": {},
"wideImgMetadata": {},
"ultraWideImgMetadata": {},
"verticalImgMetadata": {}
},
"score": 123,
"highlights": [
{
"transcript": "<string>",
"startMs": 123,
"endMs": 123,
"score": 123,
"thumbnailUrl": "<string>"
}
]
}
],
"scriptures": [
{
"book": "matthew",
"bookName": "Matthew",
"chapter": 123,
"numItems": 123
}
],
"series": [
{
"series": {
"id": 123,
"title": "The Gospel of John",
"subTitle": "<string>",
"collectionId": 123,
"description": "<string>",
"shortDescription": "<string>",
"sortOrder": 123,
"itemSortDirection": "DESC",
"showItemOrderInSeries": true,
"urlSlug": "<string>",
"colorHex": "#FF5733",
"squareImgUrl": "<string>",
"wideImgUrl": "<string>",
"ultraWideImgUrl": "<string>",
"published": true,
"verticalImgUrl": "<string>",
"squareImgMetadata": {},
"wideImgMetadata": {},
"ultraWideImgMetadata": {},
"verticalImgMetadata": {},
"items": "<array>",
"collection": {
"id": 1,
"name": "Sunday Sermons",
"fullService": false,
"variantTypes": [
{
"id": 123,
"name": "Sermon Video",
"indexable": true,
"displayOrder": 123,
"collectionId": 123
}
]
}
},
"numItems": 123,
"linkedItemUrlSlug": "<string>"
}
]
}No Authentication Required: This endpoint does NOT require authentication. Never include your API token when calling this endpoint, especially from client-side JavaScript, as this would expose your credentials to all users.
Using “Try It Out”: This endpoint requires a church-specific base URL. To test this endpoint:
- Click the server dropdown and select “Your church-specific Search API”
- Replace
{churchShortname}with your actual church shortname - Find your shortname in the Haystack Dashboard under Developer → API
https://gracechurch.thehaystack.ai/api, your shortname is gracechurch.Response Format
The search endpoint supports two response formats:Standard JSON Response (Default)
Fast, simple response with search results only. Best for most use cases.const SEARCH_URL = 'https://your-church-name.thehaystack.ai/api';
const response = await fetch(
`${SEARCH_URL}/haystack/search?q=${encodeURIComponent('prayer')}`
);
const data = await response.json();
// Returns: { query, queryAnalyticsId, items, scriptures, series }
console.log('Found', data.items.length, 'items');
import requests
SEARCH_URL = 'https://your-church-name.thehaystack.ai/api'
response = requests.get(
f'{SEARCH_URL}/haystack/search',
params={'q': 'prayer'}
)
data = response.json()
print(f"Found {len(data['items'])} items")
curl "https://your-church-name.thehaystack.ai/api/haystack/search?q=prayer"
Streaming Response with AI Overview (Advanced)
For an AI-generated overview of results, add?stream=true to receive a Server-Sent Events stream. This feature is best suited for advanced integrations that need real-time AI summaries.
Server-Sent Events Implementation
Server-Sent Events Implementation
Event Types:Popular SSE Libraries:
results: Search results (same structure as JSON response)overview: Chunks of AI-generated summary as they’re generatedcomplete: Stream finished successfullyerror: An error occurred
const SEARCH_URL = 'https://your-church-name.thehaystack.ai/api';
const eventSource = new EventSource(
`${SEARCH_URL}/haystack/search?q=prayer&stream=true`
);
let overviewText = '';
eventSource.addEventListener('results', (event) => {
const message = JSON.parse(event.data);
console.log('Results:', message.data);
});
eventSource.addEventListener('overview', (event) => {
const message = JSON.parse(event.data);
overviewText += message.data.overview;
console.log('Overview chunk:', message.data.overview);
});
eventSource.addEventListener('complete', () => {
console.log('Complete overview:', overviewText);
eventSource.close();
});
eventSource.addEventListener('error', (event) => {
console.error('Error:', JSON.parse(event.data).error);
eventSource.close();
});
import json
import sseclient # pip install sseclient-py
import requests
SEARCH_URL = 'https://your-church-name.thehaystack.ai/api'
response = requests.get(
f'{SEARCH_URL}/haystack/search',
params={'q': 'prayer', 'stream': 'true'},
stream=True
)
client = sseclient.SSEClient(response)
overview_text = ''
for event in client.events():
message = json.loads(event.data)
if message['type'] == 'results':
print(f"Found {len(message['data']['items'])} items")
elif message['type'] == 'overview':
overview_text += message['data']['overview']
print('Overview chunk received')
elif message['type'] == 'complete':
print(f'Complete overview: {overview_text}')
break
elif message['type'] == 'error':
print(f"Error: {message['error']}")
break
<?php
// Using https://github.com/mpociot/php-sse-client
require 'vendor/autoload.php';
use Mpociot\SSE\Client;
$searchUrl = 'https://your-church-name.thehaystack.ai/api';
$client = new Client("{$searchUrl}/haystack/search?q=prayer&stream=true");
$overviewText = '';
$client->on('message', function($event, $data) use (&$overviewText) {
$message = json_decode($data, true);
switch ($message['type']) {
case 'results':
echo "Found " . count($message['data']['items']) . " items\n";
break;
case 'overview':
$overviewText .= $message['data']['overview'];
echo "Overview chunk received\n";
break;
case 'complete':
echo "Complete overview: {$overviewText}\n";
break;
case 'error':
echo "Error: {$message['error']}\n";
break;
}
});
$client->listen();
?>
# Using https://github.com/Tonkpils/celluloid-eventsource
require 'celluloid/eventsource'
require 'json'
search_url = 'https://your-church-name.thehaystack.ai/api'
url = "#{search_url}/haystack/search?q=prayer&stream=true"
overview_text = ''
source = Celluloid::EventSource.new(url)
source.on_message do |raw_message|
message = JSON.parse(raw_message)
case message['type']
when 'results'
puts "Found #{message['data']['items'].length} items"
when 'overview'
overview_text += message['data']['overview']
puts 'Overview chunk received'
when 'complete'
puts "Complete overview: #{overview_text}"
source.close
when 'error'
puts "Error: #{message['error']}"
source.close
end
end
# Stream SSE events to console
curl -N "https://your-church-name.thehaystack.ai/api/haystack/search?q=prayer&stream=true"
- Python:
sseclient-py,aiohttp-sse-client - PHP:
mpociot/php-sse-client,artax/sse - Ruby:
celluloid-eventsource,sse-client - Node.js:
eventsource, built-infetchwith stream handling - Go:
r3labs/sse, standardhttppackage
Query Parameters
Natural-language search query
Available options:
embed, connect, console Required when surface=embed
Scope search to a single collection
When true, responds with Server-Sent Events streaming the AI overview as it is generated
Format hint for the AI overview
Response
Search results. Returns JSON by default, or Server-Sent Events stream when stream=true.
⌘I

