I and a friend are building an API with a web front end. The web utilizes the API via Ajax requests to interact with the back-end. We would like to offer limited access to the API for people not using the website (you must pay a fee to use the API), but full unlimited access to anyone on the website.
Now the problem: We are struggling to identify which API call comes from where. Since the website uses JavaScript for the calls, the request appears to come from the user's IP. We thought about using unique tokens for each call or signing the calls, but JavaScript would expose the methods and keys used in both cases.
We are emphasizing on security, so we are searching for a robust solution.
Thanks in advance!