WooCommerce Legacy REST API (plugin)

Uit De Vliegende Brigade
Versie door Jeroen Strompf (overleg | bijdragen) op 24 okt 2024 om 14:59 (→‎Do I need this plugin?)
(wijz) ← Oudere versie | Huidige versie (wijz) | Nieuwere versie → (wijz)
Naar navigatie springen Naar zoeken springen

The WooCommerce Legacy REST API plugin enables an older version of the REST API for WooCommerce, which was designed to enable external applications and services to interact with WooCommerce stores programmatically. The REST API provides access to data such as orders, products, customers, and more, allowing developers to build integrations, mobile apps, and other systems that can manage WooCommerce data remotely.

Forced installation

This plugin is usually installed during a WooCommerce update, without user approval. The reviews for this plugin are unusually negative (1.4 out of 5 stars with 23 reviews). Main reasons (this is anecdotal):

  • Installed without consent
  • One installation on a site that doesn't use REST API at all [1]
  • Crashing sites.

Do I need this plugin?

Yes. As of 2024.10, this is needed for ShippyPro

REST API history

Legacy APIs

There are three legacy REST API versions:

  • v1 (Feb. 2014 - WooCommerce 2.1): Original version of the WooCommerce REST API. Endpoint URL: /wc-api/v1/
  • v2 (Aug. 2015 - WooCommerce 2.4): Introduced some improvements and updates to the original API. Endpoint URL: /wc-api/v2/
  • v3 (June 2016 - WooCommerce 2.6): Final version of the legacy API, which added additional features and improvements. Endpoint URL: /wc-api/v3/

WooCommerce 3.5 - Oct. 2018

With the introduction of WooCommerce 3.5 (Oct. 2018):

  • The API was refactored, and the newer version no longer used this /wc-api/ structure. Instead, it became part of the WordPress REST API infrastructure, using /wp-json/wc/v3/ as its endpoint URL
  • The Legacy REST API continued to function.

WooCommerce 9.0 - June 2024

With the introduction of WooCommerce 9.0 (June 2024):

  • New REST API endpoint for refunds: wc/v3/refunds [2]
  • Removal of the legacy REST API
  • Introduction of the WooCommerce Legacy REST API plugin, allowing users to continue using it, when needed [3]

Background

Functionalities of the Legacy API

  • Endpoints for Data: The legacy API offered various endpoints to access WooCommerce resources like products, orders, customers, coupons, etc. These allowed for the management and retrieval of store data
  • CRUD Operations: You could perform Create, Read, Update, and Delete operations on WooCommerce data through HTTP methods (GET, POST, PUT, DELETE)
  • JSON Format: Data was returned and accepted in JSON format, making it compatible with modern web services.

Authentication methods

  • The legacy REST API primarily used Basic Authentication, where API keys (consumer key and consumer secret) were passed as part of the request headers
  • It also supported OAuth 1.0a, which was more secure and used when sending sensitive data over non-SSL (though SSL is highly recommended)

Deprecation and transition

  • With the release of WooCommerce 3.5+, the legacy REST API became deprecated in favor of a more advanced and secure API. The new REST API uses modern authentication methods like OAuth 2.0 and has better performance and security features
  • Although WooCommerce has retained backward compatibility, new features and improvements are typically only introduced in the newer API.

Reasons to move away from the Legacy API

  • Security: The new WooCommerce REST API offers better security mechanisms compared to the legacy one, especially for handling sensitive data like payments
  • Support for Modern Features: The newer API supports a wider range of features and capabilities introduced in newer WooCommerce versions
  • Improved Authentication: The new API supports improved authentication standards, including OAuth 2.0, making it more secure and reliable.

When to use the Legacy API

Sometimes, it isn't obvious when to move to a newer version of a product. That's not the case here. However, there may be reasons to use the Legacy API:

  • When maintaining older WooCommerce stores that somehow haven't updated beyond version 3.x
  • Dealing with legacy integrations that still rely on the older endpoints.

See also

Sources