New to Rows?
Rows is a spreadsheet on steroids where anyone can build internal tools without code. It has built-in integrations with the tools you use everyday, and a powerful sharing experience to instantly turn any spreadsheet into a web app, a form, or a dashboard.
✏️Sign up for free and follow our step-by-step "Talk to Any API" tutorial.
You’ve got the knowledge and Rows tools to authenticate your requests. But, you’re probably wondering how to get data from an API. Stick with us, as in this article we’ll talk about:
- Some more basic terms in API documentation
- How to use Rows’
GET()
function to request data
Some more basic terms in APIs
Again, we’ll need to just quickly make sure that we’re all on the same page regarding some terms ;)
Base URL
The Base URL (also called the Request URL) is the URL that you need to use to access the API. Look for these terms in the API docs.
Endpoint
The Endpoint is where the data that you want to interact with is located. You add it to the base URL after a forward slash /
.
Query
This is what you want to get. After the endpoint, you’ll see a ?
followed by a lot of key-value pairs, joined with &
.
Now, all these three things together create what in Rows we refer to as the action_url
:
How to know which endpoint you need to access?
Well, that’s up to you 😅. Endpoints are usually grouped according to the data that they interact with and what you can do with it.
If you have a look at the Spotify API:
You’ll see that they group them by data (Playlists), and then provide you with the base URL, along with the endpoints (along with a description with what you can do). So for example, if you wanted to get all the playlists in your account you’d just need to send your request to this URL (with some authentication, of course):
https://api.spotify.com/v1/me/playlists
But if you look at how to get a specific playlist, you'll see some curly brackets {}
? These mean that you need to provide some parameters to the URL. For example, if you wanted to get all the tracks for a playlist:
https://api.spotify.com/v1/playlists/{playlist_id}/tracks
Then you’d need to find out the Spotify ID of the playlist and replace the {}
brackets with that ID. For example:
https://api.spotify.com/v1/playlists/00981234jsadf920lu/tracks
So, now you have all the knowledge you need to start getting data from APIs! Let’s try some out in Rows.
Getting data
You’ll never guess what function you need to use in Rows to get data from any API… it’s called GET()
!
And you already know what you need to put in for the action_url
and headers
parameters.
Hint
In action_url
you would have the base URL, the endpoint you want to use, and possibly your authentication.
In headers
you'd put your authentication (if needed).
Let’s put this all into practice by getting some weather data with OpenWeatherAPI.
OpenWeatherAPI Key
We’ll want to get the current weather for a location, say, Lisbon, Portugal.
- Go to OpenWeatherMap’s API documentation.
In Call current weather data for one location, we can see that we need to add a
city name
and theAPI key
to the query string to get the current weather.API documentation screenshot
In Rows, set up a spreadsheet so that it looks like this:
- Fill in your spreadsheet with the following info:
Cell | Content |
---|---|
A2 | Your API Key |
B2 | Lisbon,Portugal (Or any city,country combination you’d like) |
In cell C2, we'll create the action_url
with Base URL from the documentation while also using cell references to make it dynamic:
- In cell D2, write
=GET(C2)
.
❇️ Boom! Now you'll see a {data} cell - open the Data Explorer and look at the results!
Try playing around with a few other cities and countries 😁.
Up next
OK, so you learned some theory as well as successfully used an API call in Rows to get weather data! That’s pretty amazing, right?
More for Advanced users
Want to learn more? Well then, check the rest of our Advanced Rows series:
- Authenticating your API calls
- Getting data from any API (you're here)
- Sending data to any API: Up next! 🚀
- Modifying JSON
- Filtering with JsonPath
- Managing multiple integrations