Automating Google Place API Using Rest Assured-Part 1

Automating Google Place API Using Rest Assured-Part 1

In this blog we will learn, how we can automate one of the most important Google place API’s using Rest Assured.

Before moving further into this blog, I would highly recommend you to read my other blogs on the understanding of API testing and how to work with GET, PUT, POST and Delete Request.

To start with Google Place API first we need to sign up to get the API keys to authenticate us on their server.

Click on this link to sign up for generating API Keys, Select product and fill out the required information.

Once you successfully signup you will get an exclusive API Key that will only work with your id.

Now in this blog, I would be starting first with Google Place Search API. We can directly look into this API by using this link.

Please don't try to Access keys that I have shown in the screenshot or code as it won't work for your ids.

As we know, in automating any API the most key part is reading and understanding the API specification documents.

So let’s first go through API Official documentation to understand this API.

In this URI: is our base URI, and

maps/api/place/textsearch/json is our resource URI,

The request type is GET,

Output could either be JSON or XML

And required mandatory parameters are query and API key.

So now let’s first execute this Request using Postman where I tried to search all the nearby restaurant in place let’s say Airoli bypassing mandatory parameter query and key in Params tag of the postman.

Now to implement the same in Rest Assured is quite easy now.

Here in the code, I have search all the Restaurants in Airoli and get the place id for the first result.

    To understand this code, first I have put a few basic assertions on status code, Response Header, and Body.

 Please Note the response we get will be in raw format that needs to be converted into String and then from the string into JSON as all the validation we need to do in JSON format only.

    Below is my output of the above code execution:

    Now let's understand one of the most an important part in API testing that is  API Chaining i.e passing the response from one API that would ultimately become input for the next rest API.

    For that let's use google Place details API in this I will find out the name, rating, and location for the place id we retrieve from our first test.
Similar to first request is our base URI, and

    maps/api/place/details/json is our resource URI

    Here mandatory parameters are placeid and API Key but in this example, I would be passing one more optional parameter "Fields" for obtaining rating and location of the specified place id.

    So now the Placeid which we got as output in our first response we will be passing as a parameter in the request.

    Below is the output of the code execution:

 Below is the complete Code Snapshot:



My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
July 18, 2019 at 2:20 PM

I want to learn Manual/Automation testing webservices/API's from scratch.. Could u please suggest me the blog.

January 6, 2020 at 1:17 PM

The greatest thing about electronic marketing and advertising organizations is the folks. We like studying the clients go to this web-site … all the places of their lives plus the idiosyncratic approaches these folks mark are typically vital and play considerable capabilities in the method. It’s these tales that wind up being the motivation for his or her visual information. The folks could be essential.

February 25, 2020 at 12:06 PM

Thanks to share these details it’s truly nice.
List Leverage