You are currently viewing What is the best way to handle a single endpoint API where all requests are a POST?

What is the best way to handle a single endpoint API where all requests are a POST?

I have to consume an API where all request go to a single endpoint: api.mydomain.com/v1

v1 only has an index.php that data is POST’ed to. There is no GET, POST, PATCH etc.. or response codes everything is 200 success.

The “noun, verb” combo is in the payload posted to the index.php page.

{

"Authentication" : { "SessionID" : "1234567890", "AuthKey" : "1234567890asdfghjkl" }, "Operation" : { "Noun" : "SomeNoun", "Verb" : "AVerb" }, "Data" : { // This can be anything key/value object. // Just depends on what data I need to pass. } 

}

All responses come in the form of:

{

"MyCompanyResponse" : { "Data" : { // This can be any number of key/value object and is the meat of what I want } } 

}

Where there is a root level object called “MyCompanyResponse” that has another child object “Data”, that will contain the actual data I am after.

What is the best way to handle this type of scenario?

submitted by /u/Windmarble
[link] [comments]