Help

Available Formats

Since we only proxy XML or JSON documents, we will only return XML or JSON responses to you. If the origin API returns data in another format, you will receive an “Invalid JSON” error message.

When you proxy a resource, you may enable the “Convert to JSON” post-processing option. This will ensure that all API data is converted to JSON before it is returned to you, regardless of whether it originated as XML or JSON.

Changes to Responses

If the original source is XML, we will return the original response body and “Content-Type” header unchanged. If the “Convert to JSON” post-processing option is enabled, or the original source is in JSON, we will parse the JSON (returning the “Invalid JSON” error if it’s invalid), and the response body will not necessarily be the same as original source (for example, new lines or whitespace may be removed). When we return JSON, the “Content-Type” header will always be returned as application/json, regardless of what the original source had for “Content-Type”.

Other than an XML document’s “Content-Type” header, we won’t pass on any other response headers from the originating API. We do provide “Cache-Control” and “Expires” headers to help you determine when a proxied resource’s cached will expire (see “Using Your Resource” below). Also, the “Content-Length” header tells you how many characters are in the response body.

Example

To use the Yahoo Weather API as an example, which returns XML, here are the headers returned by Yahoo:

$ curl -I http://weather.yahooapis.com/forecastrss?w=2463583
HTTP/1.1 200 OK
Date: Sat, 10 Aug 2013 18:30:09 GMT
P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
Cache-Control: max-age=200, public
Vary: Accept-Encoding
Content-Type: text/xml;charset=UTF-8
Age: 0
Connection: keep-alive
Server: YTS/1.20.13

And here are the headers returned by the Proxy:

$ curl -I -H "Api-Key: 14a2f4f3-4169-496e-a732-1fad06b9c34f" http://proxy.storyteller.io/username/yahoo-weather/forecastrss?w=2463583
HTTP/1.1 200 OK
Content-Type: text/xml;charset=utf-8
Vary: Accept
Cache-Control: max-age=265
Expires: Sat, 10 Aug 2013 18:22:38 UTC
Content-Length: 2800
Date: Sat, 10 Aug 2013 18:18:12 GMT

If this resource was set to convert from XML to JSON, the only difference would be “Content-Type” set to application/json (and the “Content-Length” would be different).