Giter Site home page Giter Site logo

woocommerce / wc-api-node Goto Github PK

View Code? Open in Web Editor NEW
144.0 146.0 63.0 66 KB

This client is obsolete and will no longer receive updates, a new JavaScript library is available under the name of @woocommerce/woocommerce-rest-api

Home Page: https://www.npmjs.com/package/woocommerce-api

License: MIT License

JavaScript 100.00%

wc-api-node's Introduction

WooCommerce API - Node.js Client

A Node.js client for the WooCommerce REST API. Easily interact with the WooCommerce REST API using this library.

- 2019-07-29: This client is obsolete and will no longer receive updates, a new JavaScript library is available under the name of @woocommerce/woocommerce-rest-api.

build status dependency status npm version

Installation

npm install --save woocommerce-api

Getting started

Generate API credentials (Consumer Key & Consumer Secret) following this instructions http://docs.woocommerce.com/document/woocommerce-rest-api/ .

Check out the WooCommerce API endpoints and data that can be manipulated in http://woocommerce.github.io/woocommerce-rest-api-docs/.

Setup

Setup for the new WP REST API integration (WooCommerce 2.6 or later):

var WooCommerceAPI = require('woocommerce-api');

var WooCommerce = new WooCommerceAPI({
  url: 'http://example.com',
  consumerKey: 'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  consumerSecret: 'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  wpAPI: true,
  version: 'wc/v1'
});

Setup for the old WooCommerce legacy API:

var WooCommerceAPI = require('woocommerce-api');

var WooCommerce = new WooCommerceAPI({
  url: 'http://example.com',
  consumerKey: 'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  consumerSecret: 'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  version: 'v3'
});

Options

Option Type Required Description
url String yes Your Store URL, example: http://woo.dev/
consumerKey String yes Your API consumer key
consumerSecret String yes Your API consumer secret
wpAPI Bool no Allow requests to the WP REST API (WooCommerce 2.6 or later)
wpAPIPrefix String no Custom WP REST API URL prefix, used to support custom prefixes created with the rest_url_prefix filter
version String no API version, default is v3
verifySsl Bool no Verify SSL when connect, use this option as false when need to test with self-signed certificates
encoding String no Encoding, default is 'utf-8'
queryStringAuth Bool no When true and using under HTTPS force Basic Authentication as query string, default is false
port string no Provide support for URLs with ports, eg: 8080
timeout Integer no Define the request timeout
agent Agent no User agent instance.

Methods

Params Type Description
endpoint String WooCommerce API endpoint, example: customers or order/12
data Object JS object, will be converted to JSON
callback Function Callback function. Returns err, data and res

GET

  • .get(endpoint)
  • .get(endpoint, callback)

POST

  • .post(endpoint, data)
  • .post(endpoint, data, callback)

PUT

  • .put(endpoint, data)
  • .put(endpoint, data, callback)

DELETE

  • .delete(endpoint)
  • .delete(endpoint, callback)

OPTIONS

  • .options(endpoint)
  • .options(endpoint, callback)

Promified Methods

Every method can be used in a promified way just adding Async to the method name. Like in:

WooCommerce.getAsync('products').then(function(result) {
  return JSON.parse(result.toJSON().body);
});

Release History

  • 2019-07-29 - v1.5.0 - Updated dependencies, and adds support for agent.
  • 2016-12-14 - v1.4.2 - Fixed WordPress 4.7 compatibility.
  • 2016-09-28 - v1.4.1 - Updated dependencies and updated/fixed oAuth1.0a.
  • 2016-06-30 - v1.4.0 - Added wpAPIPrefix option to allow custom WP REST API Url prefix and support for promified methods.
  • 2016-06-09 - v1.3.2 - Fixed oAuth signature for WP REST API.
  • 2016-06-08 - v1.3.1 - Fixed README.md.
  • 2016-06-03 - v1.3.0 - Added new timeout option and updated dependencies.
  • 2016-05-09 - v1.2.0 - Added support for WP REST API and added method to do HTTP OPTIONS requests.
  • 2016-03-18 - v1.1.1 - Added support for ports.
  • 2016-02-22 - v1.1.0 - Added queryStringAuth option to allow Basic Authentication as query string.
  • 2015-12-07 - v1.0.4 - Updated dependencies and fixed brackets when sorting query string.
  • 2015-12-07 - v1.0.3 - Added method to properly sort query strings when using oAuth.
  • 2015-07-11 - v1.0.2 - Fixed the examples on example.js and README.md.
  • 2015-07-11 - v1.0.1 - Added unit tests, improved the main class and added full description on README.md.
  • 2015-07-11 - v1.0.0 - Initial release.

