Session Description

This session will give a brief intro to Aeries APIs, ways of integrating the API responses in Power BI, manipulating the datasets, establishing relationships between data tables, and the importance of this to having a dynamic report.


Session Content

Get Data

  • From Web (API) - offers live connections to the database allowing for automated data refresh
    • Basic: Allows the user to request data table from a URL
    • Advanced: Allows user to add headers to the web request
  • From Files (JSON, Text/CSV) - offers easier access to larger amounts of data at the expense of real-time access to it
    • Useful when multiple API requests need to be sent to obtain all information for the district
      • Example is having to send a request for each school code in the following endpoint:
        https://demo.aeries.net/aeries/api/v5/schools/{SchoolCode}/students
    • Watch session 1008 (Posh-AeriesApi) to learn how to write a JSON file from multiple API responses

Views

  • Power Query Editor
    • Transform data
    • Change data types
    • Filtering columns
    • Handle duplicates and null values
    • Custom columns
  • Report View
    • Build your interactive dashboards
    • Visuals
    • Slicers
  • Data View
    • View data tables
    • Create new measures
    • Change formatting and properties
    • Data groups
  • Relationship View
    • Build data schema
    • Establish / edit relationships

Code Examples


Python example for pulling attendance data for a list of schools:

import asyncio
import aiohttp
import os
import json

# Setting up variables
# Create environment variable named AERIES-CERT, save your API key there
# Change url variable to your instance of Aeries and desired endpoint
# Change school codes to reflect your school district school codes
api_key = os.environ.get('AERIES-CERT')
url = 'https://demo.aeries.net/aeries/api/v5/schools/{}/Attendance'
school_codes = [0, 884, 894, 900, 901, 902, 903, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999]
headers = {
        "Accept": "application/json",
        "AERIES-CERT": api_key 
     }

results = []

async def get_data():
    async with aiohttp.ClientSession() as session:
        tasks = [session.get(url.format(school), headers=headers, ssl=False) for school in school_codes]
        responses = await asyncio.gather(*tasks)
        for response in responses:
             results.append(await response.json())
        return results

# You may change the variable name as necessary to reflect the data retrieved
# Be sure to also change in line 37 json.dump()
# Run next line if getting RuntimeError: Event loop is closed
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
attendance = asyncio.run(get_data())

# Writes to a JSON file in the same directory
# You may change the name of the file as necessary to reflect the data retrieved
with open('attendance2.json', 'w') as f:
    json.dump(attendance, f)

print('Saved')


Related Documentation