Some changes I think the API might benefit from:
Upper cap on API usage should be replaced with Rate Limits. Assign a higher rate rimit for resource-intensive API endpoints... so that people don't spam that endpoint. The current system is actually as bad as having no limits. The quotas are already high enough after buying a cheap VIP in-game. What if I concurrently try to access nations API from 1000 different threads/processes. It's much easier to do that than it looks like especially since there is a free tier in AWS and Google Cloud >_> This should actually result in much needed reduced API usage for the server imo.
After the extended deletion rule changes Alex made, the API has started to bloat with unnecessary objects in Nations, All-Cities, and Nation-Military API.
Some stats to prove that:
Total nations in the API: 13813
Total nations active in last 45 days: 6732
Total nations that should have been deleted previously (above 45 days inactivity): 7081
Total nations inactive above 90 days (in automated VM): 4668
The extra 7081 nations have slowed down Nations API endpoint by almost half. It used to take me almost 25s to fetch the Nations API earlier this year... it's now around 50s. (can be different according to internet speeds... point to be noted is that it has slowed down). At least those 4668 nation objects do not need to be present in the API. Same applies for the All-Cities and Nation-Military API.
Either change how the game handles automated VMs (preferred) or just exclude them from the API.
Fetching the status of Powered key of a nation city atm means, getting all the city ids, either through All-Cities or Nation API and then parsing through each city separately. Now, this looks ok for smaller sheets and such, but when the sheet/bot/code is dealing with 100+ nations, it means on an average calling the API 8 times for each of those 100+ nations. (if 8 is the average cities). The number shoots into thousands easily. Checking City power is a very important factor for categorizing "profitable" and active nations imo. It makes sense to add a powered key either into All-Cities API (preferred) or the Nation/Nations API (like the number of powered cities I guess). This will again reduce load since I'll be not calling your City endpoint thousands of times.
War-Attacks API is buggy (numbers are not accurate) and has pretty much fricked up design. I cannot comment on it cause I never used it because of its weird design. I ask more experienced developers to please tell Alex on how to improve this one. It's not useless atm, but it's buggy and more poorly designed relative to Alex's other API endpoints.
@Alexplease read this: http://php.net/manual/en/language.types.intro.php. I am amazed at your API's data types.
Idk how your backend behaves but I think large API results should be cached by your server (if it's not being done already). I am quite ready to lose a few minutes of updated data in return for a faster API response time. I don't need to know if a trade was done 1 minute ago as long as I am getting the data within 10-15 minutes.
Reason for this change: "Real Time" large API responses are usually more structured (paginated) than your API. I don't expect you to do that so instead lose the real time for a few minutes delay. Fetch data in the backend every 15min or so and just dump that JSON whenever someone accesses that endpoint (this is specifically for Nations, All-Cities, Nation-Military, Trade-History.... the larger ones). This is more of personal opinion without any numbers to back whether it will be faster or not and I am sure people will disagree with it and I'll be glad to read why not.
I'll keep editing, adding suggestions here. Meanwhile feel free to add more suggestions here or correct the ones suggested.