Lostsoul
Lostsoul

Reputation: 26057

Is it a bad idea to have a web browser query another api instead of my site providing it?

Here's my issue. I have a site that provides some investing services, I pay for end of day data which is all I really need for my service but I feel its a bit odd when people check in during the day and it only displays yesterdays closing price. End of day is fine for my analytics but I want to display delayed quotes on my site.

According to the yahoo's YQL faq: If you use IP based authentication then you are limited to 1000 calls/day/IP, if my site grows I may exceed that but I was thinking of trying to push this request to the people browsing my site themselves since its extremely unlikely that the same IP will visit my site 1,000 times a day(my site itself has no use for this info). I would call a url from their browser, then parse the results so I can allow them to view it in the format of the sites template.

I'm new to web development so I'm wondering is it a common practice or a bad idea to have the users browser make the api call themselves?

Upvotes: 0

Views: 74

Answers (1)

Jos
Jos

Reputation: 420

It is not a bad idea at all:

  • You stretch up limitations this way;
  • Your server will respond faster (since it does not have to contact the api);
  • Your page will load faster because the initial response is smaller;
  • You can load the remaining data from the api in async manner while your UI is already responsive.

Generally speaking it is a great idea to talk with api's from the client. It's more dynamic, you spread traffic, more responsiveness etc...

The biggest downside I can think of is depending on the availability of other services. On the other hand your server(s) will be stressed less because of spreading the traffic.

Hope this helped a bit! Cheers!

Upvotes: 1

Related Questions