Im quite new to the usage of API in web development. Im working on a web application in python/django that makes ajax jsonp requests to the giantbomb api. As I learn how to use this api to get the info want, im beginning to realize certain things should probably be handled better in my code for various efficiency/security reason. But I am unfamiliar with conventions for the usage of web-based API's. Here a few questions ive been thinking about:
thank you for help and patience in advance,
Having your API key visible to the user means they can do requests as you. Whether this is bad or not depends on the API in question. If it is possible to do three-legged auth, your server can negotiate a temporary key (e.g. Oauth's session key) with the API server and only share that temporary key with the browser.
If you intend for the browser to do the API requests via AJAX, your views don't enter into the picture at all, except to pass the API credentials to the browser for use in javascript.
If you are doing three-legged auth, your server would store the API key somewhere permanent (database or file), but the session key could live in a more temporary location (e.g. wherever your session data is stored). But it will still need to be passed to browser, assuming it is doing the actual API requests.