๐Ÿ”—REST API

This content has been imported from https://woocommerce.com/

Requirements

WordPress permalinks must be set to something that is easily human readable at: Settings > Permalinks.

Day and name is a great default, but anything aside from Plain should work

Generate API keys

The WooCommerce REST API works on a key system to control access. These keys are linked to WordPress users on your website.

To create or manage keys for a specific WordPress user:

  1. Go to: WooCommerce > Settings > Advanced > REST API. Note: Keys/Apps was found at WooCommerce > Settings > API > Key/Apps prior to WooCommerce 3.4.

  2. Add a Description.

  3. Select the User you would like to generate a key for in the dropdown.

  4. Select a level of access for this API key โ€” Read access, Write access or Read/Write access.

  5. Select Generate API Key, and WooCommerce creates API keys for that user.

Now that keys have been generated, you should see Consumer Key and Consumer Secret keys, a QRCode, and a Revoke API Key button.

The Consumer Key and Consumer Secret may be entered in the application using the WooCommerce API, and the app should also request your URL.

Frequently Asked Questions

Why am I getting โ€œwoocommerce_rest_cannot_viewโ€ or 401 error while making a request?

As the first step, make sure that you are using the correct API keys.

If the keys are correct, make sure that the keys have correct permissions (If you are reading and writing data, then make sure the permission is set to โ€œRead/Writeโ€)

If you have access to .htaccess file then add the below lines temporarily for the test

SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
RewriteRule ^wp-json/.* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

Last updated