Complete the prerequisites
Before you proceed, make sure you have worked through all lessons within the Fundamentals of building with Klaviyo section of the certificate and set up your test environment.
For these exercises, imagine you are working for a company that runs guided trips including hiking tours, wine tours, and sightseeing tours.
Before you begin, please create 3 lists in your test account. The lists should be titled:
- Hiking tours
- Wine tours
- Sightseeing tours
Your task is to use Klaviyo's APIs to determine the number of people who signed up for a wine tour.
Exercise files and solutions will be provided in Napkin.io, but you are welcome to complete them in any IDE.
Clone and set up the Napkin function
Navigate to the Napkin exercises here: https://www.napkin.io/n/4d68a6c0bf984a02
Add this Napkin function into your workspace by clicking Add to Your Functions.
To set up your workspace, add your Klaviyo private API key as an environment variable, which can be found under the Other tab. Detailed instructions can be found here.
Complete the exercises
Instructions for each part of this exercise are given in the comments in the Napkin function. This exercise has three parts:
- Get all lists in the account
- Find the Wine tours list ID
- Get the number of wine tour participants
The following documentation will be helpful as you work through these exercises:
Stuck? Check out these resources
If you get stuck, review our tutorial on getting started with Klaviyo APIs.
If you receive a response that is not in the 200s, check out our guide to rate limits and error handling for guidelines on how to resolve errors within your API call. One common error is a 401 Unauthorized error, which indicates that the authentication is incorrect. To resolve this, ensure that your authorization matches the required format.
You may also wish to make the API call in a tool like Postman to distinguish errors in the API call from errors in the Napkin code.
If you are still stuck, have any questions, or want to share your work, please post in our Developer Group on Klaviyo Community.
Solutions
Solutions can be found in this Napkin function: https://www.napkin.io/n/421bd3041c234bd8