Share 1 Cell to API

Learn how to share a single cell value from Google Sheets to an API, allowing anyone with the URL to access the data without sharing the entire sheet. This tutorial covers the steps to set up a web app using Google Apps Script to achieve this functionality.

So I wanna share one cell to an A-P-I-A-P-I, meaning I want this number to be accessible by sort of anyone who has a URL or even hook it up to some other thing like Monday or. Anywhere to import even a Google site. I wanna be able to put this in, and that's what I mean by API. Someone's gonna check this URL and get a number . And I don't wanna share the entire sheet. I don't wanna share all the tabs. I just want to share this one exact number in this cell. This one is just a sum and it's a number 360 2. And if I change this 22, that is going to change up here. The B one, the sum. Okay. How do I do this? Well, there's a lot of options to share sheets. But none of them actually help.

In this case, we need to go to Extensions app script . Here. I'm just gonna name the project anything. I'm just gonna say sell to API. You can name it anything you want. This name doesn't matter, but this function , this function here. If you have other functions here, then you can just add a function . Name, function , do get, and we're gonna add those parentheses and curly brackets. This is very important that you do do get with the capital G, and it's gonna come into play later. But what we want to do is return some number or sell value, whatever it is. This is a variable. We say ourselves, we type this in. Now we're gonna define that and we're gonna say. Variable sell value equals spreadsheet app.

Get active spreadsheet that's getting the entire file. Get sheet by name. I'm going to go over and say this is 2027 sales and in parentheses, in quotes, 2027 sales. And I'm just gonna put this on a new line so you can see it easier. Get range . Now the range is going to be B one. Okay. And I put that in quotes. B one. If I wanna get a little more interesting and a little more programmatic, let's say I can enter numbers. I'm gonna say row one, comma, and now we're gonna put row and column. So the column is two, 'cause it's in the B column. So not B, but two.

This is a number . And then let's say we want to keep adding more. Programmatic things. We can say it's one comma one, which is one row height and one column height. That's only one cell that is in row one, column two. I can do that. And what's really cool about this is with programming and programmatic things, I can change those numbers based on something, say I wanna say the final bottom row. I don't have to put a A one here. I can put get last row. And I can put a function here that says, get the last row however many rows there are. Get the last one, and put that number there and get the exact one. But for this particular use case, quote, B one, it's going to be the best. And then. I'm gonna do get value this.

Get value says go to B one on 2027 sales in this spreadsheet and get whatever value is there. And so that's the sell value. I'm gonna save this command S or if I make any other changes to this, I can also click this Save project to drive up here. Now I'm not going to click run. Clicking Run actually doesn't do anything. It's not gonna get us anything in this particular case. In order to access this, do get. And I can get any, and I mean anyone can access this if I do what I'm about to do, which is click up here and deploy new deployment. This is a very advanced part of Google App Script , but I'm gonna walk you through every step. Click the select , type up here and say web app. Now this description can be anything. It's just cell value. I can write anything I want here.

I'm gonna execute it as me. And that means anyone that I give access to this URL that's going to be produced from this, they're gonna be able to access as me. But what's really cool is that we've programmed it so they only can grab that cell value. And who has access ? Anyone. That's important too, because we want to be able to give this URL to anyone or any program or any website and say, here, here's the number you want. Click deploy. This may take a moment or a minute. Might take a little bit of time, but maybe most of the time for me it's been taking a few moments. Click, authorize access, and you do, yes, you do have to authorize the access here that's it. So here we have a web app, we have a deployment ID at the top. Yes. Version number . Sure. Web app. URL is this one. This is the key. So I'm gonna open an incognito tab and I'm just gonna copy and

paste that URL into the window. Ah, I need to do one extra thing. Should we need to do content service dot. Create text output and here we'll put sell value. So this is just saying, Hey, take whatever value is there, make it text, and then return it. Now, I've made some edits to my do get, so I'm gonna go up to a deploy and not do new deployment. This time I'm gonna do managed deployments, and here I'm gonna click the edit. Button, it's a little pencil icon. I'm gonna change version one to new version. I can say Sell value Content service. This is just saying giving a little description internally. This doesn't have anything to do with everyone else, so I'm gonna hit Deploy at the bottom again, and now I have a web app.

URL and a library, URL. I'm only going to take this web app, which doing this managed deployment means we do not change the URL at the other side. So if we give this URL to a bunch of people or a bunch of sites, and then we manage deployments and edit it, perfect. But if we do a new deployment, we're gonna get a brand new URL and we have to give that URL out to a bunch of people, which is sometimes what you want to do. Let's do a new incognito tab and paste in our script. And there we go. This is a number 3, 6 3. That is exactly our number . And let's change this a bit. I, we have now 10,000, so if I refresh this. There's the new number , so it is automatically updating the end result of this URL. Which is really, really cool and really, really helpful that now I've shared

this one cell to an API, and that can be shown on a website on Google sites. It can be shown somewhere in a dashboard in A CRM or anywhere else. This is really cool that I can now share one cell to an API and I can update it automatically, meaning that whoever grabs it is gonna grab that new number all the time. I don't have to like say, Hey, new number available. New number available. Isn't that awesome? You are watching better sheets here on YouTube. Make sure you check out this video or this video and subscribe right now to get more tips, tricks, how tos, get more out of your Google sheets than you ever have before. I'm excited to be making a ton more videos here. Ask me questions down in the comments and I will answer them in future videos. But for right now, right here, one of these videos is gonna

be your next Google sheet.