GET Request overview:

In this section we will learn how to retrieve data from an outside codebase.

For our example, lets retrieve some data make using a GET request.

The most important part of this panel is the "URL Endpoint" textbox. This is the location where our external API is and this is the link where we will be sending and fetching data from.

For our example, we'll use this handy example API.

https://reqres.in/

This is the endpoint we'll be using for our example:

https://reqres.in/api/users/2

The above block of code is what this API will give us when we call on this endpoint. We don't need to worry too much the specifics of what we are looking at, just know that the left side of the colon in each row is the name of our data, and the right side is our data.

To clarify further:

In the first row, 

"id" : 2,

"id" is the name of what we want to call and 2 is the data that it holds.

We're going to take the title from the above and put it into one of our variables for use within our project.

In order to do that, we'll use a variable called Title that we have defined in the variables tab. 

In order to access the data in the response, we will map "response.data.title" to fill in the title variable.

We're making Alexa say the title in the following speak block, and if we have had a success, it should be displaying correctly.



Success!


We've just learned how to use the most common use of the API block, fetching data from another API. Head over to one of our other tutorials to see how the other requests work!


Other resources:

Check out our tutorials on POST, PUT and DELETE requests

Still have questions? Did we miss something? Have a suggestion? 

Did this answer your question?