This project is read-only.

Getting Started with nopCommerce REST Service Plugin (AKA NopRest)

Install Plugin

  1. Clone or download the source code
  2. Add the plugin source code to your nopCommerce solution (.sln) file
  3. Re-compile the solution file, run the website, and install the plugin
  4. Configure an API Token in the plugin configuration page (you may use the "generate hash" button)
  5. Make REST call to the corresponding ActionMethod in ApiController.

Sample REST call

After plugin installation, open up developer tools in your browser (usually F12). Run the following code to do a quick test:

$.post('/Api/GetOrderById?id=1&apiToken={REPLACE_WITH_YOUR_TOKEN}', null, 
function (response) { console.log(response); });


Here's an example in Chrome:

nopCommerce REST Service Plugin Sample Call in Chrome Developer Tools

Architecture Overview

Contrary to your first impression, this plugin runs on MVC and not Web API. I've chosen MVC over Web API for simplicity, as nopCommerce has developed a very comprehensive architecture to power the MVC part. By leveraging what nopCommerce has done thus far, it allows me to get started quickly, focusing on the features instead of the setups.

In short, this project currently uses MVC to simulate REST behavior, and make use of what nopCommerce has done so far to speed up the setups.

Of course, if required in the future, I'll consider moving to Web API. But that's after this project has obtained enough attention. The current plan is to focus on getting the features (especially CRUD operations for major entities) completed.

Contributing to the Code

As explained in previous section, I've setup the basic architecture for simulating REST behavior, so you don't need to worry about that part. I would appreciate, thought, that you can help add more methods to the plugins.

I've written some sample methods in ApiController.cs. You can, base on the examples I've written, add more methods that you think required. For example, we currently have 2 methods for Customer - GetCustomerById and GetCustomerByUsername. It is probably a good idea to add methods such as (but not limited to) InsertCustomer and UpdateCustomer.

All you need to do is write new REST methods in ApiController.cs, probably some helper methods for creating the JSON objects. In anyway, please refer to other methods for example.

In short, you'll need to:

  1. FORK the project.
  2. Refer to for a list of features to be implemented.
  3. Check the comments of each item, make sure nobody is working on it.
  4. If you identified an open item, make a comment stating that you'll be working on it.
  5. Change ApiController.cs.
  6. Submit a PULL request.
  7. If your contribution is helpful, I'll merge your code into the main branch.
  8. Repeat [2] - [6]

Happy contributing! :D

Last edited Sep 6, 2014 at 7:10 PM by wooncherk, version 7