Norsani API
Norsani API was developed to allow access to Norsani resources through REST calls. To use the Norsani API you must download and activate the Norsani API WordPress plugin.
You can use any programming language your prefer to connect with the API.
React Native developers can use the Norsani React Native client package to easily connect with the API over HTTP or HTTPS.
Requirements
Norsani 2.14+
WooCommerce 3.6+.
WordPress 4.4+.
Pretty permalinks in
Settings > Permalinks
so that the custom endpoints are supported. Default permalinks will not work.
Authentication
You may access the API over either HTTP or HTTPS, but HTTPS is recommended where possible. Norsani uses the WooCommerce API customer key and secret to authenticate so before you start you should obtain your WooCommerce API keys from WooCommerce settings -> Advance -> REST API.
Authentication over HTTPS
You may use HTTP Basic Auth by providing the REST API Consumer Key as the username and the REST API Consumer Secret as the password in the request's Authorization header.
Occasionally some servers may not parse the Authorization header correctly (if you see a "Consumer key is missing" error when authenticating over SSL, you have a server issue). In this case, you may provide the consumer key/secret as query string parameters instead.
Authentication over HTTP
You must use OAuth 1.0a "one-legged" authentication to ensure REST API credentials cannot be intercepted by an attacker. Typically you will use any standard OAuth 1.0a library in the language of your choice to handle the authentication. For React Native users you can simply use the React Native Norsani API client that will handle the autentication for you.
API Endpoints
Load App
GET
https://yourwebsite.com/wp-json/norsani/v1/loadappdata
This is called to load a list of all vendors but also returns other data sets. Please see the call response for more information.
Query Parameters
Name | Type | Description |
---|---|---|
vendortype | string | Vendor type to retrieve. Pass null to get all types. |
ordertype | string | User selected order type. Pass null to get all types. |
customer | string | Current user's email address. |
locality | string | User selected locality. |
Get a single vendor
GET
https://yourwebsite.com/wp-json/norsani/v1/get_vendor/id
Returns resources of a single vendor.
Path Parameters
Name | Type | Description |
---|---|---|
id | integer | Id of the vendor to return. |
Get a single Product
GET
https://yourwebsite.com/wp-json/norsani/v1/getproduct/id
Path Parameters
Name | Type | Description |
---|---|---|
id | integer | id of the product to return. |
Search Vendors
GET
https://yourwebsite.com/wp-json/norsani/v1/searchvendors
Search vendors by keyword. This will search for the keyword within the vendor name, tags, and address.
Query Parameters
Name | Type | Description |
---|---|---|
vendortype | string | Type of vendors to search. pass null to search all. |
ordertype | string | Search vendors that offer this order type. Pass null to search all. |
keyword | string | Search keyword |
Get locality options
GET
https://yourwebsite.com/wp-json/norsani/v1/localityoptions
Will get the locality options available on the website. This endpoint does not accept any parameters.
Get data of user favorite vendors
GET
https://yourwebsite.com/wp-json/norsani/v1/getfavoritevendors
Query Parameters
Name | Type | Description |
---|---|---|
ids | string | A comma separated string of vendor ids. |
Get data of user favorite products
GET
https://yourwebsite.com/wp-json/norsani/v1/getfavoriteitems
Query Parameters
Name | Type | Description |
---|---|---|
ids | string | A comma separated list of product ids. |
Get list of user orders
GET
https://yourwebsite.com/wp-json/norsani/v1/getorders
Get a list of the user previous orders.
Query Parameters
Name | Type | Description |
---|---|---|
string | ||
numberorders | integer | Number of orders to get |
Get single order data
GET
https://yourwebsite.com/wp-json/norsani/v1/getorder/id
Path Parameters
Name | Type | Description |
---|---|---|
id | integer | Id of the order to get. |
Add to cart
POST
https://yourwebsite.com/wp-json/norsani/v1/addtocart
This uses the WooCommerce frontend cart functions to calculate totals, so you always get the up to date accurate cart totals collection on your app. This does not save any data on the server so each time you add a product to cart you should also send the previous cart data.
Query Parameters
Name | Type | Description |
---|---|---|
cartData | array | Array of cart data to be send as request. array( vendor_id => array( 'items' => array( productID => imagelink => variationID => qty => orderType => specialNotes => variations => // If not applicable set null price => name => maxOrders => remainingOrders => minQty => ), ), ... ) |
coupons | array | Array of coupon codes to apply. |
Get the checkout form.
POST
https://yourwebsite.com/wp-json/norsani/v1/getcheckoutform
This will get the checkout form fields as required on the website in addition to the checkout order review and totals.
Query Parameters
Name | Type | Description |
---|---|---|
cartData | array | Cart data as sent in the Add to Cart request. |
coupons | array | Array of coupon codes used in cart. |
orderType | string | The user selected order type. |
Verify checkout data
POST
https://yourwebsite.com/wp-json/norsani/v1/verifycheckout
This call must be done just before user has been charged for the order. This will return a data array ready to be used with WooCommerce create order API endpoint. NOTE: This will create a WooCommerce on-hold order.
Query Parameters
Name | Type | Description |
---|---|---|
cartData | array | Cart data as send in Add to cart request. |
ordertimings | array | Order preparation time array. i.e array( array( 'vendor_id' => 23, 'time' => 13:22, 'date' => 26 May, ), ... ) |
coupons | array | Array of coupon codes used. |
billingForm | array | Billing form data. i.e array('billing_email' => user@example.com, ...) |
paymentMethod | string | This must be the payment method slug used on WooCommerce. i.e for cash on delivery, WooCommerce uses "COD" slug. |
customerNote | string | Delivery notes. |
userLocation | string | User full address. |
userLocationGeo | string | User geo-location address lat,lng |
Last updated