5 min read

Commerce APIs Explained - What Are They?

Most eCommerce companies start their journey with Shopify, BigCommerce, Prestashop or WooCommerce.

Tim Davidson
Author
Tim Davidson

Most eCommerce companies start their journey with Shopify, BigCommerce, Prestashop or WooCommerce. These monolithic entry point platforms can be restrictive for businesses that muscle their way through the competition and find significant growth. For example, it's hard to plug in all the superb artificial intelligence, API-first services that are popping up these days.

Inflexibility and the push to "go to the next level" is why many online retailers are turning their attention to a MACH (Microservice, API-first, Cloud-native, Headless) architecture. This approach means they're not bound to use one tool like Shopify. They can combine the best-of-breed technologies into a unified system, all connected through API.

Explaining it like this makes the setup pretty straightforward, but developing a headless store means building a set of commerce APIs into a custom frontend so customers can do all the things they would normally expect to.

Some eCommerce services like Commerce Layer, Commercetools, Crystallize, and Shopify has excellent, full-featured commerce APIs that you can leverage to build pretty much any experimental eCommerce store. Other platforms like Wix, Squarespace and Weebly are kind of garbage and not worth working with.

What are Commerce APIs?

We've touched on why commerce APIs are important but have yet to expand on what commerce APIs are.

Commerce APIs are a set of organised functions that capture all the "things" an eCommerce website can do. This includes authenticating a user and logging in, searching for a product, recording a sale, allowing users to check their purchase history, recording shipping details, etc.

Here's a handful of the standard commerce API collections:

  • Authorisation API
  • Authentication API
  • Customers API
  • Catalogue API
  • Inventory API
  • Shipping API
  • Cart API
  • Storefront API
  • Tax API
  • Price lists API

It's worth noting that Crystallize and Commercelayer are speciality eCommerce engines built for larger-scale projects and follow a less standard commerce API structure.

Each API collection we listed above is broken down into a series of operations. For example, the BigCommerce Catalog API can create products, add product images, add variations to products, add custom fields, add product reviews, and a ton more.

A good way to think about it is that the API endpoints are neatly organized collections of functionality that allow a third-party application to perform pretty much anything a native monolithic shop could do.

What does using a Commerce API look like?

Depending on the API, there will be different technologies involved in interacting with the API. The most common way to interface with a commerce API is through REST, but GraphQL is becoming quite popular too.

Continuing with our BigCommerce product review example, this is what the code on your headless website would look like:

POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/v3/catalog/products/{{product_id}}/reviews

Accept: application/json
Content-Type: application/json
X-Auth-Token: {{ACCESS_TOKEN}}

{
  "title": "Great Coffee Mug",
  "text": "This coffee mug kept my liquids hot for several hours.",
  "status": "pending",
  "rating": 5,
  "email": "testing@bigcommerce.com",
  "name": "BigCommerce",
  "date_reviewed": "2018-07-20T17:45:13+00:00"
}

This snippet shows a POST sent to the BigCommerce API with the title, text, status, rating, email, name, and date of review for the product review.

Calling a commerce API happens through HTTP methods, which most people would be familiar with as the protocol used to access web pages.

Why use an API for eCommerce?

There are a few use cases where working with eCommerce APIs is necessary to build a store that does something better, faster, or more complex than possible with a typical monolithic setup.

Platforms like Shopify are pretty flexible, but if a big retailer like Walmart comes along and says to Shopify, "I want my store to load ten times as quickly, and I want the content to be personalized to shoppers based on their location and spending habits". Shopify would probably say, "sorry, that's not what we do".

Walmart knows what they want, but they want to build something other than an eCommerce platform from scratch. They want a more flexible solution that can blend in with their existing technology and not be restricted. This situation is the most common use case for commerce APIs.

Another great example is a blog that's been pumping out high-quality content for ten years and wants to expand its monetization strategy to sell products inside its content. They can't risk the performance hit a plugin would bring. Instead, they can use a commerce API and build a custom UI to facilitate a unique purchasing process.

I've covered these arguments in much deeper detail on the topic of why a business would consider upgrading to headless eCommerce, so I won't repeat myself by going any deeper.

What makes for a good commerce API?

The criteria for a great commerce API are pretty straightforward. First of all, all functionality should be available through REST APIs. Even if GraphQL is gaining popularity, it's still a pain in the ass to work on smaller projects (that's where tRPC is an ideal replacement).

Secondly, it needs to tick these boxes:

  • Complete
  • Good developer experience & document quality
  • Event-driven architecture

Complete

It sounds like an obvious place to start, but some incredibly popular eCommerce APIs aren't complete. The standard Shopify API is intentionally incomplete. They don't make user authentication available, so users are forced to checkout on Shopify's domain through the standard cart, which is a terrible experience. Shopify Plus allows access to this API, but it sits behind a $2,000 paywall.

Completeness is obviously essential. The whole reason behind leveraging commerce APIs is to do things that a standard store can't do. Services like Teachable, Squarespace and Wix don't get past this requirement and shouldn't be considered when weighing up which commerce API to use.

Developer experience & documentation quality

Not all APIs are made equal. Some, like Commercelayer, provide an excellent developer experience. Have questions about working with the API? No problem; the documentation is high quality and extensive. The team are known for being lightning-quick to update their docs when changes are made to the API.

Event-Driven Architecture

There's no rulebook on how API-first eCommerce companies should organize a massive collection of exposed commerce functionality into a set of APIs. An event-driven architecture is a tidy way to handle this problem and makes it much simpler for developers to figure out how to implement it.

What is an eCommerce API example?

Here are a few good eCommerce API document sources to check out:

Each of these docs provides hundreds of examples of individual eCommerce API examples.

Frequently asked questions

What's an eCommerce microservice example?

One of our clients, aftco.com, is an excellent example of an eCommerce store set up with microservices. They're using Shopify as an eCommerce backend, Klevu for product recommendations, Klayvio for eCommerce marketing, Contentful as a CMS and Next.js as the frontend framework.

If you need more examples, head over to the showcase page for Prismic, Contentful, Commercelayer, Commercetools, or any of the services listed in the MACH alliance.

What does a "Commerce API" mean?

Commerce APIs are organised collections of operations and functionality authenticated third-party applications can access. The most common example is a headless eCommerce store that pairs something like Shopify as an eCommerce backend with a custom Next.js frontend that handles all the regular eCommerce features by speaking with Shopify's APIs.

Wrapping up

Commerce APIs aren't going away anytime soon. It's likely that enterprise technologies like Microservices, API-first, Cloud-native and Headless will continue to head downmarket, becoming a realistic investment for more than just enterprise companies.

You should now understand what commerce APIs are and if they're relevant to your business!

Still have questions? Feel free to leave a comment below, and we'll get back to you in a day or two.

Written by
Tim Davidson

Tim Davidson

Tim is the face of the company. When you want to kick off a new project, or an update on your existing project, Tim is your man!

Read more on the subject

Digital Product Design Process

Tim Davidson

How To Improve UX Using Micro-Interactions

Tim Davidson

SaaS Design: A Mobile-First Approach

Tim Davidson

Don’t miss out on the latest stories!

Sign up for my newsletter to receive the latest news from the blog, you’ll get pinged every few months with a digest from the tech world.

Thank you for reaching out!