I've built a website that provides search results on legal documents. Among the features of the site is a REST API. Currently when somebody submits a query, the entire page is reloaded and the API is hit server side. I'd like to rebuild the site so that as people tweak search parameters, the results are paged in client-side using AJAX that hits the REST API.
The API requires a login (so that it can be throttled if needed), but using the site in general doesn't.
How can I make it so that people can use the site without logging in, but their use of the site hits the API client side?
The best ideas I currently have are:
Just put a username and password into the site's JavaScript and use them to log into the API when making queries. Give these credentials unthrottled access to the API. This could work, aside from putting credentials into my JavaScript.
Continue doing all API work server-side, foregoing the speed and UX improvements that come from dynamic page reloads.
Doing number 1 sucks and doing number 2 is basically giving up on having the kind of site I want.
Ideas?