The ipernity API supports JSON, XML, SOAP, XML-RPC and PHP response formats.
The format of response you choose is directly included in the URL used to call an API method.
http://www.ipernity.com/api/[method]/[format]
The format could be one of the following: json, xml, php.
An API response, regardless of output format, returns the following information:
status : ok or error – in fact anything but "ok" is an error.code : the error code in case of failure.message : the error message.JSON is the response format recommended by ipernity. With JSON, the API returns an object:
{"api" : {"status" : "ok"},
"doc" : {"doc_id" : 1234567,
"title" : "Nice car",
...
}
}
{"api" : {"status" : "ok"},
"docs" : {"page" : 1,
"pages" : 8,
"perpage" : 100,
"total" : 800,
"doc" : [{"doc_id" : 1234567, ... },
{"doc_id" : 1234568, ... },
...
]
}
}
{"api" : {"status" : "error",
"code" : 1,
"message" : "Document not found"}
}
<api status="ok"> <doc doc_id="1234567" ... ></doc> </api>
<api status="ok">
<docs page="1" pages="8" perpage="100" total="800">
<doc doc_id="1234567" ... ></doc>
<doc doc_id="1234568" ... ></doc>
...
</docs>
</api>
<api status="error" code="1" message="Document not found"> </api>
A response in SOAP format uses an XML envelope in a specific format.
<?xml version="1.0" encoding="utf-8" ?>
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<s:Body>
<x:ipernityResponse xmlns:x="urn:ipernity">
[escaped-xml]
</x:ipernityResponse>
</s:Body>
</s:Envelope>
<?xml version="1.0" encoding="utf-8" ?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<s:Fault>
<faultcode>ipernity.error.[error-code]</faultcode>
<faultstring>[error-message]</faultstring>
<faultactor>http://api.ipernity.com.com/api/soap/</faultactor>
<details>
See http://www.ipernity.com/help/api for more details
</details>
</s:Fault>
</s:Body>
</s:Envelope>
A response in SOAP format uses an XML envelope in a specific format but with unescaped XML response. To get this response format, specify the soapxml output format.
<?xml version="1.0" encoding="utf-8" ?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<ipernityResponse xmlns="http://www.ipernity.com/todo#">
[xml]
</ipernityResponse>
</s:Body>
</s:Envelope>
A response in XML-RPC uses an XML envelope in a specific format.
<?xml version="1.0" encoding="utf-8" ?>
<methodResponse>
<params>
<param>
<value>
<string>[escaped-xml]</string>
</value>
</param>
</params>
</methodResponse>
<?xml version="1.0" encoding="utf-8" ?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>[error-code]</int></value>
</member>
<member>
<name>faultString</name>
<value><string>[error-message]</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>