wc-api-node's People

Contributors

claudiosanches avatar enricodeleo avatar mtzagkarakis avatar rfink avatar smartacus avatar thiagofalencar avatar wackywombaat12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wc-api-node's Issues

Query string authentication fallback

Hi,
On some hosts the basic authentication method doesn't work (Dreampress's Varnish cache for example, strips the authorization header).

The WC API already has a query parameter fallback (e.g., &consumer_key=ck_...&consumer_secret=cs_...), could this get exposed in the Node api as an option?

GET the latest product randomly.

Am trying to fetch data from the json that is returned when am i send the GET request.
Here is my code:
WooCommerce.get('products', function(err, data, res) {
console.log(res);
});

It returns all the products correctly though i need to get a single product, from the documentation for you to get the single product you have to fetch with a given id, though i need to get the latest product.

So when i phrase the object, console.log(res.products[0]); i get an error undefined error. Anyway around this?

Webpack errors

Hello!

Having errors when trying to use npm package in Webpack build.

Module not found: Error: Can't resolve 'net' in '***/node_modules/forever-agent'
 @ ./~/forever-agent/index.js 6:10-24
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./~/woocommerce-api/index.js
 @ ./assets/scripts/bootstrap.js
 @ ./assets/scripts/main.js
ERROR in ./~/forever-agent/index.js

Also Module not found and can't resolve 'tls' and 'fs'

There is something I've missed?

reactnative woocommerce api

Hi ,
I'm trying to integrate WooCommerceAPI in react-native project
First , i encountered a problem with crypto module wich is installed but when running the app i get an error "Module crypto not found"
Then, i installed crypto-js and used rn-nodeify to resolve this issue, then i runned the project again i get , "Object prototype may only be an object or null "

I don't know what does this error mean?

Thanks

JS Client Returns 401; Postman returns 200

var WooCommerceAPI = require('woocommerce-api');
//import WooCommerceAPI from 'woocommerce-api';

let WooCommerce = new WooCommerceAPI({
    url: 'http://data.uikit.dev',
    wpAPI: true,
    consumerKey: 'ck_df9b0cb9f1c7aa8eb04ae05b4cca3097e8f8693c',
    consumerSecret: 'cs_61da879ea10f7a3d815006cad6452560a1e28e8a',
    version: 'wc/v1',
});

WooCommerce.get('products', function(err, data, res) {
    console.log(err);
    console.log(res);
});

If I put the same info into PostMan, it works just fine – it even works if I grab the URL from Chrome’s network tab, but the JS returns a 401 error.

QuickCast: http://quick.as/j2GQim38g

Is this still a server issue?

Consumer Secret is invalid

I am trying to get data from my Woocommerce store. The store is located at an 'https' url but all get in the response to any endpoint is,

{ errors: [ { code: "woocommerce_api_authentication_error", message: "Consumer Secret is invalid" } ] }

I have generated and cross checked the key and secret multiple times. I can get the data in the browser if I send credentials as query params but not using the API.
What is wrong?

Create customer leaves WP user with email address as default display name

(Perhaps this is more an enhancement request)

