Examples
Below you can glance at some simple examples that will help you to understand how easy you can retrieve data using Keyword Tool API.
Please note, that to get the data using the code examples below, you need to subscribe to Keyword Tool API and receive a unique API key.
To get the data, you will need to replace [API_KEY] with the actual API key that you will be able to find in your account menu after subscribing.
Example Codes for Retrieving Google's Keyword Suggestions
https://api.keywordtool.io/v2/search/suggestions/google?apikey=[APIKEY]&keyword=apple&metrics=true&metrics_location=2840&metrics_language=en&metrics_network=googlesearchnetwork&metrics_currency=USD&output=json
curl \
--request POST 'https://api.keywordtool.io/v2/search/suggestions/google' \
--data-raw '{
"apikey": "[APIKEY]",
"keyword": "apple",
"category": "web",
"country": "US",
"language": "en",
"type": "suggestions",
"exclude": [],
"metrics": true,
"metrics_location": [
2840
],
"metrics_language": [
"en"
],
"metrics_network": "googlesearchnetwork",
"metrics_currency": "USD",
"output": "json"
}'
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.keywordtool.io/v2/search/suggestions/google',
'body': JSON.stringify({
"apikey": "[APIKEY]",
"keyword": "apple",
"category": "web",
"country": "US",
"language": "en",
"type": "suggestions",
"exclude": [],
"metrics": true,
"metrics_location":[
2840
],
"metrics_language":[
"en"
],
"metrics_network": "googlesearchnetwork",
"metrics_currency": "USD",
"output": "json"
})
};
request(options, function (error, response) {
if (error) {
throw new Error(error);
}
console.log(response.body);
});
<?php
$params = [
'apikey' => '[API_KEY]',
'keyword' => 'apple',
'country' => 'US',
'language' => 'en',
'type' => 'suggestions',
'exclude': [],
'metrics': true,
'metrics_location' => [
2840
],
'metrics_language' => [
'en'
],
'metrics_network' => 'googlesearchnetwork',
'metrics_currency' => 'USD',
'output' => 'json',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.keywordtool.io/v2/search/suggestions/google');
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($ch);
$response = json_decode($output, TRUE);
var_dump($response);
import requests
url = "https://api.keywordtool.io/v2/search/suggestions/google"
data = {
"apikey": "[APIKEY]",
"keyword": "apple",
"category": "web",
"country": "US",
"language": "en",
"type": "suggestions",
"exclude": [],
"metrics": "true",
"metrics_location": [
2840
],
"metrics_language": [
"en"
],
"metrics_network": "googlesearchnetwork",
"metrics_currency": "USD",
"output": "json"
}
response = requests.post(url, json = data)
print(response.text.encode('utf8'))
Example Codes for Retrieving Google's Search Volumes
https://api.keywordtool.io/v2/search/volume/google?apikey=[APIKEY]&keyword=["apple","samsung"]&metrics_location=2840&metrics_language=en&metrics_network=googlesearchnetwork&metrics_currency=USD&output=json
curl \
--request POST 'https://api.keywordtool.io/v2/search/volume/google' \
--data-raw '{
"apikey": "[APIKEY]",
"keyword": [
"apple",
"samsung"
],
"metrics_location": [
2840
],
"metrics_language": [
"en"
],
"metrics_network": "googlesearchnetwork",
"metrics_currency": "USD",
"output": "json"
}'
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.keywordtool.io/v2/search/volume/google',
'body': JSON.stringify({
"apikey": "[APIKEY]",
"keyword": [
"apple",
"samsung"
],
"metrics_location":[
2840
],
"metrics_language":[
"en"
],
"metrics_network": "googlesearchnetwork",
"metrics_currency": "USD",
"output": "json"
})
};
request(options, function (error, response) {
if (error) {
throw new Error(error);
}
console.log(response.body);
});
<?php
$params = [
'apikey' => '[API_KEY]',
'keyword' => [
'apple',
'samsung'
],
'metrics_location' => [
2840
],
'metrics_language' => [
'en'
],
'metrics_network' => 'googlesearchnetwork',
'metrics_currency' => 'USD',
'output' => 'json',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.keywordtool.io/v2/search/volume/google');
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($ch);
$response = json_decode($output, TRUE);
var_dump($response);
import requests
url = "https://api.keywordtool.io/v2/search/volume/google"
data = {
"apikey": "[APIKEY]",
"keyword": [
"apple",
"samsung"
],
"metrics_location": [
2840
],
"metrics_language": [
"en"
],
"metrics_network": "googlesearchnetwork",
"metrics_currency": "USD",
"output": "json"
}
response = requests.post(url, json = data)
print(response.text.encode('utf8'))
Please note that in GET request method, 'metrics_location' and 'metrics_language' are comma separated while in POST request method, they are array.
You can find the comprehensive API reference with more code samples on this page: https://docs.keywordtool.io/reference
Updated about 2 years ago
What’s Next