Using the REST API to Update Vehicle Listings in WordPress

The Inventory Presser dealership plugin was built with a feed-first mentality. Our software & services company feeds inventory updates and photos to hundreds of sites each day. Here’s how we fine-tune sites for efficient Vehicle Post Type updates using the WordPress REST API.

The REST API provides remote access to WordPress sites and their data. We extend the REST endpoints for posts and attachments to provide finer control over meta fields on vehicle posts and terms.

All the usual methods of importing and updating post data will work, too. Inventory Presser vehicles are posts, and plugins like WP All Import can import flat files and populate post meta values.

Is this the Right Guide for You?

This page describes how to construct HTTP web requests. The intended audience is software developers. Use this survey to find the best method of adding inventory:

Find out which method is right for you

Answer a few questions and find out which method will work best for your dealership.

If you want to build a WordPress REST API client to update vehicles, here’s what we do at Friday Systems…

Install and Activate the Plugin

Search for Inventory Presser in your site’s dashboard, or visit https://wordpress.org/plugins/inventory-presser/ to download the plugin.

Create a user and Application Password for authentication during updates

We create an administrator user account that will not be used by humans. Then, we generate an Application Password for that user.

  1. Needs capabilities to insert, update, and delete posts, media attachments, and taxonomy terms.
  2. Needs an Application Password generated to authenticate requests to the REST API.

* Can’t find Application Passwords on your users? WordFence disables Application Passwords by default.

If you’re a Friday Systems customer, you can stop here. Send us the site URL, user name, & application password, and we can begin updating the inventory.

Sample Requests

Use Basic Auth to provide the user name and application password you created earlier during POST or DELETE requests.

Vehicle Requests

Use the list of meta fields and an example vehicle post to build requests.

Insert a Vehicle

POST https://demo.inventorypresser.com/wp-json/wp/v2/inventory

List 100 Vehicles

GET https://demo.inventorypresser.com/wp-json/wp/v2/inventory?per_page=100

Retrieve or Update a Specific Vehicle

POST to update a vehicle by post ID. GET to retrieve a vehicle by post ID.

POST/GET https://demo.inventorypresser.com/wp-json/wp/v2/inventory/8171

Media Requests

Insert a Photo

Specify the meta fields on attachments and the parent post in the body of the request.

POST https://demo.inventorypresser.com/wp-json/wp/v2/media

Retrieve or Update a Specific Photo

POST to update a photo with the attachment post ID. GET to retrieve an attachment by post ID.

POST/GET https://demo.inventorypresser.com/wp-json/wp/v2/media/75370

List 100 Photos of a Specific Vehicle

Requires authentication.

GET https://demo.inventorypresser.com/wp-json/wp/v2/media?parent=8171&page=1&per_page=100

Other Requests

Declare an inventory update finished

When clients finish updating inventory, the feed complete endpoint should be used to notify plugins that vehicles have been updated. We’ve released a plugin for anyone using Rocket.net hosting that clears CDN caches after inventory updates: https://github.com/fridaysystems/invp-rocket-net

PUT https://demo.inventorypresser.com/wp-json/invp/v1/feed-complete