The WC Key Manager plugin provides a REST API endpoint that allows you to retrieve and display a comprehensive list of all keys, along with detailed information. To access this data, you can use the GET method with the endpoint ‘/keys’.
https://example.com/wp-json/wc/v1/keys/?consumer_key={consumer_key}&consumer_secret={consumer_secret}
Parameters
Parameter | Description |
---|---|
consumer_key | The corresponding secret key is used for authentication with the WooCommerce API. |
consumer_secret | The corresponding secret key is used for authentication with the WooCommerce API. |
product_id | The unique identifier for a specific product in WooCommerce. |
order_id | The unique identifier for a specific order in WooCommerce. |
customer_id | The unique identifier for a specific customer in WooCommerce. |
status | The consumer key is used for authentication with the WooCommerce API. |
Example of API Response:
{
"id": 25,
"code": "AUBR-5KTE-IFXO-UZ33",
"valid_for": 0,
"activation_limit": 0,
"activation_count": 0,
"product_id": 78,
"customer_id": 0,
"order_id": 0,
"order_item_id": 0,
"subscription_id": 0,
"vendor_id": 0,
"email": "",
"price": 0,
"ordered_at": null,
"status": "available",
"created_at": "2024-07-03 11:57:44",
"updated_at": null
},
{
"id": 24,
"code": "1OST-GAU2-9Q8L-CY6I",
"valid_for": 0,
"activation_limit": 0,
"activation_count": 0,
"product_id": 78,
"customer_id": 0,
"order_id": 0,
"order_item_id": 0,
"subscription_id": 0,
"vendor_id": 0,
"email": "",
"price": 0,
"ordered_at": null,
"status": "available",
"created_at": "2024-07-03 11:57:44",
"updated_at": null
},
{
"id": 22,
"code": "FDJP-26CF-EB4D-SBRY",
"valid_for": 0,
"activation_limit": 0,
"activation_count": 0,
"product_id": 69,
"customer_id": 0,
"order_id": 0,
"order_item_id": 0,
"subscription_id": 0,
"vendor_id": 0,
"email": "",
"price": 0,
"ordered_at": null,
"status": "available",
"created_at": "2024-07-03 11:38:08",
"updated_at": null
}
If you need to retrieve responses based on a specific product ID, you can do so with the following API call:
Example of API Call:
https://example.com/wp-json/wc/v1/keys/?product_id=69&consumer_key=ck_f3db7b87befb91b50654a83d51a2fec9f28870b0&consumer_secret=cs_86832fa747333b0af7a28bdc4c504b122a0981cc
Additionally, you can filter the results by customer_id, order_id, and status, either individually or in combination. For instance, if you want to view only the active keys for a specific product, your API call would look like this:
Example of API Call:
https://example.com/wp-json/wc/v1/keys/?status=active&product_id=69&consumer_key=ck_f3db7b87befb91b50654a83d51a2fec9f28870b0&consumer_secret=cs_86832fa747333b0af7a28bdc4c504b122a0981cc
This flexibility allows you to tailor your API queries to retrieve exactly the information you need.
Fields in API Response:
The API will return a JSON response with the following parameters:
Parameter | Description |
---|---|
id | The unique identifier for the keys. |
code | The keys which is created. |
valid_for | Duration or validity period of the keys. |
activation_limit | Maximum number of times the keys can be activated. |
activation_count | Number of times the key has been activated. |
product_id | The unique identifier for a specific product in WooCommerce. |
customer_id | The unique identifier for a specific customer in WooCommerce. |
order_id | The unique identifier for a specific order in WooCommerce. |
order_item_id | The unique identifier for a specific item within an order in WooCommerce. |
subscription_id | The unique identifier for a specific subscription in WooCommerce. |
vendor_id | The unique identifier for a specific vendor in WooCommerce, especially relevant in a multi-vendor marketplace setup where different vendors sell products through the same WooCommerce store. |
email | The email address associated with the keys. |
price | Price of the keys. |
ordered_at | Date and time when the key was ordered. |
status | The email address associated with the keys. |
created_at | Current status of the keys (e.g., active, available). |
updated_at | Date and time when the key was last updated. |