I am off and running on scripting calls to API.
I am looking for help from anyone on the following questions, though (and forgive my ignorance if I misuse terms):
I am playing around with getting data.
I would like a list of courses with their term_id and number of students enrolled.
I make the call to this endpoint (with these parameters)
then parse the response to get the termid
then crank it into a csv file with the other course info (one line per course).
My script (attached) works, I just need answers to a few questions to get it to work better
1. I just played around with the "nested" JSON objects until I ferreted out the termid. (again, sorry, don't know the parlance - Inside the course JSON object , "term" : is a braced comma-separated list of its own parameters...)
Is there a better / easier way to get to these "second level" ids, names, etc than how I did it above?
Here is the course response and what I wanted
2. If I set the per_page as above (100), then the term_id only updates in my csv every 100 lines based on the first termid in that call. I think I probably need to move my script around a bit, but I have tried to no avail. If I change the per_page to =1, then it works (as it is updated every call again, but this time there is only one course per call).
This, of course is slow.
Attached is my script ( from the course, site and token redacted, annotated by me, so forgive me if I misunderstood the purpose of stuff).
Thanks for any thoughts!