Safe Search

Discover how we can perform safe searches using the Pixabay API.

Another option we can add to our query string when requesting data is a safe search. When set to true, only the images which are suitable for all ages will be returned.

Press + to interact

Adding safe search

It is added to our query string like this:

Press + to interact
const { data: images } = useFetch(
() =>
`?key=${apiKey}&q=${searchTerm.value}&page=${currentPageNumber.value}&per_page=${imagesPerPage.value}&safesearch=true`,
{
baseURL: baseUrl,
}
);

We only need to add this when we want safe search ...