Use cases
Different use cases for our API v3 are described below, starting with the simplest one. A tag indicates whether the use case is relevant to an organization or a partner.
Getting the activities in a program
Context
Marc is an admin in an organization called Loyola Gym and he wants to find if a specific program at Loyola Gym has fitness activities.
Building the Amilia API integration
Authenticate the user in the API
First you need to authenticate.
https://app.amilia.com/api/V3/authenticate
The response will contain a token which you will need for all the following calls:
Get all programs for an organization
You will need the organization id, which is the rewriteUrl you set in your Amilia account under Options. Say the organization id here is loyola-gym.
https://app.amilia.com/api/V3/en/org/loyola-gym/programs
This will return the programs for Loyola Gym:
Get a program's activities
Say you found the first returned program has id 65111. Send the request below to get its activities.
https://app.amilia.com/api/V3/en/programs/65111/activities
You will get a response with all the activities in the program, where you can check the name of the activities to see if it's related to fitness.
Getting participants for all occurrences of a program [Organization]
Context
Joanne is the director in the Forest Explorers day camp for 8-11 year olds. Each day at Forest Explorers is divided in half, with the morning spent on an activity and the afternoon spent on another one. For a given half-day each participant picks one of two possible activities, for instance Canoe vs Responsible Marshmallow Roasting.
Joanne wants to get the list of participants in each of the activities in the Summer 2019 program in order to count them and therefore evaluate the popularity of each activity. This will help her decide which ones will be reconducted next year. The camp typically receives five participants each day. If an activity has fewer than two participants, she will not reconduct it.
For example, she noticed the Responsible Marshmallow Roasting activity did not get any participant while Canoe, which happened at the same time, got three participants, so the Responsible Marshmallow Roasting activity will not happen next year.
Building the Amilia API integration
Authenticate the user in the API
First you need to authenticate.
https://app.amilia.com/api/V3/authenticate
The response will contain a token which you will need for all the following calls.
Get all programs
You will need the organization id, which is the rewriteUrl you set in your Amilia account under Options. Say the organization id is forest-explorers. Get the list of programs by entering this request:
https://app.amilia.com/api/V3/en/org/forest-explorers/programs
The response will look like:
Note that the organization id can also be a number. You will see it in some responses.
Get activities for a program
Find the program id for Summer 2019. Say it is 777000. Enter the following request:
https://app.amilia.com/api/V3/en/org/forest-explorers/
programs/777000/activities
The request will have activity ids which will be used in the following steps. Say we look at Canoe and it has activity id 343434.
Get persons in an activity
Using the previous activity id, enter this request:
https://app.amilia.com/api/V3/en/org/forest-explorers/
activities/343434/persons
The response will be a list of participants. If the response is paginated, you will get the number of participants from the Paging TotalCount at the bottom. Here the response is shown without contacts or skills for visual simplicity. We can see that the Canoe activity has three participants: Catherine, Anna and Emma.
Repeat for all other activities in the program
And count the number of participants in each activity.
Say we look at Responsible Marshmallow Roasting:
https://app.amilia.com/api/V3/en/org/forest-explorers/
activities/343477/persons
We get an empty response:
The response returned empty because there were no participants in the activity. Joanne can then decide not to reconduct Responsible Marshmallow Roasting the following year.
Getting expired memberships
Context
Celine is an admin in an organization called Yoga Central and she wants to find expired memberships. She wants to contact the persons who purchased them in order to suggest a renewal of their membership.
Building the Amilia API integration
Authenticate the user in the API
First you need to authenticate.
https://app.amilia.com/api/V3/authenticate
The response will contain a token which you will need for all the following calls:
Get all memberships for an organization
You will need the organization id, which is the rewriteUrl you set in your Amilia account under Options. Say the organization id here is yoga-central.
https://app.amilia.com/api/V3/en/org/yoga-central/memberships
This will return the memberships for Yoga Central:
Get a membership
Say you found the first returned membership has id 8421. Send the request below to get the persons in that membership:
https://app.amilia.com/api/V3/en/org/yoga-central/memberships/8421/persons?status=Expired
You will get a response with all the persons with that expired membership.
Repeat for other memberships
Repeat the last step for all the organization's memberships.
Getting all standup paddling activities along the Montreal southern coast
Context
Florence wants to build an application to find all the standup paddling (SUP) activities and their occurrences within a perimeter surrounding the south side of the Montreal coast.
Building the Amilia API integration
Authenticate the user in the API
First you need to authenticate.
https://app.amilia.com/api/V3/authenticate
The response will contain a token which you will need for all the following calls.
Make a list of geographical points encompassing the area.
This is done outside of our API. Say the area under consideration for the SUP-finding app is a polygon encompassing the following points, starting from the westernmost one and going clockwise:
- the Honore-Mercier bridge in Lasalle (45.41298, -73.65284)
- Hochelaga (45.53647, -73.54251)
- the St. Lawrence River in front of Hochelaga (45.53647, -73.52947)
- between the South Shore and St. Helen Island (45.48655, -73.51419)
- the St. Lawrence River in front of La Prairie (45.41707, -73.51848)
- another point in Lasalle slightly more to the South (45.40864, -73.63281)
Get keywords
SUP is related to a keyword. Enter this request to get the list of keywords:
https://app.amilia.com/api/v3/en/keywords
In the response we have a keyword for 'Surf SUP' and it is 248, so 248 will be used as the keyword id from now on.
Get locations
For this you will need to do a search by polygon with the above geographical points and the keyword id.
https://app.amilia.com/api/v3/en/locations?type=Polygon &coordinates=45.41298,-73.65284,45.53647,-73.54251,
45.53647,-73.52947,45.48655,-73.51419,
45.41707,-73.51848,45.40864,-73.63281 &keywordId=248
This will return a list of locations where SUP happens. You will need the location ids for the next call.
Get activities by location
Say one of the location ids is 821128. Enter this request:
https://app.amilia.com/api/v3/en/locations/821128/
activities?keywordId=248
You will get the SUP activities. You will need their id for the next request.
Get an activity's occurrences
Using the first returned activity id, 121212, enter this request to get its occurrences:
https://app.amilia.com/api/V3/en/activities/
121212/occurrences
The response will be:
Repeat for the other activities in that location and then for the other locations
Repeat the occurrence step for all activities, and then repeat the activities and occurrences steps for all locations.