Reports & ads

Statistics

4 endpoints · https://pos.pages.fm/api/v1

View Markdown

Order statistics

GET/shops/{SHOP_ID}/analytics/sale

Get order statistics

Path parameters

SHOP_IDintegerrequired

Shop ID

Example: 4

Query parameters

sincestring · date-time

Start date

Example: "2024-01-01T00:00:00Z"
untilstring · date-time

End date

Example: "2024-12-31T23:59:59Z"
split_by[]array<string>

Group statistics by one or more dimensions. Each value is a <Table>.<field> key.

  • Time.hour / Time.day / Time.month / Time.year — by date bucket
  • Order.source / Order.order_sources — by order source / account
  • Order.status — by order status code
  • Order.warehouse_id — by warehouse
  • Order.post_id — by Facebook post
  • Order.partner_id — by shipping carrier
  • Order.marketplace_id — by e-commerce marketplace
  • Order.country_code / Order.province_id / Order.district_id / Order.commune_id / Order.region_filter — by shipping geography
  • Order.tag — by order tag
  • Order.is_wholesale / Order.is_livestream — wholesale / livestream flag
  • Order.livestream_manager_ids — by livestream manager
  • Order.total_price — by order total price bucket
  • Order.ads_or_normal / Order.ad_account_id / Order.ad_id — ad partitioning
  • User.id / User.sale_group / User.department_id — by staff / sale group / department
  • Customer.id / Customer.level_id / Customer.new — by customer / level / new vs. old
  • Variation.id / Variation.product_id — by variation / product
  • Variation.category / Variation.supplier / Variation.brand_id / Variation.tag — by product taxonomy
  • Variation.price_range / Variation.quantity_range — by product price/quantity bucket
  • Variation.upsale / Variation.quantity — upsell flag / sold quantity
  • UTM.p_utm_source / UTM.p_utm_campaign / UTM.p_utm_medium / UTM.p_utm_term / UTM.p_utm_content — by UTM tag
  • Promotion.default / Promotion.advance / Promotion.combo — by promotion / combo
  • Ads.ad_id / Ads.ad_set_id / Ads.ad_campaign_id — by ad / ad set / campaign
Values"Time.hour""Time.day""Time.month""Time.year""Order.source""Order.order_sources""Order.status""Order.warehouse_id""Order.post_id""Order.partner_id""Order.marketplace_id""Order.country_code""Order.province_id""Order.district_id""Order.commune_id""Order.region_filter""Order.tag""Order.is_wholesale""Order.is_livestream""Order.livestream_manager_ids""Order.total_price""Order.ads_or_normal""Order.ad_account_id""Order.ad_id""User.id""User.sale_group""User.department_id""Customer.id""Customer.level_id""Customer.new""Variation.id""Variation.product_id""Variation.category""Variation.supplier""Variation.brand_id""Variation.tag""Variation.price_range""Variation.quantity_range""Variation.upsale""Variation.quantity""UTM.p_utm_source""UTM.p_utm_campaign""UTM.p_utm_medium""UTM.p_utm_term""UTM.p_utm_content""Promotion.default""Promotion.advance""Promotion.combo""Ads.ad_id""Ads.ad_set_id""Ads.ad_campaign_id"
filterobject

Filter applied to the order set. Object keyed by <Table>.<field>; each value is an array of strings. Append _exclude to a key to negate it (e.g. Order.status_exclude, Variation.category_exclude). Append _and to AND-combine multi-valued list filters (e.g. Variation.tags_and). Common keys:

  • Variation.id / Variation.product_id — by variation / product
  • Variation.category / Variation.supplier / Variation.brand_id / Variation.brand — by product taxonomy
  • Variation.tag / Variation.tags / Variation.attribute — by product tag / attribute
  • Variation.price_range / Variation.quantity_range / Variation.quantity — by product price/quantity
  • Variation.upsale / Variation.one_time_product / Variation.is_bonus_product / Variation.product_price_of_zero / Variation.unlink_ecommerce — flag filters
  • Order.source / Order.source_exclude / Order.order_sources — order source
  • Order.status — order status code
  • Order.warehouse_id / Order.post_id / Order.partner_id / Order.shop_partner_id / Order.marketplace_id — operational filters
  • Order.country_code / Order.province_id / Order.district_id / Order.commune_id / Order.region_filter / Order.region_filter_phil — shipping geography
  • Order.tag / Order.is_wholesale / Order.is_livestream / Order.received_at_shop / Order.is_upsale_order — order flags
  • Order.total_price / Order.revenue — by total/revenue bucket
  • Order.ad_id / Order.ads_source / Order.ad_account_id / Order.ads_or_normal — ads filters
  • Order.order_currency — order currency
  • Order.id / Order.project — by order id / project
  • Order.p_utm_source / Order.p_utm_campaign / Order.p_utm_medium / Order.p_utm_term / Order.p_utm_content / Order.utm_affiliate / Order.link — UTM filters
  • Order.instant / Order.N24H / Order.GSGN — service partner filters
  • Order.livestream_manager_id / Order.livestream_manager_ids — livestream manager
  • User.id / User.sale_group / User.department_id / User.pke_mkter / User.assigning_seller_id / User.assigning_care_id / User.item_assign_seller_id — staff filters
  • Customer.id / Customer.level_id / Customer.gender / Customer.tag / Customer.conversation_tags / Customer.new / Customer.referral_code — customer filters
  • Promotion.default / Promotion.advance / Promotion.id / Promotion.combo — promotion filters
