Success response
The return value of an API request is always JSON. Here's an example of what the returned data might look like for a successful API request:
{
"success": true,
"message": "",
"path": "wireframe-api\/components\/Card",
"args": {
"exampleArg": false
},
"data": {
"json": {
"title": "Hello World",
},
"rendered": "<div class=\"card\"><h2>Hello World<\/h2><\/div>",
}
}
In this case the "rendered" property of the "data" object contains whatever Card::render()
returns, while "json" contains whatever Card::renderJSON()
returns. Note that you need to implement this method yourself or Wireframe API will only return null
as the value of the "json" property:
public function renderJSON(): ?string {
return json_encode([
"title" => $this->title,
]);
}
Error response
Here's an example of what an error returned by the API would look like:
{
"success": false,
"message": "Unknown component (Test)",
"path": "wireframe-api\/components\/Test",
"args": {
"exampleArg": false
},
}
Wireframe API attempts to return applicable HTTP status codes with each response, but the (boolean) "success" flag is also provided just in case. "success" is true
if HTTP status code is equal to or greater than 200 and smaller than 300, and for all API errors there's some kind of message indicating what went wrong.