python – How do applications know how return the data an API requested?

Let’s say I have an application that has the below function:

void myFunction(string firstName) {
cout << firstName << ” Refsnesn”;
}

int main() {
myFunction(“Liam”);
myFunction(“Jenny”);
myFunction(“Anja”);
return 0;

Now let’s say I want to have an API call that gets all first names. Do you now have to create a function that traverses a list, array, stack, or whatever object was created to do so? And when they are talking about how APIs don’t reveal how the application works they are talking about for example not revealing that you are using an array vs. stack, or sorting the names in alphabetical order, or something else.