Get Google Review API and Display the Rating and Reviews on Your Website

Where to get the Place ID?

Check this link:

Type the place information in the input box where you need the Place ID for.

Where to find the Place Detail API?

Check this link:

Create your API Key from this page, and click “CREATE CREDENTIALS”
Returned JSON data containing place rating and reviews data

CORS Issue

Cross-Origin Resource Sharing allows a server to indicate any origin (domain, scheme, or port) other than its own from which a browser should permit loading resources for the security implications. Read more:

try {
const url = `${ID}&key=${process.env.NEXT_PUBLIC_GOOGLE_API_KEY}`;
fetch(url, {
method: 'GET',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Credentials': 'true',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PATCH, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version'
}).then(res => {
if (res.ok) {
return res.json();
} catch (e) {



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Hanwen Zhang

Hanwen Zhang


Full-Stack Software Engineer at a Healthcare Tech Company | Document My Coding Journey | Improve My Knowledge | Share Coding Concepts in a Simple Way