REST API is a method of pulling data in from many different types of websites. If you know that a data source you have has a REST API, using a REST API connection in Grow can be very helpful. This article will give you an idea of what you need to connect to a REST API and show you how to put it into Grow.
Keep in mind that with APIs, you are totally dependent on what info they give you. If it isn't available in the API, you can't get the data, no matter how hard anyone tries.
Each API is different, but there are a couple things you will need almost every time.
- Token or Keys
For our example, we'll say the Awesome Company has a score for how awesome each flavor of ice cream is. You want a metric showing the top ice cream flavors to help you prioritize what flavor to serve next.
First, you'll need an API URL. The API URL tells the website's API what data you want. Each service or website will have documentation on what the URLs look like and what info they can give back to you.
Let's say the AwesomeCo has a URL that returns all the flavors and their scores. It could look like this:
Tokens or Keys
Next, you'll need an API token or key. Each API key is unique to a person's account and often can be updated inside that service's website. It acts like a password---but another level of security for the API above your username and password for that service. The key tells the service's API that you do have authorization to access their data.
You can usually find your API key in your Settings for that service. It is often located on a tab labeled "API" or something similar. If you don't find it on first try, you can always try checking the service's API documentation or sometimes our help center.
Let's say you log in to your AwesomeCo account and find your API key, which is
apikey = 123key321.
So now you have all the info needed to connect to AwesomeCo via their API.
Next, go to Grow and click Add Metric. Select Custom REST API from the list of data sources.
On this page, enter your URL into the URL field.
Underneath that, you'll see a section labeled Headers. In the "Key" field, enter
apikey, then in the "Value" field, enter the key
Click the blue Connect button and let the ice cream data flow. 🍦
API come in a huge variety of types and complexities. Unfortunately, just because a service has an 'REST API' it doesn't mean that Grow will be able to connect to it. However, we are always willing to try and help you figure it out.
If you want to see another example of how to use a REST API, check out this article here.
Questions about REST API? Feel free to email email@example.com or chat in on the site and we'll be happy to help.