We can successfully create a customer account on wordpress from our nodejs backend (as documented in http://woothemes.github.io/woocommerce-rest-api-docs/#create-a-customer).

However, we have noted that, once the customer account is created, the user's default public display name is set to the email address (we need users to login with their email addresses). We are setting the user's first and last name properties during user creation, as this:

var newCustomer = {
    customer: {
    email: _this.email,
    first_name: _this.firstName,
    last_name: _this.lastName,
    username: _this.email,
    password: _this.password,
  }

_wooHelper.post('customers', newCustomer, callback);

I am not entirely sure if setting the public display name is within WooCommerce's API control or not, but just wanted to report this to the dev team and see if this is a dead-end or a potential enhancement to the nodejs client.

List all products pagination not working properly

I am testing with Node.js library and this is my first trial. I am trying different page size and different limitation, but none works!
WooCommerce.get('products?per_page=5&after=2016-08-06T09:58:52+00:00', function(err, data, response) { res.send(response); });

I have tried page size as 5 or 50 and use an after to make sure no products matching the criteria. However, always 10 products returned. What could be the reason? I'm using woocommerce 2.6.4 on wordpress 4.5.3

What's the best way to detect the Woocommerce version.

This is just a question, not an issue, but I appreciate If someone can help me.

How could I know before hand the Woocommerce and WP version to determine the API version and prefix to be used ?

Based on Woocommerce and WP version I have to know if I need to use wp-json or wc-api and which version, right?

Any ideas? Thank you!

Invalid signature

var WooCommerceAPI = require('woocommerce-api');

var WooCommerce = new WooCommerceAPI({
url: 'http://localhost:8080/demo', // Your store URL
consumerKey: 'ck_xxxxxxxxxxxxxxxxxxxxxx', // Your consumer key
consumerSecret: 'cs_xxxxxxxxxxxxxxxxxxxxxxx', // Your consumer secret
wpAPI: true, // Enable the WP REST API integration
version: 'wc/v1' // WooCommerce WP REST API version
});

WooCommerce.get('products', function(err, data, res) {
console.log(res);
});

{"code":"woocommerce_rest_authentication_error","message":"Invalid Signature - p
rovided signature does not match.","data":{"status":401}}
i'm already install oauth-1.0a and express js & Dependencies .
Regard
VIJAY

Issues with the wpAPI: false option

If I read the Woo Docs, it says The WP rest API doesn't need to be installed...

When I run the following code without the wpAPI set to true, the response is '-1', however, when i add the wpAPI: true, the API works as intended.

I don't have the WP Rest Plugin installed, I'm not sure if this issue is jut a misunderstanding on my part? Any further explanation to help me understand what is going on would be fantastic, thanks

var WooCommerce = new WooCommerceAPI({
  url: 'https://example.com',
  wpAPI: true, // <-- this
  version: 'wc/v1',
  consumerKey: 'ck_xxx',
  consumerSecret: 'cs_xxx',
  queryStringAuth: true 
});

WooCommerce.get('products').then(function(result) {
   console.log(JSON.parse(result.toJSON().body));
});

Invalid parameter(s): billing, shipping for the woocommerce-api: "1.4.2"

Hai ,
I am using the woocommerce module, It was awesome working before updating my wordPress to version 4.7.1, But from the new version i.e 4.7.1 it is not showing the correct response it throws the error like

Invalid parameter(s): billing, shipping
version which i used for woocommerce-api: "1.4.2"

Here is my code

app.post('/api/createOrder',function(req,res){
  var data = req.body
  WooCommerce.post('orders', data, function(order, data, res1) {
    console.log(res1);
    var json=JSON.parse(res1)
    res.send(json)
  });
})

In req.body which i passed is

{
  "payment_method": "bacs",
  "payment_method_title": "Direct Bank Transfer",
  "set_paid": true,
  "billing":{
    "first_name": "John",
    "last_name": "Doe",
    "address_1": "969 Market",
    "address_2": "",
    "city": "San Francisco",
    "state": "CA",
    "postcode": "94103",
    "country": "US",
    "email": "[email protected]",
    "phone": "(555) 555-5555"
  },
  "shipping": {
    "first_name": "John",
    "last_name": "Doe",
    "address_1": "969 Market",
    "address_2": "",
    "city": "San Francisco",
    "state": "CA",
    "postcode": "94103",
    "country": "US"
  },
  "line_items": [
    {
      "product_id": 938,
      "quantity": 2
    }
  ],
  "shipping_lines": [
    {
      "method_id": "flat_rate",
      "method_title": "Flat Rate",
      "total": 10
    }
  ]
}

wordPress Version:4.7.1
woocommerce-api version:1.4.2
Please give me suggestion that how can i solve this. Thanking You

401 Unauthorized error when posting.

I am able to make get calls with it successfully but when I try to post it gives me 401 invalid signature error.

my code for Ionic 2.
var WooCommerce = new WooCommerceAPI({
url: 'http://vishaljoshi.in/woocommerce',
consumerKey: 'ck_',
consumerSecret: 'cs_',
wpApi: true,
version: 'wc/v1',
wpAPIPrefix: 'wp-json'
})

WooCommerce.post('customers', this.data, function(err, data, res) {
console.log(res);
});
// Am i missing something here?

How get the value in x-wp-totalpages header

I need to know, how i get the header value of x-wp-totalpages, this is my code:

WooCommerce.get( 'products', function( err, data, res ) {
console.log('data: ' , data);
console.log('header: ' , res.getReponseHeader('x-wp-totalpages'));
});

Thanks.

Do you still maintaining this?

Have this issue:

[$injector:unpr] Unknown provider: WPProvider <- WP <- mycontroller

Thank you! It's hard to find a good library for angular and wc api.

Throwing "write EPROTO" error in case of SSL.

We are facing "write EPROTO" error for now, initially it was working for non-ssl.
In case of ssl, we are not able to access woocommerce api in node.My woocomerce application is running on ssl, while node is not running on ssl.

 Error: write EPROTO 140336970151808:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:794:

Please take a look and assist us to resolve this issue.

Thanks

Invalid timestamp

{ code: 'woocommerce_api_authentication_error', dynamics-export-app | message: 'Invalid timestamp' }

I get this authentication issue. But, no idea on this issue.

Woocommece Version: 2.5.5
Wordpress version: 4.5.2

Any one know it?

woocommerce_api_authentication_error, Invalid Timestamp

I'm working on a local Wordpress server and a local NodeJS server.

Everything was working fine until I changed some products on Woocommerce, and I started getting this error when trying to call the API.

{
  errors: [
    {
      code: "woocommerce_api_authentication_error",
      message: "Timestamp inválido"
    }
  ]
}

Invalid Signature

Hi, I just installed woocommerce-api, created new api keys (api is enabled) in woocommerce and did a simple call to get orders and test it, but I'm getting this error:

{"errors":[{"code":"woocommerce_api_authentication_error","message":"Invalid Signature - provided signature does not match"}]}
const WooCommerce = require('woocommerce-api');

const wooCommerce = new WooCommerce({
  url: 'http://example.com/index.php',
  consumerKey: 'ck_33a6316baf347629067389cccfb574b5433f0bf6',
  consumerSecret: 'cs_5ae71218180dd1a0fdfe6d21baf12f88fb23c338'
});

wooCommerce.get('orders', (err, res, body) => {
  console.log(body);
  // {"errors":[{"code":"woocommerce_api_authentication_error","message":"Invalid Signature - provided signature does not match"}]}
});

request parameters

{ url: 'http://example.com/index.php/wc-api/v3/orders',
  method: 'GET',) 
  encoding: 'utf8',
  timeout: undefined,
  headers: 
   { 'User-Agent': 'WooCommerce API Client-Node.js/1.4.0',
     'Content-Type': 'application/json',
     Accept: 'application/json' },
  qs: 
   { oauth_consumer_key: 'ck_33a6316baf347629067389cccfb574b5433f0bf6',
     oauth_nonce: 'SRQbsOIP3KnGsUjKj5Lu5RWsprEH9J9k',
     oauth_signature_method: 'HMAC-SHA256',
     oauth_timestamp: 1478204724,
     oauth_version: '1.0',
     oauth_signature: 'WMAJ1JQb6WJvJFpuVyXMMGsTO8Wg5QYtOrfCyGsy+BY=' } }

any clues?

Error: Invalid JSON Body passed

Seems like there's a WP Core issue with v4.7 where a "invalid_json_body" error is returned by the API if the request has no body, which is the case with WooCommerce.get requests.

See the core issue here.

Same thing on the WC API PHP Wrapper and apparently removing the Content-Type header works as a temporary fix - any chance the same can be done here, while WP 4.7.1 isn't released? Or is there another workaround? Thanks!

Multisite option

I want to create an app with WordPress (WooCommerce) multisite. Where user may choose SubSite at the first time app starts and app is remembering his choise on the next start.

Thx.

Error: Cannot find module "../package.json"

I'm working on integrating Woocommerce Rest API with Ionic 2 using this package:

npm install --save woocommerce-api

import * as WooCommerceAPI from 'woocommerce-api';

ionViewDidLoad() {
var WooCommerce = new WooCommerceAPI({
url: 'http://example.com',
consumerKey: 'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
consumerSecret: 'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
});
}
I'm getting this error and app stops running.
Error: Cannot find module "../package.json"
Pls Advice me,
Thanks & Regards,

Status 401

Hi,

I don't succeed to connect to my woocommerce, I get a status 401 instead.

Here is my code :

var WooCommerceAPI = require('woocommerce-api');

var WooCommerce = new WooCommerceAPI({
  url: 'http://www.mywebsite.com/',
  wpAPI: true,
  version: 'wc/v1',
  consumerKey: 'ck_myKey',
  consumerSecret: 'cs_mySecret'
});
WooCommerce.get('', function(err, data, res) {
  console.log(res);
});

And get the following message :

{"code":"woocommerce_rest_authentication_error","message":"Invalid Signature - provided signature does not match.","data":{"status":401}}

I'm sure of my consumerKey and consumerSecret (did it many times to be sure).

Any idea why I get a 401 status ?

Thanks :)

PS: I'm using WooCommerce Version 2.6.0-beta-4

Filter parameter issue

Sending request with this endpoint
products?filter[tax_query][0][taxonomy]=product_brand&filter[tax_query][0][field]=slug&filter[tax_query][0][terms][0]=adidas
The request is actually sent to
http://my-domain.com/wp-json/wc/v1/products?filter%5Btax_query%5D%5B0%5D%5Bfield%5D=slug&filter%5Btax_query%5D%5B0%5D%5Btaxonomy%5D=product_brand&filter%5Btax_query%5D%5B0%5D%5Bterms%5D%5B0%5D=adidas&oauth_consumer_key=ck_26faeaf9f02b235c4cc547e77e8c14f6c07c2eec&oauth_nonce=DqiZopJKGuiXdug6IHYQ9cLNZZ6IT7gd&oauth_signature_method=HMAC-SHA256&oauth_timestamp=1475085829&oauth_version=1.0&filter%5Btax_query%5D%255B0%255D%255Bfield%255D=slug&filter%5Btax_query%5D%255B0%255D%255Btaxonomy%255D=product_brand&filter%5Btax_query%5D%255B0%255D%255Bterms%255D%255B0%255D=adidas&oauth_signature=wyYTV7aitqK9hlkJgESe6gJbrpZCAlJgvxyEcmM5020%3D
notice the filter parameter is duplicated twice.
and i get an error:
{"code":"woocommerce_rest_authentication_error","message":"Invalid Signature - provided signature does not match.","data":{"status":401}}

I think there is an issue with oAuth library

Using latest WC version WP-Rest api

Authentication fails when path is not wc/vXXX

Hi, I am struggling a lot with auth in case the vendor is changed to something else than wc.

var WooCommerce = new WooCommerceAPI({
url: 'http://store.com',
consumerKey: 'ck_XXX',
consumerSecret: 'cs_XXX',
verifySsl: false,
wpAPI: true,
version: 'vendorA/v1',
queryStringAuth: true,
});

permission_callback will call wc_rest_check_manager_permissions() or connected_user_can() which no longer finds the permissions of the user used in the connection.

Please clarify if this is the expected behaviour or I am missing something.

Thx,

can't delete a shipping class, getting error code "woocommerce_api_no_route"

i'm using this code:
WooCommerce.delete('products/shipping_class/27', function(err, data, res) { console.log(res); });
and keep getting this error:

{"errors":[{"code":"woocommerce_api_no_route","message":"No route was found matching the URL and request method"}]}

i have tried on 2 different sites ( and changed the class id number) and same error keep showing up.

i can do other operations like get and put successfully.

Customizable api path

Since wp-rest allow the developer to change the default path (for example I use wp-rest instead of wp-json) the module should provide a way to specify so.

Fields Parameter does not work as expected

As documentation states, we may limit the fields returned in the response using the fields parameter like this GET /orders?fields=id. This pretty much works with orders endpoint, but returns strange results when using with customers//orders endpoint. For example:

customers/405/orders?fields=order_number,completed_at,line_items returns single cancelled order, whereas with only customers/405/orders it returns all processed user's orders without any cancelled ones.

Could you please investigate on this issue?

PS. I'm using woocommerce-api v1.0.4 and did not specify api version in the WooCommerceAPI constuctor, thus it is supposed to be v3.

Integration question

Is it possible to integrate Twitter Digit's functionality? I want completly change WordPress core signup/auth process to Twitter Digits via Phone Number.

How to get On sale product using REST API ?

Hi Team,
I am on using wc-api-node, when i am try to get all on sale product using endpoint /products in current version woocommerce api ( v1) and add filter['on_sale']=true it's doesn't give me the correct result.

anyone can help me to do this ?

Thanks

Timeout option

Would you accept a P.R. that allowed a "timeout" configuration to be used? I have a few requests that go beyond 30 seconds (for example), and it would be nice to have request them out. Thanks!

How to get shop currency via REST api

Where can I find the shop's currency using the REST api?
I can't find an endpoint in your rest api that refers to general shop information.
I am trying to write an integration app for an e-commerce platform.

"nonce is already used"

Using the NodeJS woocommerce-api package + woocommerce 3.0.0 + wp 4.7.4.

Getting "nonce is invalid, already used" error "woocommerce_api_authentication_error".

  • Tried curl but getting "401 - woocommerce_rest_cannot_view".

Any advice?

**** UPDATE ****

Using the node package 'woocommerce' which is not official from the woocommerce team and uses the legacy API -> works well!

Any app's example?

Hi do you have any app examples builded onto that framework? May be opensource?

No route was found matching the URL and request method

@claudiosmweb while I was testing for this example got error. Is there anything I was missing:

// PUT example
WooCommerce.put('orders', { // Working if orders/id. IMO this should be updated in example
  order: {
    status: 'completed'
  }
}, function(err, data, res) {
  console.log(res);
});

This return No route was found matching the URL and request method

{"errors":[{"code":"woocommerce_api_no_route","message":"No route was found matching the URL and request method"}]}

No support for React native!

I am trying to use this npm module for my react native project and it wouldn't work.
When i try to import the module, it throws the error shown in the screen shot. please Fix this. i am stuck because of this error. I tried all the solution shown for this error.. still not working.

simulator screen shot 26-sep-2016 7 24 45 pm

"woocommerce_rest_cannot_view" and 401 Unauthorised

When using the new REST API I keep getting a woocommerce_rest_cannot_view error. I double checked everything as per the API and this package's documentation and code but couldn't find anything wrong with my setup.

Here's the code I'm using:

    import WooCommerceAPI from 'woocommerce-api';

    var WooCommerce = new WooCommerceAPI({
        url: 'https://192.168.22.10.xip.io',
        wpAPI: true,
        version: 'wc/v1',
        consumerKey: 'ck_5cd77...',
        consumerSecret: 'cs_b54c...',
        verifySsl: false
    });

    WooCommerce.get('products', function(err, data, res) {
      console.log(res);
    });

I tried setting the permalinks, creating new keys, changing the URL... nothing fixed it.

When I test this via Paw (API tool for Mac) using Basic Auth and the exact same parameters though, it works perfectly! I get a SSL certificate dialog similar to Safari's, choose to continue and the request is processed perfectly.

I'm guessing the "verifySsl" option isn't doing it's job? What else can I try?

Not returning full list of products

Hi All,

Can anyone explain to my why this is not working and returning a full list of products.

WooCommerce.get('products', function(err, data, res) {
        if (res !== null) {
            allItems = JSON.parse(res);
        }
    });

it appears to be only returning 10 products.

WooCommerceAPI is returning wrong endpoint information

I am using nodejs SDK v1.0.2. When I try to read the endpoint index, I just get a 1 result:

_wooHelper.get('', function(error, data, res){
console.log(res);
done();
});

console.log(res) outputs 1. Inspecting the data variable, it looks like the client is connecting to /wc-api/v3. Connecting to this url via curl also returns 1. Connecting via curl to /wc-api/v2 does return the expected index information.

I wanted to submit an issue as I am not sure if the result 1 when connecting to v3 is by design, and I am not sure how to tell the nodejs sdk woocommerce api client to instead connect to v2 and get the correct endpoint information.

PUT request removing product categories on update

When I try to update the price, the price updates and all other fields are intact, except the categories, which becomes null.

wooCommerce.get('/products/'+prodid, function(err, pdata, res) {
pdata.product.regular_price = newPrice
//here categories is ["Category 1"]
wooCommerce.put('/products/'+prodid, pdata, function(err, data, res) {
                    console.log(err, 'res' ,res.body);
                    //here category is []
                })
})

Is there something simple that I missed?

Repo not in sync with npm

When I install the package from NPM, it is not quite in sync, for example, I have to manually fix the promises to get the getAsync functions working. I believe the latest changes have not been released to create the sync.

Thanks

Query parameter for product search returns erroneous api authentication error

I am using the NodeJS SDK to interact with the lastest version of WooCommerce (2.4.4, API v3).

Issue: I run the following query against the API:

var queryUrl =  util.format('products?filter[q]=%s&filter[limit]=500', encodeURIComponent(displayName));
    debug(queryUrl);
    _wooHelper.get(queryUrl, callback);

This returns the following error:

"errors": [
        {
            "code": "woocommerce_api_authentication_error",
            "message": "Invalid Signature - provided signature does not match"
        }
    ]

However, if I remove the limit filter, the API returns the expected result. This is the code that works:

var queryUrl =  util.format('products?filter[q]=%s', encodeURIComponent(displayName));
    debug(queryUrl);
    _wooHelper.get(queryUrl, callback);

By trial and error with this query, I have not been able to find a way to add the LIMIT filter without the systems return the api_authentication error. So the purpose of this issue submissions is to report that a) the API is returning an api_authentication error, when this seems not to be the problem and b) it seems one cannot mix the LIMIT filter with other parameters in a search query.

Signature mismatch using proxy

Hi,
First I'd like to tell you how grateful I am to find such a practical API adapted on NodeJS.
I am currently using it under Ionic to fetch informations from the website designed with wordpress/woocommerce. I had an issue recently with mismatching signature on OAuth. I've managed to print both non-hashed signature and I found out the problem.

As I am currently testing on browser I had to avoid CORS, and this was done with a proxy thank to ionic. But now I can use API on debug because signatures are built with the proxy address (localhost) on the client side, whereas the serve is building them with the server address (example.com).

In my opinion, the best solution would be to take proxy in the parameters when declaring the wc-api class.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.