DEV Community

Cover image for Easy way to Create your own API for FREE

Easy way to Create your own API for FREE

Varshith V Hegde on September 14, 2022

Table of Contents Table of Contents Introduction What is Google Sheets? How to create API using Google Sheets? Step 1 Step 2 Step 3 ...
Collapse
 
thomasbnt profile image
Thomas Bnt

Hello! Google Sheet isn't for that 🫣

Collapse
 
kaspera profile image
Kasper Andreassen

Indeed, but to quote myself when I used Google Sheets as a CMS:

anything that can fit into a spreadsheet eventually will end up in a spreadsheet.

Doesn't mean it's a pretty sight though πŸ˜‚

Collapse
 
varshithvhegde profile image
Varshith V Hegde

πŸ˜‚Great

Collapse
 
varshithvhegde profile image
Varshith V Hegde

It feels like illegal πŸ˜‚

Collapse
 
vinceamstoutz profile image
Vincent Amstoutz • Edited

Very good job and an interesting approach for non-developers or to create a prototype very fast.
However, I think that you may mention in your title "static API" and adding at least one of these tags to be more accurante : #sheet #googleworkspaces #google #appscript

Regards

Collapse
 
varshithvhegde profile image
Varshith V Hegde

πŸ˜…Yeah sorry for it

Collapse
 
vinceamstoutz profile image
Vincent Amstoutz

No problem, it's also for your visibility πŸ˜‰

Collapse
 
hacknetayush profile image
HackNetAyush

But it will be a static api...
Then you can also write some json and host it... That's also an api then!

Collapse
 
varshithvhegde profile image
Varshith V Hegde

but you can do live writing and reading using some appscript in the google console so even if it is static in some you can update add delete very easily and it's very easy to contain also

Collapse
 
hacknetayush profile image
HackNetAyush

Okay, I was unaware of that we can update the content of google sheets using some script.

Thread Thread
 
varshithvhegde profile image
Varshith V Hegde

Yup πŸ‘

Collapse
 
mellen profile image
Matt Ellen-Tsivintzeli

This is great! Thanks for sharing.

I might try integrating this into my github pages somehow πŸ˜‹

Collapse
 
varshithvhegde profile image
Varshith V Hegde

Yeah you can if you do please send me the link love to see your projects. πŸŽ‰

Collapse
 
georgecronje1 profile image
georgecronje1

WOW! This is actually so cool! Actually quite useful for a mock API even.

Collapse
 
varshithvhegde profile image
Varshith V Hegde • Edited

Yeah i even created website so everyone can track the placement information πŸ˜…. Varshithvhegde.github.io/placements

Collapse
 
alvesjessica profile image
Jessica Alves

A complementary reading :)
medium.com/@eric_koleda/why-you-sh...

Collapse
 
varshithvhegde profile image
Varshith V Hegde

Wow I thought to cover the disadvantages in my next post. And I think for small applications or if you are competing in a hackathon and you need faster way to generate api i think this would be great.

Collapse
 
varshithvhegde profile image
Varshith V Hegde

Ok now this comment made my dayπŸ₯Ί. Happy to know that this helped.

Collapse
 
tleperou profile image
Thomas LepΓ©rou

That's quiet original and may definitely fit with some use cases -- e.g. interfacing with Google forms' results. Caution with the term API which might be excessive though. Thanks for sharing

Collapse
 
varshithvhegde profile image
Varshith V Hegde

I dont know about google forms but you can use it as server for your contact form i have made it you can check it here

Collapse
 
digitalcolony profile image
Michael Allen Smith

Step 4: Should be "Apps Script". I found the option under the Extensions menu.

Collapse
 
varshithvhegde profile image
Varshith V Hegde

Yes there are multiple ways to get there and this also ne of them .Thanks for noting it

Collapse
 
vladgen profile image
David

Hi, recently I discovered DevApiService. It's online tool for mockup API. You can make HTTP requests (GET, POST, PUT and DELETE) without limits and with token authorization than generate the platform.

Collapse
 
be_rajeevkumar profile image
Rajeev Kumar

Hello Varshith,
I followed the same but wasn't able to print the table.
Please check this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>HTML + CSS</title>
</head>
<body></body>
<script>
const api =
"https://script.google.com/macros/s/AKfycbxctkTYq0JxZVkTpXVES5FJtSA5_dWeZyTWMKOcOdo/dev";
fetch(api)
.then((respons) => respons.json())
.then((characters) => showCharacters.data());
showCharacters = (characters) => {
document.write(
"<table class='tab'><tr class='tab'><th class='tab'><h2>Name</h2></th><th class='tab'><h2>USN</h2></th><th>"
);
characters.forEach((character) => {
if (character.Name != "Name") {
document.write(
"<tr style='color:black;font-weight: bold;'><td>" +
character.Name +
"</td><td class='tab'>" +
character.Location +
"</td><td>"
);
}
});
};
</script>
</html>