Introduction
People search for billions of different keywords on Google daily. As the go-to search engine, Google offers many filtering options for its users to customize searches depending on their needs. In this article, I will explain the usage of such filters with SerpApi, and how to apply them to your API calls properly.
Extracting non-adult results with the safe
filter
You can filter your results not to include adult content using the safe
parameter with active
value. This comes in handy when trying to extract family-friendly results, and you don't want to waste time going through your results manually to exclude those that don't meet the requirements. If such a filter is not applied, Google might warn you about the possibility of adult results appearing for your query:
Below are two queries with and without safe=active
used:
Search query without the safe
filter.
Search query with the safe
filter.
Showing precise results with the nfpr
filter
Perhaps you've tried to look for a specific word spelled incorrectly in Google's eyes. Unfortunately, Google tries to be smarter than the user, which in some cases is beneficial, while in the others it might be annoying.
We can bypass the default Google behavior with the nfpr=1
parameter. This way, we get exactly what we are looking for, even when the word we searched for might seem incorrect.
Once again, here are two examples of results with and without the nfpr
parameters used:
Search query without the nfpr
parameter
Search query with the nfpr
parameter
Getting all results for your query with the filter
parameter
To show only the most relevant results, Google automatically excludes "Similar results" labeled as very similar to the ones displayed. This information can be found on the last page of your search results:
While in many cases, you'd like to get the most relevant results, in some situations, you might be interested in the exact number of results Google provides for your query. To do that, you can use the filter=0
parameter for your query, which forces Google to display all the results, including the omitted ones. This can increase your output by even a couple of hundred results!
You can refer to the examples below to compare the same queries with and without filter
parameter:
Search query without filter
parameter
Search query with filter
parameter
Advanced search parameters
On top of the above mentioned options, Google also allows for other filtering options with the appropriate value for tbm
parameter. Some values are common for both Google Search and Google News, while others are engine-specific.
Common Google Search and Google News tbs
values
You can specify the time for your Google Search and Google News queries:
- Past hour - tbs=qdr:h
- Past 24 hours - tbs=qdr:d
- Past week - tbs=qdr:w
- Past month - tbs=qdr:m
- Past year - tbs=qdr:y
- Custom range - tbs=cdr:1,cd_min:x/x/x,cd_max:y/y/y, where x/x/x is start date and y/y/y is end date.
You can play with your time tbs
values to customize your searches even further. For example, you can search for results in the past 5 hours using tbs=qdr:h5, or you can get results from the past six months using tbs=qdr:m6.
Google Search and Google News specific tbs
values
There are also a couple of tbs
values that are specific for each engine. They will only work with that engine, and using them with the other one has no results
For Google Search, you can set your query to display only results that match your search term verbatim. To do that, you need to add tbs=li:1
. You can find the example below:
Verbatim search in Google Search API
With Google News, you can add an additional time filter to get results from archives. This filter is tbs=ar:1
, and you can check the example below:
Archives search in Google News API
You can also sort your news by date. The default sorting is by relevance, and to change that to date sorting, add tbs=sbd:1
to your parameters. You can use the below example as a guide:
Google News API results sorted by date
The final filter I want to discuss is the option to show duplicates in Google News API results. This works only when your results are sorted by date, and you won't be able to use this filter alone. The parameter that should be used is tbs=sbd:1,nsd:1
and you can find the example below:
Google News API results sorted by date and including duplicates
Pagination with num
and start
parameters
Even though these parameters serve for pagination purposes, it's worth mentioning them as they are one of the most commonly used Google Search API parameters.
By default, Google serves ten results per page, and the same behavior is default for our Google Search and Google News APIs. However, you can increase the number of results in a single API call to 100 by adding num=100
parameter. The examples with and without this parameter can be found below:
Google Search API returning ten results (default)
Google Search API returning 100 results
You might wonder how to extract additional results, as Google can serve more than 100. This is where the start
parameter comes in handy. To get results 101-200, you can use your previous query with num=100
parameter and add an additional start=100
parameter. To get the following results (201-300), increase your start parameter by 100, resulting in start=200
value. You can refer to the examples below:
2nd page of Google Search API results (101-200)
3rd page of Google Search API results (201-300)
You can learn more about the pagination by checking the link below:
How does Google Pagination Work?
Closing thoughts
Google constantly changes, and at SerpApi, we are changing accordingly. Some filters previously available in Google are no longer available; on the other hand, some filters might be added in the future. We keep up with Google and add as many options for our users as possible. If you notice a filter not supported in our APIs, feel free to contact us at contact@serpapi.com. We will be more than happy to help you!
Check our Tips and Tricks blog post
Use the Playground to test our APIs
Join us on Twitter | YouTube