A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.
To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).
Validator.nu Web Service Interface: Difference between revisions
(Sample code) |
(GNU now implemented) |
||
Line 29: | Line 29: | ||
* [[Validator.nu XML Output|XML]] (append <code>&out=xml</code> to URL). | * [[Validator.nu XML Output|XML]] (append <code>&out=xml</code> to URL). | ||
* [[Validator.nu JSON Output|JSON]] (append <code>&out=json</code> to URL). | * [[Validator.nu JSON Output|JSON]] (append <code>&out=json</code> to URL). | ||
* Human-readably plain text (append <code>&out=text</code> to URL; should not be assumed to be forward-compatibly stable for machine | * Human-readably plain text (append <code>&out=text</code> to URL; should not be assumed to be forward-compatibly stable for machine parsing—see the next item). | ||
* [[Validator.nu GNU Output|GNU error format]] (append <code>&out=gnu</code> to URL). | |||
===Not Implemented=== | ===Not Implemented=== | ||
* Relaxed-compatible (lacks a spec) | * Relaxed-compatible (lacks a spec) | ||
* Unicorn-compatible (hoping that Unicorn changes instead) | * Unicorn-compatible (hoping that Unicorn changes instead) |
Revision as of 11:43, 22 January 2008
Validator.nu can be called as a Web service. Input and output modes can be chosen completely orthogonally. Responses can be optionally compressed.
(Please use the Web service API reasonably. See the Terms of Service.)
Input Modes
For most Web service use cases, you should probably POST the document as the HTTP entity body.
Implemented
- Document URL as a GET parameter; the service retrieves the document by URL over HTTP or HTTPS.
- Document POSTed as the HTTP entity body; parameters in query string as with GET.
- Document POSTed as a
textarea
value. - Document POSTed as a form-based file upload.
Not Implemented
- Document in a
data:
URI as a GET parameter. application/x-www-form-urlencoded
Output Modes
When using Validator.nu as a Web service back end, the XML and JSON output formats are recommended for forward compatibility. The available JSON tooling probably makes consuming JSON easier. The XML format contains XHTML elaborations that are not available in JSON. Both formats are streaming, but streaming XML parsers are more readily available. XML cannot represent some input strings faithfully.
Implemented
- HTML with microformat-style
class
annotations (default output; should not be assumed to be forward-compatibly stable). - XHTML with microformat-style
class
annotations (append&out=xhtml
to URL; should not be assumed to be forward-compatibly stable). - XML (append
&out=xml
to URL). - JSON (append
&out=json
to URL). - Human-readably plain text (append
&out=text
to URL; should not be assumed to be forward-compatibly stable for machine parsing—see the next item). - GNU error format (append
&out=gnu
to URL).
Not Implemented
- Relaxed-compatible (lacks a spec)
- Unicorn-compatible (hoping that Unicorn changes instead)
- W3C Validator-compatible SOAP (legacy)
- EARL (not implemented; domain modeling mismatch)
Compression
Validator.nu supports HTTP response compression. Please use it. Response compression is orthogonal to the input methods and output formats.
The standard HTTP gzip mechanism is used. To indicated that you prepared to handle gzipped responses, include the Accept-Encoding: gzip
request header. When the header is present, Validator.nu will gzip compress the response. You should also be prepared to receive an uncompressed, though, since in the future it may make sense to turn off compression under heavy CPU load.
HTTP request compression is not supported yet.
Sample Code
There a sample Python program that shows how to deal with compression and redirects. (It may not be exemplary Python, though.)