Skip to content

Instantly share code, notes, and snippets.

@martindrapeau
Last active August 29, 2018 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martindrapeau/02decac674ccdfa9f98e0c1352739ae3 to your computer and use it in GitHub Desktop.
Save martindrapeau/02decac674ccdfa9f98e0c1352739ae3 to your computer and use it in GitHub Desktop.
MySkillChart API instructions for Amilia

Amilia API for MySkillChart integration

The Amilia API is located here: http://amiliaapp.github.io/amilia-demo-organization/api-documentation.html. It lists calls that are public. In addition, there is another document which lists calls with authentication required. Those are not yet public and will be sent in a separate PDF.

First off, most calls take as argument the language (en for English in your case) and a "rewrite url" - the id of the organization or customer. For your demo org, it is myskillchart. You'll notice those parts in the signature of the API calls below. I built the examples using your demo account.

The API is always a URL and returns JSON. Authenticated calls require an extra HTTP header. I've gone ahead and used jQuery to code up the calls. You can run those in your browser from your website domain or on the amilia.com domain (we respect CORS).

Fetching the list of active programs

$.get('https://www.amilia.com/PublicApi/myskillchart/en/Programs')

Returns

{
  "Items": [
    {
      "Id": 35006,
      "Name": "Boys",
      "Start": "2018-08-01T00:00:00",
      "End": "2020-08-31T00:00:00",
      "Url": "https://www.amilia.com/store/en/myskillchart/shop/programs/35006",
      "PictureUrl": "https://d44a4f4190a56244f28e-5f78a810e214884e03e314eb55e5dccb.ssl.cf2.rackcdn.com//25e9d1f4-1742-4f32-bfb6-4f52a1154bc1_circus_school4.jpg"
    }
  ],
  "Page": {
    "NextId": null,
    "Next": null
  }
}

Pull out the program id 35006.

Fetching the list of activities in a program

$.get('https://www.amilia.com/PublicApi/myskillchart/en/Programs/35006/Activities')

Returns

{
  "Items": [
    {
      "Id": 1891917,
      "Name": "Boys Beginner Mondays & Tuesdays",
      "Description": null,
      "ResponsibleName": "",
      "Prerequisite": null,
      "Note": null,
      "ThirdPartyUrl": null,
      "ExtraInformation": "",
      "Url": "https://www.amilia.com/store/en/myskillchart/shop/activities/1891917",
      "LegacyLocation": "",
      "Price": 200,
      "Schedule": [
        {
          "StartTime": "18:00:00",
          "EndTime": "19:00:00",
          "StartDate": "2018-09-03T00:00:00",
          "EndDate": null,
          "RecurenceEndDate": "2019-06-24T00:00:00",
          "Occurences": null,
          "Staff": [],
          "Facilities": [],
          "ExceptOccurences": [],
          "Days": [
            "Monday",
            "Tuesday"
          ],
          "DayMask": 6
        }
      ],
      "Age": null,
      "TaxCredit": null,
      "SpotsRemaining": null,
      "SpotsReserved": 1,
      "ShortScheduleString": "On Mondays, Tuesdays from 6:00 PM to 7:00 PM",
      "HasSessionEnabled": true,
      "AgeSummary": "",
      "OrganizationId": 7778,
      "SubCategoryName": "Twice a week",
      "SubCategoryId": 1891916,
      "SubCategoryPosition": 1,
      "Status": "Normal",
      "CategoryName": "Beginner",
      "ProgramName": "Boys",
      "PictureUrl": null
    },
    {
      "Id": 1891918,
      "Name": "Boys Intermediate Wednesdays & Thursdays",
      "Description": null,
      "ResponsibleName": "",
      "Prerequisite": null,
      "Note": null,
      "ThirdPartyUrl": null,
      "ExtraInformation": "",
      "Url": "https://www.amilia.com/store/en/myskillchart/shop/activities/1891918",
      "LegacyLocation": "",
      "Price": 200,
      "Schedule": [
        {
          "StartTime": "18:00:00",
          "EndTime": "19:00:00",
          "StartDate": "2018-09-03T00:00:00",
          "EndDate": null,
          "RecurenceEndDate": "2019-06-24T00:00:00",
          "Occurences": null,
          "Staff": [],
          "Facilities": [],
          "ExceptOccurences": [],
          "Days": [
            "Wednesday",
            "Thursday"
          ],
          "DayMask": 24
        }
      ],
      "Age": null,
      "TaxCredit": null,
      "SpotsRemaining": null,
      "SpotsReserved": 0,
      "ShortScheduleString": "On Wednesdays, Thursdays from 6:00 PM to 7:00 PM",
      "HasSessionEnabled": true,
      "AgeSummary": "",
      "OrganizationId": 7778,
      "SubCategoryName": "Twice a week",
      "SubCategoryId": 1891925,
      "SubCategoryPosition": 2,
      "Status": "Normal",
      "CategoryName": "Intermediate",
      "ProgramName": "Boys",
      "PictureUrl": null
    }
  ],
  "Page": {
    "NextId": null,
    "Next": null
  }
}

Pull out the activity ID 1891917. The next step to fetch participants requires an API token.

Retrieve your API token. It is attached to your administrator credentials.

var username = 'your email';
var password = 'you password';
$.ajax({
  url: AMILIA_URL + 'https://www.amilia.com//PublicApi/en/Authentication/Login',
  type: 'GET',
  dataType: 'json',
  beforeSend: function(xhr) {
    xhr.setRequestHeader('Authorization', 'Basic ' + btoa(username + ':' + password));
  }
});

Returns something like this:

{
  "Token": "eyJ0exxxxxxxxxxxxxxxxxxxxxxxxxxiJ9.exxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxXYkZCQ2dzTXNpTlZVUTYiLCJ1YUlkcyI6WzczNjczNjFdfQ.PlEzq9ahzprp5xlust9eOQEPLEVxxxxxxxxxxxxxyQ"";
}

You can use this token in the following call to fetch attendance

Fetch participants in an activity

var token = 'your API token';
$.ajax({
  url: 'https://www.amilia.com/PublicApi/myskillchart/en/Activities/1891917/Persons',
  dataType: "json",
  beforeSend: function(xhr) {
    xhr.setRequestHeader("Authorization", "Bearer " + token);
  }
});

Returns something like this:

{
  "Items": [
    {
      "Id": 4832528,
      "AmiliaId": "P12113125",
      "FirstName": "Oba",
      "LastName": "Sharkey",
      "Gender": "Male",
      "DateOfBirth": "2014-06-06T04:00:00",
      "Email": null,
      "Address": null,
      "IsArchived": false,
      "GenuinePerson": null
    }
  ],
  "Page": {
    "NextId": null,
    "Next": null
  }
}

The participant information is currently limited to their name, gender and date of birth. We will be adding more information. For example: guardian name, address, phone number and email; participant picture, etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment