SuggestGrid JavaScript Clients
SuggestGrid has JavaScript clients that can be used by any web browser, RequireJS, Node.js, CommonJS, jQuery, and EcmaScript 6 module systems. These are frontend clients.
Note that SuggestGrid Node.js Client is available for JavaScript backends. In addition, SuggestGrid REST API is the most basic choice.
API
Only the API methods that can be accessed by public keys are available in SuggestGrid JavaScript clients. These methods are single action post, recommendation, and similarity methods:
-
postAction
-
recommendItems
-
recommendUsers
-
getSimilarItems
-
getSimilarUsers
All of these methods are POST
methods made to SuggestGrid. Therefore, only POST
requests is allowed for CORS requests made to SuggestGrid.
Usage
Warning: Do not use your private keys for SuggestGrid JavaScript Clients.
These clients are made for public usage in mind. API keys used in browsers are exposed to the public. Therefore, we strongly request our clients to use their public keys for these clients.
SuggestGrid JavaScript clients are available under dist folder. Minimized clients are also available there. SuggestGrid JavaScript Client is also available on npm and bower as suggestgrid-js
.
Below are example implementations of SuggestGrid JavaScript clients. These examples demonstrate how to send an action to SuggestGrid on a click of a button.
suggestgrid.js
SuggestGrid JavaScript Client:This is the standard SuggestGrid JavaScript client. It is a UMD implementation, therefore can be consumed by many module loaders.
Examples:
- Vanilla JavaScript Example
- Browserify Example
- RequireJS Example
- Webpack Example
- SystemJS Example
- Bower Example
suggestgrid.es6.js
SuggestGrid EcmaScript 6 Client:This is the SuggestGrid client of the bright future of JavaScript! Use it if you can! The example is demonstrated with SystemJS.
Microsoft Edge can load EcmaScript 6 modules if its experimental features are enabled [1]. browser-es-module-loader project can be used to load modules in other browsers.
Example:
suggestgrid.jquery.js
SuggestGrid jQuery Plugin:This is the SuggestGrid jQuery plugin. It has the same functionality with the standard SuggestGrid JavaScript client, but it makes jQuery requests.
Example:
Development
Build Process
In order to create a modular structure without duplications, SuggestGrid clients are created by merging small JavaScript snippets.
The clients are created by the snippets in src folder by build.sh script. This is the command triggered by npm build
command.
Update the Client
One changes are made the following commands would publish it on a patch version upgrade:
npm run build
npm version patch
npm run push
npm publish
License
The MIT License (MIT) – Copyright (c) 2016 SuggestGrid