I am in the planning and early coding stages of writing my first full-fledged API for a large scale we application. I have used several APIs over the years but this is the first time I have been asked to construct something that will allow programmatic interaction on this level.
I have done quite a bit of research looking for best practices and such and have identified what I THINK will offer a fairly flexible response communication system.
My questions are:
Is this what you expect to see as API interaction?
Did I miss anything important?
Explanation of API:
I am going to be using HTTP Type 1 protocol for communication and a unique API key for authentication.
I am expecting this to come through CURL requests over an SSL connection.
Example of Successful (200 OK) XML Response (rate limit request):
<?xml version="1.0" encoding="UTF-8"?>
<node>
<short_message>Request Complete</short_message>
<long_message>Rate Limit Status Response</long_message>
<response_data>
<rate_limit>40</rate_limit>
<rate_used>31</rate_used>
</response_data>
</node>
Example of Failed XML Response (Will be sent under appropriate 400/500 Header);
<?xml version="1.0" encoding="UTF-8"?>
<node>
<error_code>1201</error_code>
<short_message>API Error</short_message>
<long_message>The requested API version (1.5) is invalid</long_message>
</node>
Additionally I am setting up the error codes to be used in search-able documentation for easing the migraines of other developers. Pass/Fail of request will be given through appropriate HTTP codes--Success (200), bad requests (400), method not found (404), authentication failed (403), etc...
I am also using version based endpoints so that any code changes will not require external code changes.
Finally devs will be able to request all responses in either XML, JSON, or PHP serialized arrays.
The internals of my code are very simple. All data is passed through POST (probably using CURL or some alternative) including a unique API key. That API key is linked to a user in the system which will then allow the internal methods to execute a limited set of functions that are enabled for that specific user.
I am following the API 'Golden Rule'--"Always add, never delete".
So.. what else should I consider and what have I missed?