0:00
all right so in this video we are going
0:04
to learn how to create an API using
0:06
Google spreadsheet I have created
0:09
a uh Google spreadsheet and then named
0:12
it free API you can name it anything it
0:14
does not matter or let's say make it
0:22
classmate girls okay and uh what we can
0:26
do is uh we will see who are the girls
0:30
there in your class and if they are
0:33
single or not because that is important
0:35
look better right so like this actually
0:38
we could have done this and then say
0:41
single and let's name fa color first is
0:44
Ana she is single uh true and favorite
0:49
color is right then we have
0:53
false let me do this quickly
1:27
all right I have put all the values so
1:30
for that we will click on extensions and
1:32
then app script and when you click you
1:35
will come here in this page let's call
1:39
the function get API data and then let
1:50
have this so we are getting the
1:56
and uh this is from the spreadsheet and
1:59
then we get the active spreadsheet that
2:01
is this one and then we get the active
2:03
sheet so you know that this is sheet one
2:06
and all and spreadsheet means like this
2:08
so this is getting this active
2:10
spreadsheet and then from that it is
2:12
taking the sheet number or like anything
2:14
you have named here so that is getting
2:16
all the sheets like the AC sheet there
2:19
and then we are getting the data now we
2:22
will have an empty array we can call it
2:25
API data so now we have this headers
2:30
and the index so what we will do is we
2:35
are calling the headers that is this as
2:38
this is in the first uh Row first row
2:41
means like if you know about coding if
2:43
you know about programming we use zero
2:45
as the first number right so this is the
2:47
first row that is this one and then we
2:51
are getting the index for from that
2:53
header now from this headers we are
2:56
getting the index of name single and
2:57
favorite color let me check the okay we
3:00
are calling this Fab color so we also
3:02
need to call this Fab color I hope
3:06
everything else is good
3:11
okay now what we are saying is we are
3:14
calling a for Loop and then we are
3:18
data right and this will be the key when
3:21
we get the API you know that we get it
3:23
as a object file as a Json object right
3:26
so we have key value pair in that so the
3:29
keys our name single and Fab color you
3:31
can name it anything and when we have
3:34
done it we will return this so return
3:37
this as json. stringify and then API
3:40
data will be there so this whole API
3:43
data inside this array when we push the
3:46
data we will make it a Json and then we
3:50
return this right and the last step will
3:53
be to create the web app because this is
3:57
being the API all right but we don't
3:59
don't have the web app that can show you
4:02
the API data for that we can say
4:05
function uh do get and then oops we
4:13
say variable output is equal to content
4:16
service dot create text input and this
4:21
is a function then output
4:32
Json and output do set content is this
4:38
get API data so we just add it
4:42
there and we return the output can just
4:46
make it like this so here we put our
4:50
spreadsheet ID spreadsheet name like the
4:53
sheet name so this is your spreadsheet
4:56
ID we copy this and then paste it here
5:00
and then in sheet one that is you can
5:02
see the sheet name that is here if you
5:05
have not changed this let's say we are
5:06
running like naming this something else
5:09
so let's name this girls and then you
5:12
have to name it girls as well deploy it
5:39
click and this is here so you we can
5:42
just see the data like this now you can
5:44
see we have data till Diva right but uh
5:50
let us oops let us do this if we make it
5:54
like this and add any extra data let's
5:58
say we are adding a new
6:05
be that can be let's say Tina and she is
6:09
single and then her favorite color is
6:13
gold okay now when we update the data
6:21
reload you can see that the new girl is
6:25
here for any reason the color is not
6:30
there I think because I was there Let me