api.xep.com is a web service. It accepts formatting requests via HTTP REST interface. The service formats submitted XML documents with the RenderX XEP engine and replies with XML response which contains a formatting log and a link from which the formatted PDF document can be downloaded.
You can use REST API to interact programmatically with this service. api.xep.com API provides access to the formatting service via URI paths. To use a REST API, your application will make an HTTP request and parse the response. The response format is XML. Your method will be the standard HTTP POST method. You can send either standalone XSL-FO files ("xml" field) or XML file with its stylesheet ("xml" and "xsl" fields).
If you're constructing the POST query manually, it should look something like this. All line endings must be \r\n.
POST /format/ HTTP/1.1 Content-Type: multipart/form-data; boundary=--275f257ff6ad4bd5815d266dcb1fc5d5 Host: api.xep.com Content-Length: 35261 --275f257ff6ad4bd5815d266dcb1fc5d5 Content-Disposition: form-data; name="xml"; filename="hammer.xml" Content-Type: text/plain; charset=utf-8 {RAW XML DATA} --275f257ff6ad4bd5815d266dcb1fc5d5 Content-Disposition: form-data; name="image1"; filename="nail.jpg" Content-Type: text/plain; charset=utf-8 {RAW IMAGE DATA} --275f257ff6ad4bd5815d266dcb1fc5d5 Content-Disposition: form-data; name="xsl"; filename="hammer.xsl" Content-Type: text/plain; charset=utf-8 {RAW XSL DATA} --275f257ff6ad4bd5815d266dcb1fc5d5--
The multipart boundary should be randomly generated and should not occur anywhere inside the payload data. Also, don't forget the line ending after your {RAW * DATA} and before the final boundary.
If your formatting request is successful then the response should look something like this.
<?xml version="1.0" encoding="utf-8"?> <response> <document>http://api.xep.com/document/729310ed-1169-4f7c-a7cd-1ec0a68958a0/</document> <log> waiting for files shakehand ok event system-id //color.fo openState validate event validation OK closeState validate openState compile openState masters openState sequence-master event master-name all-pages closeState sequence-master closeState masters openState sequence event master-reference all-pages openState static-content event flow-name xsl-region-before closeState static-content openState static-content event flow-name xsl-region-after closeState static-content openState static-content event flow-name xsl-footnote-separator closeState static-content openState flow event flow-name xsl-region-body closeState flow closeState sequence closeState compile openState format openState sequence event master-reference all-pages openState flow event page-number 1 event page-number 2 closeState flow openState static-content event page-number 1 event region-name xsl-region-after event region-name xsl-region-before event page-number 2 event region-name xsl-region-after event region-name xsl-region-before closeState static-content closeState sequence closeState format openState generate event output-format pdf event page-number 1 event page-number 2 closeState generate </log> <processing-time>0.137093</processing-time> </response>
If you call the service anonymously your formatted documents will be accessible to download without protection. The service doesn't reveal links of documents. They are only sent to the client and known only by the client. Links are randomly generated and hard to predict.
The service uses HTTP Basic Authentication to distinguish anonymous formatting requests from authorized ones. To enable the authentication clients should create an account and send requests with HTTP Basic Auth. If the client sends formatting request with enabled authentication then the formatted document will be only accessible to authenticated client.
For more information on how to send requests with basic access authentication check out the documentation of your programming language.
You can also use the cURL command line tool for submitting formatting requests to the service. In that case cURL acts as a client and you don't need to write your own program. Below you can see several examples which demonstrate the most common usages. You can turn on tracing to find out the underling request format which is required when interacting with the service.
Formatting standalone XSL-FO file:
curl -F "xml=@color.fo;type=application/xml" http://api.xep.com/format/
Formatting XSL-FO file with images:
curl -F "xml=@bgimage.fo;type=application/xml" -F "image1=@spots.jpg;type=image/jpeg" http://api.xep.com/format/
Formatting XML file with XSLT stylesheet:
curl -F "xml=@hammer.xsl;type=application/xml" -F "xsl=@hammer.xsl;type=application/xml" http://api.xep.com/format/