success_statusstring

Success status

Example: "send_to_partner"
success_recordstring

Success record

Example: "inserted_at"
user_typestring

User type

Example: "create"
returned_recordstring

Returned record

Example: "inserted_at"
select_fields[]array<string>

Select fields

Responses

object
dataarray<object>

Statistics data

successboolean

Success status

Request
curl "https://pos.pages.fm/api/v1/shops/{SHOP_ID}/analytics/sale?api_key=API_KEY"
Response 200
{
  "success": true,
  "data": [
    {
      "Time.day": "2020-07-22",
      "returned": null,
      "success": {
        "cod": 1710000,
        "discount": 0,
        "order_count": 3,
        "price": 1800000,
        "product_count": 18,
        "shipping_fee": 0,
        "custom_formula_d6ae-ad02-be3d-b26e-3f65-d497-33c4": 1000000
      }
    },
    {
      "Time.day": "2020-07-27",
      "returned": null,
      "success": {
        "cod": 570000,
        "discount": 0,
        "order_count": 1,
        "price": 600000,
        "avg_price": 600000,
        "product_count": 6,
        "shipping_fee": 0,
        "custom_formula_d6ae-ad02-be3d-b26e-3f65-d497-33c4": 1000000
      }
    },
    {
      "Time.day": "2020-07-28",
      "returned": null,
      "success": {
        "cod": 5130000,
        "discount": 0,
        "order_count": 9,
        "price": 5400000,
        "avg_price": 600000,
        "product_count": 54,
        "shipping_fee": 0,
        "custom_formula_d6ae-ad02-be3d-b26e-3f65-d497-33c4": 1200000
      }
    },
    {
      "Time.day": "2020-07-30",
      "returned": null,
      "success": {
        "cod": 570000,
        "discount": 0,
        "order_count": 1,
        "price": 600000,
        "avg_price": 600000,
        "product_count": 6,
        "shipping_fee": 0,
        "custom_formula_d6ae-ad02-be3d-b26e-3f65-d497-33c4": 1200000
      }
    }
  ]
}

List of customized formulas

GET/shops/{SHOP_ID}/analytics/get_list_formula

Get list of customized formulas

Path parameters

SHOP_IDintegerrequired

Shop ID

Example: 4

Responses

object
dataarray<object>

List of formulas

successboolean

Success status

Request
curl "https://pos.pages.fm/api/v1/shops/{SHOP_ID}/analytics/get_list_formula?api_key=API_KEY"
Response 200
{
  "success": true,
  "data": [
    {
      "formula": "{price} - {shipping_fee}",
      "id": "0ea7-bc72-ae51-0769-a7c9-ca34-fff6",
      "name": "tien hang - phi ship",
      "unit": "currency"
    },
    {
      "formula": "{revenue} + {transfer_money}",
      "id": "3db3-72a7-c426-066a-4eed-a63b-be49",
      "name": "doanh thu + ck$",
      "unit": "currency"
    }
  ]
}

List of analytic fields

GET/shops/{SHOP_ID}/analytics/get_analytic_fields

Get list of analytic fields

Path parameters

SHOP_IDintegerrequired

Shop ID

Example: 4

Responses

object
dataarray<object>

List of analytic fields

successboolean

Success status

Request
curl "https://pos.pages.fm/api/v1/shops/{SHOP_ID}/analytics/get_analytic_fields?api_key=API_KEY"
Response 200
{
  "success": true,
  "data": [
    {
      "id": "price",
      "name": "Tiền hàng"
    },
    {
      "id": "avg_price",
      "name": "Giá bán trung bình"
    },
    {
      "id": "shipping_fee",
      "name": "Phí VC thu của khách",
      "description": "Tiền vận chuyển thu của khách."
    },
    {
      "id": "discount",
      "name": "Chiết khấu",
      "description": "Tổng số tiền giảm giá trên từng sản phẩm."
    },
    {
      "id": "product_count",
      "name": "SL bán thực",
      "description": "Hàng bán ra đã trừ SL hoàn/đổi trả"
    },
    {
      "id": "close_rate",
      "name": "Tỷ lệ chốt",
      "description": "Số đơn chốt / (Tổng số đơn - SL đơn xoá)."
    },
    {
      "id": "commissions",
      "name": "Hoa hồng",
      "description": "Hoa hồng cho nhân viên, có thể cài đặt trong phần cấu hình."
    }
  ]
}

List of custom statistic folders

GET/shops/{SHOP_ID}/statistic_custom/folders

Get list of custom statistic folders and their report items (folder_items). Each folder groups related custom reports configured for the shop (e.g. revenue, orders, products, finance, debts).

Path parameters

SHOP_IDintegerrequired

Shop ID

Example: 4

Responses

object
successboolean

Success status

foldersarray<object>

List of custom statistic folders

Request
curl "https://pos.pages.fm/api/v1/shops/{SHOP_ID}/statistic_custom/folders?api_key=API_KEY"
Response 200
{
  "success": true,
  "folders": [
    {
      "name": "OtherReports",
      "label": "Báo cáo khác",
      "order": -1,
      "shop_id": 4,
      "creator_id": null,
      "last_editor_id": null,
      "can_remove": false,
      "is_removed": null,
      "setting": null,
      "total_price_ranges": null,
      "inserted_at": "2024-02-26T08:21:01",
      "updated_at": "2024-02-26T08:21:01",
      "folder_items": [
        {
          "id": "9d80f8b9-1c68-4026-81e6-70ed2381d360",
          "name": "pages.shop.statistic.salesStatistics",
          "label": "Doanh số",
          "description": null,
          "folder_name": "employee",
          "parent_id": null,
          "order": 0,
          "shop_id": 4,
          "creator_id": null,
          "last_editor_id": null,
          "can_remove": false,
          "is_removed": null,
          "attributes": null,
          "fields": [
            "total_order_count",
            "order_count",
            "price",
            "shipping_fee",
            "discount",
            "capital",
            "product_count"
          ],
          "filter": null,
          "children": [],
          "charts": null,
          "compare_ranges": {
            "chart": "bar-chart",
            "field": "product_count",
            "ranges": [
              {
                "range": "7"
              },
              {
                "range": "-7"
              }
            ]
          },
          "fill_color": false,
          "setting": {
            "returned_record": "success_record",
            "success_record": "inserted_at",
            "success_status": 0,
            "user_type": "assign"
          },
          "sort_by_field": null,
          "time_range": [
            "90"
          ],
          "users_can_see": null,
          "inserted_at": "2024-02-26T08:21:01",
          "updated_at": "2024-02-26T08:21:01"
        }
      ]
    },
    {
      "name": "Revenue",
      "label": "Báo cáo doanh thu",
      "order": 1,
      "shop_id": 4,
      "creator_id": null,
      "last_editor_id": null,
      "can_remove": false,
      "is_removed": null,
      "setting": null,
      "total_price_ranges": null,
      "inserted_at": "2023-09-20T03:01:25",
      "updated_at": "2023-09-20T03:01:25",
      "folder_items": [
        {
          "id": "9783d2e9-d973-4f6f-a735-f5883f4e678f",
          "name": "commons.time",
          "label": "Thời gian",
          "description": null,
          "folder_name": "Revenue",
          "parent_id": null,
          "order": 0,
          "shop_id": 4,
          "creator_id": null,
          "last_editor_id": null,
          "can_remove": false,
          "is_removed": null,
          "attributes": [
            "Variation.product_id"
          ],
          "fields": [
            "success_order_count",
            "returned_order_count",
            "price",
            "sales",
            "revenue",
            "capital",
            "profit"
          ],
          "filter": [],
          "children": [],
          "charts": [
            {
              "field": "success_order_count",
              "top": "all",
              "type": "bar-chart",
              "width": 100
            }
          ],
          "compare_ranges": {
            "chart": "bar-chart",
            "field": "profit",
            "ranges": [
              {
                "range": "7"
              },
              {
                "range": "-7"
              }
            ]
          },
          "fill_color": false,
          "setting": {
            "returned_record": "success_record",
            "success_record": "updated_at",
            "success_status": 1,
            "user_type": "update"
          },
          "sort_by_field": {
            "multi": [
              {
                "columnKey": "product_count",
                "field": "product_count",
                "order": "descend"
              }
            ]
          },
          "time_range": [
            "30"
          ],
          "users_can_see": null,
          "inserted_at": "2023-09-20T03:01:25",
          "updated_at": "2026-05-05T04:33:58"
        }
      ]
    }
  ]
}