> stdout Tradier Developer Blog

Tradier APIs Now Support CORS

Posted on 15 May 2014 by Jason Barry | Announcement

If you have ever tried to make an AJAX request to another site, you have probably seen an error message like this:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://example.com' is therefore not allowed access.

The Access-Control-Allow-Origin header is a part of a specification called Cross-Origin Resource Sharing, or CORS. The CORS specification allows the browser to make requests from the browser to sites other than the origin. There are a lot of great resources on how to use CORS, I’ve linked to handful at the bottom of this post.

We recently had a customer ask if the Tradier API could support CORS requests. Without question, it makes developing web applications much easier (and potentially faster) as it reduces the need for backend servers to proxy requests.

With our recent release, Tradier now fully supports the CORS specification. All REST-based API requests can be made following cross-origin request standards.

Here is a quick example using jQuery, courtesy of Steve Agalloco:

$.ajax({
  url: 'https://staging.api.tradier.com/v1/markets/quotes?symbols=APIS',
  headers: {
    'Authorization' : 'Bearer YOUR_ACCESS_TOKEN',
    'Accept' : 'application/json'
  }
}).done(function(data) {
  console.log(data);
});

Happy Developing!

Additional CORS Resources:

Note: OAuth APIs don’t support CORS requests for security purposes. Access tokens should be handled carefully in the browser.

comments powered by Disqus
Tradier Inc.
  • 11016 Rushmore Drive, Suite 350
  • Charlotte, NC 28277
  • Phone: 980.272.3670
  • Email: hello@tradier.com