ocapi-shop Insights API
Storefront analytics and the newsletter's subscribers.
Storefront analytics and the newsletter's subscribers.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/ocapi-shop:ocapi-shop-insights-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Ocapi Insights API
version: '1'
description: 'Manage Ocapi stores from your own code: the catalog, categories, orders, images, the storefront''s
design and the store''s settings. It is the same API the Ocapi CLI, the iOS and Android apps and
the MCP server use.
Changes go live on the storefront as soon as a request succeeds. To prepare products before
shoppers see them, create them with `hidden: true` and publish them later. The storefront''s
design is the exception: changes to it go to a draft, which Publish storefront makes live.
## Authentication
The API uses OAuth 2.1 with the authorization code flow and PKCE. Discovery metadata is at
`/.well-known/oauth-authorization-server`, clients
register themselves at `/oauth/register`, and tokens come from `/oauth/token`.
Send the access token on every request:
```http
Authorization: Bearer
```
Access tokens last one hour; use the refresh token to get a new one. A token carries one or
both scopes:
- **`read`** allows `GET` requests.
- **`write`** allows everything else: creating, updating, reordering and deleting.
A request beyond the token''s scope gets `403 insufficient_scope`.
## Conventions
- **IDs** are prefixed by type: `str_` stores, `prd_` products, `cat_` categories, `ord_` orders,
`col_` collections, `pag_` pages, `lnk_` links, `dom_` domains, `usr_` users, `inv_` invitations, `whk_` webhooks.
- **Prices** are plain numbers in the store''s currency (`currency` on the store), not cents.
- **Timestamps** are ISO 8601 in UTC.
- **Lists** return `{ "data": [...], "next_page": 2 }`. Pass `page` and `per_page` (up to 100,
default 50); `next_page` is `null` on the last page.
- **Updates** with `PATCH` change only the fields you send.
## Errors
Every error has the same shape:
```json
{
"error": {
"code": "invalid",
"message": "Name can''t be blank",
"details": { "name": ["can''t be blank"] }
}
}
```
| Status | Code | Meaning |
| --- | --- | --- |
| 400 | `bad_request` | The body is malformed or a required parameter is missing |
| 401 | `unauthorized` | The token is missing, invalid or expired |
| 403 | `insufficient_scope` | The token can only read |
| 402 | `plan_limit_reached` | The change would add more than the store''s plan allows (products, images per product or shoppable videos); `details` has `limit`, `plan`, `allowed`, `used`, `upgrade_plan` and `upgrade_url`, where the owner upgrades (both left out when no plan allows more) |
| 404 | `not_found` | The resource doesn''t exist or belongs to a store you can''t reach |
| 422 | `invalid` | Validation failed; `details` maps each field to its messages, with dotted keys for nested fields (`items.0.quantity`) |
| 426 | `upgrade_required` | An Ocapi app build is too old; `details` has `min_version` and `update_url` |
| 429 | `rate_limited` | Over 300 requests in a minute for one sign-in; retry after a minute |
| 503 | `unavailable` | Uploads or image imports are temporarily unavailable |
`message` is written to be shown to people as is.
Plan limits only stop additions: a store over a limit after moving to a smaller plan keeps its
products, images and videos, and can still edit or remove them. During the free trial a store has
the Pro plan''s limits.'
servers:
- url: https://dashboard.ocapi.shop
security:
- bearer: []
tags:
- name: Insights
description: Storefront analytics and the newsletter's subscribers.
paths:
/api/v1/stores/{store_id}/subscribers:
parameters:
- $ref: '#/components/parameters/StoreId'
get:
operationId: listSubscribers
tags:
- Insights
summary: List newsletter subscribers
description: The emails the storefront's newsletter block collected, newest first, with each one's status. Mail only those whose status is subscribed.
parameters:
- $ref: '#/components/parameters/Page'
- $ref: '#/components/parameters/PerPage'
responses:
'200':
description: A page of subscribers
content:
application/json:
schema:
$ref: '#/components/schemas/SubscriberPage'
/api/v1/stores/{store_id}/metrics:
parameters:
- $ref: '#/components/parameters/StoreId'
- $ref: '#/components/parameters/From'
- $ref: '#/components/parameters/To'
get:
operationId: getMetrics
tags:
- Insights
summary: Get storefront metrics
description: Visits, clicks and WhatsApp messages on the storefront between two dates. Numbers can lag a few minutes.
responses:
'200':
description: The totals
content:
application/json:
schema:
$ref: '#/components/schemas/Metrics'
'422':
$ref: '#/components/responses/Invalid'
'503':
$ref: '#/components/responses/Unavailable'
/api/v1/stores/{store_id}/sales:
parameters:
- $ref: '#/components/parameters/StoreId'
- $ref: '#/components/parameters/From'
- $ref: '#/components/parameters/To'
get:
operationId: getSales
tags:
- Insights
summary: Get sales and profit
description: 'The store''s sales between two dates, from its own orders: revenue, orders, average order, units and best sellers. Owners also get the gross profit and margin, overall, by product and by category, from the cost of each product.'
responses:
'200':
description: The sales
content:
application/json:
schema:
$ref: '#/components/schemas/Sales'
'422':
$ref: '#/components/responses/Invalid'
/api/v1/stores/{store_id}/metrics/{table}:
parameters:
- $ref: '#/components/parameters/StoreId'
- name: table
in: path
required: true
schema:
type: string
enum:
- top_products
- top_links
- top_videos
- by_country
- by_referrer
description: The ranking
- $ref: '#/components/parameters/From'
- $ref: '#/components/parameters/To'
- name: by
in: query
schema:
type: string
enum:
- views
- messages
- clicks
- watch_time
description: 'What to rank by; the table''s first measure when left out. top_products: views or messages. top_links: views. top_videos: views or watch_time (average percent watched). by_country and by_referrer: views or clicks.'
get:
operationId: getMetricsTable
tags:
- Insights
summary: Get a storefront ranking
description: The storefront's top products, links or videos, or its visitors by country or referrer, between two dates.
responses:
'200':
description: The ranking
content:
application/json:
schema:
$ref: '#/components/schemas/MetricsTable'
'404':
$ref: '#/components/responses/NotFound'
'422':
$ref: '#/components/responses/Invalid'
'503':
$ref: '#/components/responses/Unavailable'
components:
schemas:
MetricsTable:
type: object
required:
- from
- to
- by
- data
properties:
from:
type: string
format: date
to:
type: string
format: date
by:
type: string
data:
type: array
description: Highest first
items:
type: object
required:
- key
- name
- value
properties:
key:
type: string
description: 'What is ranked: a product, link or video ID, a country code or a referrer'
name:
type:
- string
- 'null'
description: The product's or link's name, while it exists
value:
type: number
Metrics:
type: object
required:
- from
- to
- visits
- unique_visitors
- clicks
- click_rate
- average_session_seconds
- whatsapp_messages
properties:
from:
type: string
format: date
to:
type: string
format: date
visits:
type: integer
description: Storefront sessions
unique_visitors:
type: integer
clicks:
type: integer
description: Visitors who clicked something (a product
a link): null
click_rate:
type: number
description: Clicks per visitor, from 0 to 1
average_session_seconds:
type: integer
whatsapp_messages:
type: integer
description: Visitors who started a WhatsApp message to the store
Sales:
type: object
required:
- from
- to
- revenue
- orders_count
- average_order
- units_sold
- tips
- top_products
properties:
from:
type: string
format: date
to:
type: string
format: date
revenue:
type: number
description: 'What paid orders took in: their totals, shipping and tips included, tax left out. An order whose deposit is paid (partially_paid) counts at its full total; `collected` is what came in'
collected:
type: number
description: 'What customers actually paid of those orders so far, tax included: a deposit, not its balance'
balance_due:
type: number
description: The balances still due after deposits on those orders
orders_count:
type: integer
description: Orders placed, paid or not, cancelled ones left out
average_order:
type:
- number
- 'null'
description: Revenue per paid order; null without paid orders
units_sold:
type: integer
tips:
type: number
description: The part of revenue customers gave as tips
top_products:
type: array
description: The best sellers by revenue
items:
type: object
required:
- title
- units
- revenue
properties:
title:
type: string
units:
type: integer
revenue:
type: number
profit:
type: object
description: 'Only for the store''s owners. Gross profit on the paid items whose cost was known when they were ordered: what they sold for after discounts and without tax, less their cost. Shipping, tips, gift cards, and cancelled, refunded or charged back orders are left out.'
required:
- gross_profit
- margin
- net_sales
- cost
- uncosted_revenue
- by_product
- by_category
properties:
gross_profit:
type: number
margin:
type:
- number
- 'null'
description: gross_profit over net_sales, from 0 to 1; null without costed sales
net_sales:
type: number
description: What the items with a cost sold for
cost:
type: number
description: What those items cost
uncosted_revenue:
type: number
description: What items without a cost sold for, left out of the profit; set their products' cost to count them
by_product:
type: array
items:
$ref: '#/components/schemas/ProfitLine'
description: The 10 most profitable products
by_category:
type: array
items:
$ref: '#/components/schemas/ProfitLine'
description: Most profitable first
ProfitLine:
type: object
required:
- title
- units
- net_sales
- cost
- gross_profit
- margin
properties:
title:
type:
- string
- 'null'
description: The product, or the category (null for products without one)
units:
type: integer
net_sales:
type: number
description: What the units sold for
after discounts and without tax: null
cost:
type: number
description: What the units cost the merchant when ordered
gross_profit:
type: number
margin:
type:
- number
- 'null'
description: gross_profit over net_sales, from 0 to 1 (negative at a loss); null without sales
Error:
type: object
description: The body of every error response
required:
- error
properties:
error:
type: object
required:
- code
- message
properties:
code:
type: string
description: unauthorized, insufficient_scope, not_found, invalid, bad_request, rate_limited, unavailable, upgrade_required or plan_limit_reached
message:
type: string
description: Readable by people and models
details:
type: object
description: 'Field errors ({ field: [messages] }), min_version and update_url for upgrade_required, or for plan_limit_reached limit (products, images_per_product, videos or social_posts_per_day), plan (basic is Starter, plus is Pro), allowed, used, upgrade_plan and upgrade_url (both left out when no plan allows more)'
SubscriberPage:
type: object
required:
- data
- total
- next_page
properties:
data:
type: array
items:
type: object
required:
- email
- subscribed_at
- status
properties:
email:
type: string
subscribed_at:
type: string
format: date-time
description: When the address signed up
status:
type: string
enum:
- subscribed
- pending
- unsubscribed
- bounced
description: Only subscribed addresses confirmed their sign-up and get the store's emails. pending ones haven't confirmed yet (double opt-in); bounced ones can't receive email.
total:
type: integer
description: Subscribers in all
next_page:
type:
- integer
- 'null'
description: The next page number, or null on the last page
parameters:
Page:
name: page
in: query
schema:
type: integer
minimum: 1
default: 1
description: Page number; follow `next_page` from the previous response
From:
name: from
in: query
schema:
type: string
format: date
description: 'First day, as 2026-01-31; with to. Both left out: the last 30 days'
PerPage:
name: per_page
in: query
schema:
type: integer
minimum: 1
maximum: 100
default: 50
description: Results per page
To:
name: to
in: query
schema:
type: string
format: date
description: Last day, included; at most 366 days after from
StoreId:
name: store_id
in: path
required: true
schema:
type: string
pattern: ^str_[0-9a-z]{26}$
description: The store's ID, from List stores
example: str_01k70000000000000000000001
responses:
Invalid:
description: Validation failed; details lists the problems by field
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
NotFound:
description: Not found, or in a store you can't reach
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Unavailable:
description: Temporarily unavailable; retry in a minute
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
securitySchemes:
bearer:
type: http
scheme: bearer
description: An OAuth access token. See Authentication above for how to get one.