Re: [Apps-Script] Apps Script API Call

54 views
Skip to first unread message
Message has been deleted

Riël Notermans

unread,
Jun 22, 2020, 3:09:37 AM6/22/20
to Google Apps Script Community
You can do:

for (var cityName of obj) {
  var city is obj[cityName];
  
  //and then
  var code = city.code;


};

If you want an array:

var names = Object.keys(obj);

// ["Buenos Aires", "Chicago", "London", "Los Angeles", "..."]

Met vriendelijke groet,

pic
Riël Notermans
Technisch Directeur
logo
phone
email
email
040 711 41 94
ri...@zzapps.nl
www.zzapps.nl


On Mon, Jun 22, 2020 at 1:05 AM Vincent Adipietro <vincent....@gmail.com> wrote:
Hi! I need help setting up a variable to call this API: https://api.chartmetric.com/apidoc/#api-Artist-GetWherePeopleListenInsights

I would typically use "var = finalData.obj.cities[0+I].name" , but in this API Call, the actual city name is after obj, rather than the word "cities." Because the cities are different for each artist (top 5 cities by steams), I'm having a tough time calling this API. I spoke with Chartmetric and here's the response they gave me: 

For Spotify Top Cities, you should be able to iterate over the JSON object to get the different keys. Each key name will then be the city name.  


Screen Shot 2020-06-18 at 10.33.27 AM.png

Any advice is appreciated! I am using Apps Script!

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/526b8a03-2a2d-4fac-9b5e-5116adf7bccfo%40googlegroups.com.

Riël Notermans

unread,
Jun 22, 2020, 3:10:57 AM6/22/20
to Google Apps Script Community
Actually the first example is 'Iterating over the JSON object' ;)

Met vriendelijke groet,

pic
Riël Notermans
Technisch Directeur
logo
phone
email
email
040 711 41 94
ri...@zzapps.nl
www.zzapps.nl

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages