Creating a Pipes2 Search endpoint
A Pipes2 search endpoint should output a regular Pipes2 feed. The only difference is that the endpoint gets a query param (q
) of the search term the end user is typing on her mobile/TV device.
Create an endpoint on your server that expects q
as a query param.
Bellow you can see an expressjs
example but you can implement it on whatever server infrastructure you are using.
const express = require('express')
const app = express()
const port = 3000
app.get('/search', async (req, res) => {
const searchTerm = req.query.q;
// Create a fetchItemsBySearchTerm function that calls your API and fetches items according to the given search term.
const items = await fetchItemsBySearchTerm(searchTerm);
// Create a renderItemsAsFeed function that renders items to the Pipes2 schema (https://docs.applicaster.com/integrations/feed-json-protocol)
const feed = renderItemsAsFeed(items)
res.json(feed)
})
To integrate the endpoint you just created just add it as feed inside Zapp according to the instructions written here.
For the example above your feed URL will be
https://example.com/search?q={{q}} The device will dynamically replace
{{q}} with the user's typed search term.