How to get a category name with the ID via API

You should probably save the data in a global, so you can call the function multiple times in the same PHP script.