# WP Generate Rest API keys

## Website Config

Before we start, make sure you have installed **WordPress** and **WooCommerce** and your website is up and running. If you have not installed WordPress yet, start from here: <https://wordpress.org>

#### For WooCommerce Required Plugins

* [WooCommerce](https://wordpress.org/plugins/woocommerce/) *Free*
* **App Builder** *License Key*

### **Step 1: Configuration of your WordPress website**

If you’re using non-pretty permalinks in WooCommerce, the REST API will not work. Configure pretty permalinks in **Settings > Permalinks** so that the custom endpoints are supported.

![Config WordPress permalinks settings.](/files/-MeOwhYWfYB79m1lBwNW)

### **Step 2: Configuring WooCommerce**

Pre-generated keys can be used to authenticate use of the REST API endpoints. New keys can be generated either through the WordPress admin interface or they can be auto-generated through an endpoint.

**Generating API keys in the WordPress admin interface**

Note: We not require WRITE permission READ is enough.

To create or manage keys for a specific WordPress user, go to **WooCommerce > Settings > Advanced => REST API>** Keys/Apps.

![Generating API keys.](/files/-MeOwzBW5rlD88swjkyy)

Click the “**Add Key**” button. In the next screen, add a description and select the WordPress user you would like to generate the key for. Use of the REST API with the generated keys will confirm to that user’s WordPress roles and capabilities.

Choose the level of access for this REST API key, which can be Read access, Write access or Read/Write access. Then click the “Generate API Key” button and WooCommerce will generate REST API keys for the selected user.

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

## App Config

### Configure API

Unzip file `product.zip` located inside the **app** folder.

### **API Endpoint and Customer Secret & Key**

Open file `api.js` in `product/lib/constants/app.dart` and change it with your domain name, customer key and customer secret you generated from `Woocommerce -> Settings -> Advanced -> REST API`

1. **Open file in below path:**

```
product/lib/constants/app.dart
```

2\. And replace your Rest API keys and domain with below info in **app.dart** file:

<pre><code><strong>const String baseUrl = 'https://yourdomain.com/';
</strong>
<strong>const String consumerKey = 'ck_xxxxxxxxxxxxxxxxxx';
</strong>
<strong>const String consumerSecret = 'cs_xxxxxxxxxxxxxxx';
</strong></code></pre>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.nilog.net/developers/wp-generate-rest-api-keys.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
