|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +get_school_info.py |
| 4 | +
|
| 5 | +A self-contained script to fetch school metadata (School ID 994) from the Aeries demo API. |
| 6 | +Replace the placeholder values below with your actual Aeries instance URL and API certificate. |
| 7 | +""" |
| 8 | + |
1 | 9 | import requests |
2 | | -import json |
3 | | -API_HOST = "https://demo.aeries.net/aeries/admin/api/v3/schools/520/students/grade/11" |
4 | | -requestHeaders = {"formatType":"application/json", \ |
5 | | - "AERIES-CERT":"insert cert key here"} |
6 | 10 |
|
7 | | -def reqpull(): |
| 11 | +# ─── CONFIGURATION ────────────────────────────────────────────────────────────── |
| 12 | + |
| 13 | +# Base URL for your Aeries instance (no trailing slash) |
| 14 | +AERIES_BASE = "https://demo.aeries.net/aeries" |
| 15 | + |
| 16 | +# Your 32-character Aeries API certificate (case-sensitive) |
| 17 | +API_KEY = "477abe9e7d27439681d62f4e0de1f5e1" |
| 18 | + |
| 19 | +# The school ID you wish to fetch |
| 20 | +SCHOOL_ID = "994" |
| 21 | + |
| 22 | +# ─── END CONFIGURATION ────────────────────────────────────────────────────────── |
| 23 | + |
| 24 | +def get_school_info(base_url: str, cert: str, school_id: str) -> None: |
8 | 25 | """ |
9 | | - DEMO API: 477abe9e7d27439681d62f4e0de1f5e1 |
10 | | - DOCUMENTATION: https://support.aeries.com/support/solutions/articles/14000077926-aeries-api-full-documentation#aeries-api-h5 |
11 | | - :return: |
| 26 | + Fetches and prints metadata for the given school ID. |
12 | 27 | """ |
13 | | - request = requests.get(API_HOST, headers = requestHeaders) |
14 | | - r1= request.json() |
15 | | - |
16 | | - q=[] |
17 | | - a=[] |
18 | | - for q in r1: |
19 | | - a.append(q['PermanentID']) |
20 | | - print("The Permenant ID's for this grade level are") |
21 | | - print(a) |
22 | | - #if you want just the perm ID's delete below |
23 | | - for i in a: |
24 | | - API_HOST1 = "https://delnorte.asp.aeries.net/admin/api/v3/schools/520/Transcript/"+x |
25 | | - requestHeaders1={"formatType":"application/json", \ |
26 | | - "AERIES-CERT":"insert vert key here"} |
27 | | - request1 = requests.get(API_HOST1, headers = requestHeaders1) |
28 | | - r2= request1.json() |
29 | | - print("Printing each transcript may take a while so i am going to make it better") |
30 | | - print(r2) |
31 | | - |
32 | | - |
| 28 | + url = f"{base_url}/api/v5/schools/{school_id}/gpas" |
| 29 | + headers = { |
| 30 | + "AERIES-CERT": cert, |
| 31 | + "Accept": "application/json" |
| 32 | + } |
| 33 | + |
| 34 | + response = requests.get(url, headers=headers) |
| 35 | + if response.status_code == 200: |
| 36 | + school_data_list = response.json() |
| 37 | + if isinstance(school_data_list, list) and school_data_list: |
| 38 | + school_data = school_data_list[0] # Take the first item as a dictionary |
| 39 | + print("School Information:") |
| 40 | + for key, value in school_data.items(): |
| 41 | + print(f" {key}: {value}") |
| 42 | + else: |
| 43 | + print("No school data found.") |
| 44 | + print("Number of Students found:", len(school_data_list)) |
| 45 | + else: |
| 46 | + print(f"Error {response.status_code}: {response.text}") |
| 47 | + |
| 48 | +if __name__ == "__main__": |
| 49 | + get_school_info(AERIES_BASE, API_KEY, SCHOOL_ID) |
0 commit comments