Welcome to Metrics API

Why a Metrics API by Commerce Layer and how to get started with it

Commerce Layerarrow-up-right is a transactional commerce API for international brands. It lets you make any digital experience shoppable, anywhere.

As an ecommerce platform ourselves, we're aware of how much ecommerce metrics are essential to merchants' ability to make informed, data-driven decisions. When running an online store, it’s important to keep an eye on your data history to see how your business is doing. Ecommerce metrics are a big part of this, as well as a source of rich insights that can form the basis for your future sales and marketing strategies.

That's why we decided to develop our own Metrics API that enables you to extract almost any kind of data information from your Commerce Layer's organization order, return, or cart history. By querying the Metrics API you'll be able to gather and aggregate useful data that you can leverage in different ways, such as:

  • creating your own organization reports

  • building custom metrics dashboards

  • set up metric-based alerts

  • send metric data to any open-source or in-house developed tool, library, or framework

... and more.

Create a Commerce Layer account

To use our Metrics API and get meaningful data information from it you need a Commerce Layer account. Specifically:

If you already have an organization properly configured and up and running you can start making requests to the Metrics API endpoints right away. Otherwise, the best way to get started is to create an accountarrow-up-right and try the Commerce Layer core API while reading the documentationarrow-up-right. Remember that Commerce Layer is free for developers, and it will be forever. 😉

Let's get started!

Now, you can take the time to explore the rest of this guide, check the API reference any time you need, and get the most out of the tons of information the Metrics API enables you to get from your ecommerce data.

For everything else, join us on Discordarrow-up-right and feel free to ask any questions to the team or get involved in the conversation with the rest of our developers' community.

Resources

Do you prefer to get your feet wet in the first place, start playing with the Metrics API directly, and get back to the docs at your leisure? We've got you covered.

Postman collection

Fork the Metrics API public Postman collectionarrow-up-right and make all the tests you need. We selected a set of real-life use cases and common metrics and stats you may want to extract from your real organization data — go through them and get an idea of what you can do with the Metrics API!

Helper endpoints

Don't forget to check our helper endpoints: if your use case is in this list you can get the data analysis you need with a very simple query, in a snap.

CLI plugin

You can use Commerce Layer Metrics API (performing all the available queries, using filters, and more) directly from the command line as well. To do that, leverage the Metrics pluginarrow-up-right of our CLIarrow-up-right.

OpenAPI schema

Building off a common spec enables collaborative, design-first development practices. Since we are iteratively improving our APIs, utilizing an API schema as a source of truth is vital to conform to API style and governance policies. Feel free to leverage the Metrics OpenAPI schemaarrow-up-right to build mock servers, auto-generate code, SDKs, and implement contract testing.

LLM-friendly text files

Large Language Models are becoming increasingly important for information retrieval and knowledge assistance. To make Commerce Layer Metrics API documentation content available in text-based formatsarrow-up-right that are easier for LLMs to process, ingest, and work with, you can leverage the following llms.txt files.

  • Indexarrow-up-right — contains an index of all the page URLs and titles of the Metrics API docs site, providing a comprehensive list of all available markdown-formatted pages:

  • Full contentarrow-up-right — contains the full content of the Metrics API docs site in one file that can be passed to LLMs as context:

circle-info

Following a clear separation of concerns, each Commerce Layer API docs site has its own LLM files. The ones above index information about Metrics API only (Getting started, and API reference). Check also: Core API, Provisioning API, and Rules Engine.

MCP server

Model Context Protocol gives AI tools a structured way to discover and retrieve your docs as resources — no scraping required. To allow AI assistants to access Commerce Layer Metrics API's documentation content directly, making it easy for tools like Claude Desktoparrow-up-right, Cursorarrow-up-right, and VS Codearrow-up-right extensions to answer questions using the docs, we expose via HTTP an MCP server at the following URL:

circle-exclamation
circle-info

Following a clear separation of concerns, each Commerce Layer API docs site has its own MCP server so that you can connect, activate, and deactivate them based on your needs. The one above is related to Metrics API only (Getting started, and API reference). Check also: Core API, Provisioning API, and Rules Engine.

Last updated