Welcome to Metrics API
Why a Metrics API by Commerce Layer and how to get started with it
Commerce Layer 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:
An organization from which you want to get the metric data.
Some integration or webapp API credentials that provide you with a valid access token to authenticate to the Metrics API endpoints.
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 account and try the Commerce Layer core API while reading the documentation. 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 Discord 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 collection 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 plugin of our CLI.
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 schema 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 formats that are easier for LLMs to process, ingest, and work with, you can leverage the following llms.txt files.
Index — 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:
https://docs.commercelayer.io/metrics/llms.txtFull content — contains the full content of the Metrics API docs site in one file that can be passed to LLMs as context:
https://docs.commercelayer.io/metrics/llms-full.txtMCP 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 Desktop, Cursor, and VS Code extensions to answer questions using the docs, we expose via HTTP an MCP server at the following URL:
https://docs.commercelayer.io/metrics/~gitbook/mcpVisiting the URL above in your browser will result in an error. Instead, you can share this with tools that can make HTTP requests, like LLMs or IDEs.
Last updated

