DEV Community

Cover image for How To Build Your Own Keyword Tool With Google Ads API & C#
Hasan Aboul Hasan
Hasan Aboul Hasan

Posted on

How To Build Your Own Keyword Tool With Google Ads API & C#

What we will build?

We'll use Google Ads API to build a keyword Research tool that allows you to get keyword suggestions and metrics like Search volume data , CPC and Competition based on user input.

Examples of keyword tools:

If you go to, you can search for a keyword, it will give you hundreds of keyword suggestions.

Image description

It is considered one of the best free keyword tools. (But it’s not totally Free)

Another example is H-supertools.

Image description

I developed H-supertools from scratch, and today this website is one of my main income streams.

Today, In this post, I will reveal how you can build similar tools, so maybe you can turn it also into an income source too!

How does our Keyword Tool works?

It's a simple C# console application. When you run it, you'll have two options:

  1. Authenticate with Google Ads API
  2. Perform keyword research

Image description

Let's perform Keyword Research and search for "C#"
Image description

After the search, our tool gets back ~500 keyword ideas with search volume data, competition, and CPC values.

Of course, In my case, it's a simple console application (just for simplicity reasons) But we can use and implement the same code in any type of applications like mobile, web, or even a desktop application.

Let's Start Coding!

Step 1: Setup Your Google Console Account

So, our first step is to go to Google cloud console and login with your Gmail account.

After you login, create a project, and then click on Enable APIs

Image description

Now search for “Google ad API” and Enable The API

Image description

Step 2: Create OAuth Credentials to access Google Ads API

Image description

Finish the wizard, then you will be able to get the client and secret IDs as shown in the images below:

Image description

Image description

We will use these Keys to authenticate our application.

Before we continue, if you are that person who loves to watch videos instead of reading long posts, you can check the full tutorial here:

Google Ads API Authentication Code

Open KeywordIdeasGoogleAPI.cs Class in our Project.

google ads api with c#

You will see we have two methods.

  • Authenticate()
  • Search()

I found the Google ads API authentication code on Github.

I tweaked it a little bit and Made it simpler for you to understand and use 😃

Let's Authenticate!

I will run the application.

google ads api authentication c#

Hit 1 to authenticate.

It will ask you for the client ID and secret

google ads api authentication example

Copy From Google Console, Paste, hit enter, and authenticate your Gmail account.

Now it will prompt you to copy authentication keys:

google ads api c# authentication keys

Copy and paste these keys in the app.config file in your project files.

google ads api app.config

How To Get The Google Ads Developer Token

Now the next step is to get the developer token. As You can see, we need to set the developer token in the app.config file.

For this, you will need to create a Google ads Manager Account.

Google ads Manager Account

Click Here To Create a Google ads Manager Account.

Create one, Sign In, and click on tools, then click on API center and you'll see the developer token there.

google ads developer token

We got the Token, Paste in the app.config file, and we are ready!

Perform a Keyword Research Test

In the Google Ads API, we have the keyword ideas service.

It is the service I used to perform keyword research.

The Sample Code mentioned on the page will not work directly, this is why again, I tweaked and simplified it so you can run easily and smoothly. (I think I deserve a Heart and maybe a Unicorn 😅)

The Search Method

Keyword tool with google ads api

In the main application, create an instance of our class KeywordIdeasGoogleAPI.

Create a new object of Google client, and pass it to the search method with other parms: locationId, customerId, languageId, and the searchTerm.

keyword tool with google ads api

How to get the customer id?
Create a Google Ads Test Account

Login, and you will see a red message showing that this is a test account, just click and copy the customer ID as shown below:

google ads test account

Make sure to remove the dashes and keep only the numbers when you paste in your code.

we still have locationId and languageId.

Find a list of Location IDs by clicking here. And Find a list of Language Ids here.

For Example, "English" Id is 1000, and "New York" Id is 21167.

Now we are ready to perform a keyword research!

Run the application again

keyword tool with c#

Let's say, we wanna search for this keyword: “subscribe to my channel.” 😅

Hit Enter, and you will see the Magic🎩

get search volume with c#

Note: CPC Bids means that advertisers are paying these numbers to advertise on Google.

Check The Full Project Here on Github.

If you did it. Congratulations 🥳

The Google Ads API is free but has some limitations.Did you know you can use the Free Google Suggestions API To Develop a Keyword Research Tool with no limits! Yes! If you wanna learn how. Check this post.

Top comments (3)

ndquang profile image

I did every step correctly
But when running I get the error:
Grpc.Core.RpcException: 'Status(StatusCode="Unimplemented", Detail="GRPC target method can't be resolved.", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1710404575.084000000","description":"Error received from peer ipv6:[2404:6800:4005:809::200a]:443","file":"..\..\..\src\core\lib\surface\","file_line":1070,"grpc_message":"GRPC target method can't be resolved.","grpc_status":12}")'

rickrickiin profile image

If we want to optimize Google Ads well, we need to know the basics. Recently I found this interesting post, so I recommend it to others:

seba__01ebf7c5a35b8483036 profile image

So useful ! Thanks Hasan. Any thoughts on how to retrieve keyword search volume data from the past 4 years?