An YQL wrapper used to generate a proxy URL to a given resource.
Current version: 1.0.1
Lead Maintainer: Halim Qarroum
npm install --save proxify-url
bower install --save proxify-url
This small component aims to make it possible to issue AJAX requests to third-party resources when it is not possible in normal cases, typically because of CORS or because the remote service does not support JSONP for instance.
The library will generate an URL pointing to the initial resource, but instead of having the browser directly request the remote server for the resource, it will request the Yahoo Query Language API to act as a middle man since it supports
Proxify an url
Simply require the
proxify-url module according to the environment you are in (Node.js, AMD and the browser are supported), and call the returned function with the given URL. An example in the browser would be as follow :
var url = ;
Note that the returned proxy URL will be secured and that by default the output will be a JSON document.
To customize the proxy URL parameters and how the document is returned by the YQL API, you can pass the following options to the
proxify function :
||The format in which the document must be returned. The default value is
||Indicates in what format the YQL API should be parsing the document. The default value is
||YQL transforms all JSON data sources into XML before returning results. During the tranformation from XML to JSON, the original JSON may be altered or become "lossy". In other words, the original JSON may not be the same as the returned JSON. By default, this library disables lossy JSON, but you can pass the boolean
||Indicates to the YQL API that it should return the result of the query as a parameter of a function, in a JSONP manner. The value of the
The below example will ask the YQL API to parse the document as JSON and to output it as an XML document, and to pass it to a function called
var url =;
Since this module is distributed in the form of an UMD (Univeral Module Definition), it might be easy to use it using module loaders such as
require in Node while still keeping the module completely encapsulated.
However, in the context of a browser, the
proxify object name is exported in the global namespace. To prevent it from conflicting with another component exporting an object with the same name, you can use the
.noConflict function as follow.
var proxy = proxify;