Making API Calls with JustSERP API: A Powerful Tool for Google SERP Data Retrieval
In today's digital age, search engine result pages (SERPs) play a crucial role in determining the online visibility and success of businesses. To harness the power of SERP data, developers can leverage APIs like JustSERP, which provides a seamless way to retrieve search results from Google. By making a POST request to the API endpoint, developers can specify various parameters to customize their search queries. To try out sample queries without building an application, you can do so in your justserp dashboard or the API documentation. Let's take a closer look at the key components of the API call provided:
const axios = require('axios');
const options = {
method: 'POST',
url: 'https://api.justserp.com/v1/search',
headers: {
accept: 'application/json',
'content-type': 'application/json',
'x-api-key': '<API-KEY-HERE>'
},
data: {
keyword: 'string',
device: 'desktop',
country: 'United States',
language: 'English',
num: '10',
start: '0',
uule: 'string',
html: 'false'
}
};
axios
.request(options)
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.error(error);
});
Request Data
Endpoint and Headers: The API call begins by specifying the endpoint URL, which is 'https://api.justserp.com/v1/search'. Additionally, the request headers include the 'accept' and 'content-type' fields, which are set to 'application/json'. The 'x-api-key' field should be replaced with a valid API key obtained from JustSERP. When you sign-up, you get 200 free calls to try out the API service.
- Request Payload: The data section of the API call contains several parameters that define the search query. These parameters include:
- 'keyword': The search term or keyword for which you want to retrieve SERP data.
- 'device': The device type for which the search results should be generated (e.g., 'desktop' or 'mobile').
- 'country': The country from which the search results should be obtained (e.g., 'United States', 'United Kingdom', etc.).
- 'language': The language in which the search results should be presented (e.g., 'English', 'Spanish', etc.).
- 'num': The number of search results to be returned.
- 'start': The index of the first search result to be retrieved.
- 'uule': A string parameter that represents the location from which the search results should be localized.
- 'html': A boolean parameter indicating whether the response should include HTML content.
Handling the Response
Once the API call is made, the response is obtained in JSON format. In the provided code snippet, the response data is logged to the console using console.log(response.data). Let's examine the different components of the response body and understand their significance:
- Meta: The "meta" object contains metadata related to the API response. It includes the following fields:
- "status": An integer indicating the HTTP status of the API request.
- "query": The search query for which the SERP data was retrieved.
- "device": The device type specified in the API request.
- "googleURL": The URL of the Google search page corresponding to the query.
- "totalResults": The total number of search results found for the query.
- "time_taken": This field indicates the time taken by the API to process the request and retrieve the SERP data.
1. Organic Results: The "organic_results" array contains objects representing individual search results. Each object within the array consists of the following fields:
- "position": The position of the search result on the SERP.
- "title": The title of the search result.
- "description": A brief description or snippet associated with the search result.
- "link": The URL of the search result.
2. "Ads": Paid ads data is an array of paid ads links for this google query.
3. "related_questions": An array of strings representing related questions associated with the query.
4. Related Searches: The "related_search" array contains strings representing related search queries associated with the original query.
However, developers can further process the response data as per their requirements. This may involve extracting specific information, performing data analysis, or integrating it into other applications. You can take a look at various use-cases of this data by checking our article from last month.
The JustSERP API offers developers a convenient way to retrieve Google SERP data in JSON format. By leveraging this API, businesses can gain valuable insights into their online presence, monitor competitors, and make data-driven decisions. With the ability to customize search queries based on keywords, devices, countries, and languages, the JustSERP API empowers developers to harness the power of SERP data effectively.