Members-only tutorial
Watch the video and get the practice sheet with membership.
About this Tutorial
Sheet Resources
Apps Script APIs used
Apps Script methods used
Video Transcript
<div>00:00 I think this video is going to be pretty fun because you're going to join me as we work through a problem, an API problem, where Learn how to filter data effectively using the query where clause in Google Sheets. Opens in new tab we're going to try to use the Collegiate Dictionary API that exists.<br>00:12 I was looking through some Google Sheet videos and I saw this Miriam Webster Slash Dictionary.
URL and I thought oh this might still exist where Learn how to filter data effectively using the query where clause in Google Sheets. Opens in new tab you just add the word and then you can get the definition with this import Discover how to import data into your Google Sheets seamlessly. Opens in new tab XML but it doesn't really work we can even try to do something maybe try to get this<br>00:30 to work with like a sometimes it needs the www sometimes no it's not working so I was like hey there is an actual API here wouldn't it be cool if I could figure out the API and I wanna walk through figuring it out so I havent figured it out yet so youre gonna walk with me through it I have been reading<br>00:56 the documentation theres json documentation all this stuff its really good to read all of this but also sometimes its really good to just walk through so I did get an API key were gonna use an API key here I dont think Ive set up anything I have a extensions app script Explore the power of Apps Script to automate tasks in Google Sheets. Opens in new tab going to go over here create API<br>01:18 key all caps im gonna grow grab it and put it in there yeah we have nothing set up so far so were gonna just call it a function Understand how to create and use functions in Google Sheets for better calculations. Opens in new tab get definition were going to get our word here and then were gonna have our variables here were gonna use URL fetch app of course .fetch and were gonna fetch the URL which it<br>01:40 will tell us but yeah make sure you get your API key put it in an API key if you want to follow along yourself lets see we have an introduction we have data Get insights on managing and analyzing data within Google Sheets. Opens in new tab structure entry metadata labels inflections I think these are all parts of it but lets see just the overview ah terminology cool we want to see <br>02:09 the api uhm lets just use dictionary we had need json right json fields Learn about fields in Google Sheets and how they relate to your data. Opens in new tab request here we go request url ok grab this and put that in as our url actually we can call that variable url here we go and we need an api key so we'll add that and we need a word here this is the word so we will add word and we<br>02:42 will add that as a uhm variable here and now we add our api key plus api key our api key is going to be variable api key equals spreadsheet Dive into the basics of spreadsheets and their functionalities. Opens in new tab app dot get active spreadsheet Find out how to access and manipulate the active spreadsheet in Google Sheets. Opens in new tab just do this so many times get sheet by name api key in all caps dot get range i know it by heart start a1 i knew i put it in there<br>03:14 alright so there's our api key we're gonna hit save we're going to fetch this url we want some options i think i think we're gonna need some options here let's go back to our api documentation maybe not lets just go grab the data we have meta definition def there it is def so lets look at our data that<br>03:47 comes back without any options so variable response equals this and we're going to return response dot get content text that's how we get access to that API or most APIs were going to save this right here in lets do equals get definition a3 lets make this a little bit bigger so we can see it.<br>04:16 And see what we get invalid API key not subscribed for this reference alright let me go figure that out so I went back and looked at the documentation I think I forgot this test word here so we're going to add that uhm wait no test seems to be the word one second so what we might want to do is add some<br>04:38 options here where the options is method is uhm not post but git and we want to try that let's see if that works and it doesn't really say that our reference is bad it does say reference not subscribe for this reference invalid api key but we can maybe look at that api key again ok i see the issue this<br>05:11 is so silly this is silly this is a appscript issue I didn't get value, I only got the range of the API key.<br>05:20 Really was this was the absolute exact thing to give us because the API key was wrong it was just not getting the value great now we have this data wow awesome so now we are grabbing the data correctly and we just need to parse it should be pretty easy we can look at this json beautifier let's look at<br>05:43 the best one here and what we want to do is get where's the definition there it is short def def oh my god its so far down uhm so lets do this lets make this into json or uhm data equals json dot parse response and now we can do return data dot i think we want one dot short def i think that's what we<br>06:25 want to do because looking at this we want short def here we might want even zero one perfect we want zero probably just one short definition save that hmm theres no short def for software but there is short def definitions for these words i dont know why software doesnt have one type r cannot read properties<br>06:59 of undefined so this software doesnt have a short definition but now we have definitions for all these words we have at least one definition set act or action of setting yeah coach to go in a coach these are some version of the definition we can possibly put both in there maybe lets do this variable <br>07:24 short def one each equals this and variable short def two if there is a second one join uhm just short def one plus lets put a forced uhm put a space in between them short def two and see what happens.<br>08:06 Now we're getting errors because they probably don't have short def hmm what we could as well do is instead of this allowing for more we can just say try try here try this and catch if theres an error i think we need to Put, error return error so it'll try it it won't give us an exact this error it'll<br>08:43 just give us some blank so we can try it it makes it a little cleaner I think actually each of these datas have a short def so we'll do this and I bet we're gonna get something for everything but everything has one that I made that mistake im looking at this again and I see ok there's a zero here one<br>09:02 two that means theres probably three definitions for this particular word but if theres only one definition were gonna have to only access this zero so well just take the first definition uhm you know this is not absolutely perfect cause we did this in about ten minutes uhm but I think this is a really<br>09:16 cool way to show you how to take just a random here API look at the documentation capture this URL add in our words add in our API key we just added a new sheet put get value we made sure that that was a little sticking point uhm and we just do this over and over again this response equals we do the <br>09:40 fetching we add some options if we need it to we might not even need those options i bet it works without these options let's try it it's always good to just try something and if you keep getting errors then just read through those errors and see what happens let's replace all of these yeah we don't <br>10:00 need those options we're just grabbing the data that we're getting back and we're parsing through it with json which is this data equals json.parse and then were gonna go here and parse through it and we looked at it through this json viewer here hopefully this was fun for you and now you can use dictionaries<br>10:20 inside of your spreadsheet tools cool</div>
Courses
Add Icons To Your Sheets With a Domain Name
00:04:21
Automatic Screenshots in Apps Script
Add Tasks to Google Tasks From Google Sheets
Tweet From a Sheet
Convert Google Sheets into a REST API
Expense Tracker Template with Data Entry Form Inside Sheets
Build a Book Recommender with AI in Google Sheets
Build a License Key Generator and API in 20 Minutes
Create Your Own API by Deploying a Web App
Access Free API's with Google Sheets
Use Random Quote API in Google Sheets
OpenSea Data Inside Sheets
Tag Emails From A List of Members in Google Sheets
Spreadsheet Automation 101 Lesson 4: Access APIs Introduction
How to Validate Email Addresses
Build Your Own Free Domain Availability Checker
Build a Job Status Checker API in 15 Minutes
Spreadsheet Automation 101 Lesson 4: UrlFetchApp
Spreadsheet Automation 101 Lesson 4: OmdbAPI get ApiKey, get Data in URL
Spreadsheet Automation 101 Lesson 4: OmdbAPI Parameter Picker
Spreadsheet Automation 101 Lesson 4: OmdbAPI get data in Apps Script
Spreadsheet Automation 101 Lesson 4: JSON (beautifier) and OmdbAPI parameters
Quickstart Tutorial OpenAI API in Google Sheets
Shaman: AI Blog Writer
ChatGPT Clone in Google Sheets Part 1
ChatGPT Clone in Google Sheets Part 2
How To Set Up Stripe Webhook to Google Sheets with Google Script
00:22:10
Create Instant QR Codes
Access the Dictionary API to get Definitions for Words in Google Sheets