API Call with Changing Key

Hello all!

I’m trying to show the team lineups on my page, however the result of the API is too complicated to be parsed for me.

I’ve highlighted the dynamic key below: “Newcastle United” in this case is specific for API/lineup/2; and it’ll change for API/lineup/3… I’m trying to have pages to show the lineups dynamically (if you’ve picked 4 from the previous page or dropdown, I want to show the results of API/lineup/4). Unfortunately, when I’m picking the API results as a source for my repeating group, I couldn’t find a way to say 1st element of Lineups but I have to specifically select “Newcastle United”; however this won’t let me work programatically, thus I cannot create a page for any lineup.

Do you think I’m looking for the impossible, or would you have any workaround suggestions? Maybe a better way to hook up the API? (I really hope this is a newbie question and there’s an easy solution that I’m missing!)

Thanks in advance!
Bounty: I’ll buy a beer whoever solves this problem first! If you’re not close proximity, I’ll venmo/paypal you! Don’t like beer? Have a cup of coffee, on me.

API:

Result:
{
“api”: {
“results”: 2,
“lineUps”: {
Newcastle United”: {
“formation”: “4-4-1-1”,
“startXI”: [
{
“number”: 12,
“player”: “Martin Dúbravka”
},
{
“number”: 22,
“player”: “DeAndre Yedlin”
},
{
“number”: 6,
“player”: “Jamaal Lascelles”
},
{
“number”: 2,
“player”: “Ciaran Clark”
},
{
“number”: 3,
“player”: “Paul Dummett”
},
{
“number”: 11,
“player”: “Matt Ritchie”
},
{
“number”: 8,
“player”: “Jonjo Shelvey”
},
{
“number”: 10,
“player”: “Mohamed Diamé”
},
{
“number”: 15,
“player”: “Kenedy”
},
{
“number”: 17,
“player”: “Ayoze Pérez”
},
{
“number”: 21,
“player”: “Joselu”
}
],
“substitutes”: [
{
“number”: 26,
“player”: “Karl Darlow”
},
{
“number”: 5,
“player”: “Fabian Schär”
},
{
“number”: 19,
“player”: “Javier Manquillo”
},
{
“number”: 30,
“player”: “Christian Atsu”
},
{
“number”: 4,
“player”: “Sung-Yueng Ki”
},
{
“number”: 9,
“player”: “Salomón Rondón”
},
{
“number”: 13,
“player”: “Yoshinori Muto”
}
]
},
Tottenham Hotspur”: {
“formation”: “4-3-2-1”,
“startXI”: [
{
“number”: 1,
“player”: “Hugo Lloris”
},
{
“number”: 24,
“player”: “Serge Aurier”
},
{
“number”: 6,
“player”: “Davinson Sánchez”
},
{
“number”: 5,
“player”: “Jan Vertonghen”
},
{
“number”: 33,
“player”: “Ben Davies”
},
{
“number”: 17,
“player”: “Moussa Sissoko”
},
{
“number”: 15,
“player”: “Eric Dier”
},
{
“number”: 20,
“player”: “Dele Alli”
},
{
“number”: 27,
“player”: “Lucas Moura”
},
{
“number”: 23,
“player”: “Christian Eriksen”
},
{
“number”: 10,
“player”: “Harry Kane”
}
],
“substitutes”: [
{
“number”: 13,
“player”: “Michel Vorm”
},
{
“number”: 16,
“player”: “Kyle Walker-Peters”
},
{
“number”: 4,
“player”: “Toby Alderweireld”
},
{
“number”: 7,
“player”: “Heung-Min Son”
},
{
“number”: 19,
“player”: “Mousa Dembélé”
},
{
“number”: 40,
“player”: “Luke Amos”
},
{
“number”: 18,
“player”: “Fernando Llorente”
}
]
}
},

Annotation%202019-06-20%20215721

We dont see your api setting, but you can add dynamic value by putting them between [] in connector like …lineups/[id]

1 Like

Thanks @Jici I already have the ID as a variable, but what returns from the API requires me to pick “'s api lineUps Sporting Kansas City startXI” and Sporting Kansas City is another variable that changes with the teams of the API return. And I cannot find a way to always match the first team startXI and then seconds team XI.

Oh I see what you mean now. This is a bad design from their API.

Maybe you can request them to update that to be hometeam and awayteam instead of team name

The only way I see to fix that (and it doesn’t make sense), is to create the payload manually and add all possible team in API connector.

Another way, but this time you need to use javascript or json plugin, is to get the raw data (instead of selecting json, you select text) and decode it.

@Jici just did! Let’s see if they can refactor it for me. Meanwhile, I’ll try to use the raw data and see what I can do with it.

1 Like