The XO Search API token.
The text query used to perform a search through the catalog.
NodeJS / NPM example
import { search } from '@attraqt/search';
const query = 'T-shirt';
search.init({ token: SEARCH_API_TOKEN });
const response = await search.query(query);
console.log(response);
HTML example
<script type="text/javascript">
xo.init({
search: {
token: SEARCH_API_TOKEN
}
});
xo.search.query('T-Shirt').then((response) => {
console.log(response);
});
</script>
HTTP example
POST https://api-eu.attraqt.io/search HTTP/1.1
Content-Type: application/json; charset=UTF-8
{
"token": "SEARCH_API_TOKEN",
"query": "T-Shirt"
}
curl
example
curl -d "{\"token\":\"${SEARCH_API_TOKEN}\", \"query\":\"T-Shirt\"}" \
-H "Content-Type: application/json; charset=UTF-8" \
-X POST "https://api-eu.attraqt.io/search"
JavaScript example
const response = await fetch('https://api-eu.attraqt.io/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8'
},
body: JSON.stringify({
token: SEARCH_API_TOKEN,
query: 'T-Shirt',
})
});
if (response.ok) {
console.log(await response.json());
}
HTTP example
GET https://api-eu.attraqt.io/search/:token?encoded=:encodedParams HTTP/1.1
curl
example
curl "https://api-eu.attraqt.io/search/${SEARCH_API_TOKEN}?encoded=%7B%22query%22%3A%22T-Shirt%22%7D"
JavaScript example
const token = SEARCH_API_TOKEN;
const params = encodeURIComponent(JSON.stringify({
query: 'T-shirt'
}));
const response = await fetch(
`https://api-eu.attraqt.io/search/${token}?encoded=${params}`
);
if (response.ok) {
console.log(await response.json());
}