FD1 Client Protocol

FD1 Data Endpoint

This endpoint allows you to fetch tables of data and also filter and sort the results.

This endpoint requires a "v" packet, with v.table as a minimum.

FieldDescription
v.tableThe requested table of data you wish to access. This is typically something like logical.products meaning the logical view of products.
v.limitMaximum number of rows to return. Your requested limit may be restricted by controls on your login.

The output of fd1.data can be controlled using Parameter "qo" which defines a JSON object structure to return. "qo" is defined at the top level, it is not part of "v"

Examples

Requesting 3 products by pid, and having a custom JSON output object.

{
    a: "fd1.data",
    v: {
        table: "logical.products",
        limit: 3
    },
    qo: {
        pid:true,
        idstring: "physkey",
        description: true
    }
}

Requesting all products with pid between 1200 and 2000. A default collection of fields is returned

{
    a: "fd1.data",
    q: {
        "pid(>=)": 1200,
        "pid(<)": 2000
    },
    v: {
        table: "logical.products"
    }
}

Selecting all products, that have been sold today AND belong to a specific single department. This might be the base of a 'products sold today' report

{
    a: "fd1.data",
    v: {
        table: "logical.products[r_depid=@depid][sold today]",
        param: {
            depid: 2
        }
    }
}

Requesting a list of all known departments, and including as additional fields:

  1. Number of products assigned to each department
  2. Number of items sold today
  3. Total revenue for items sold today
.

{
    a: "fd1.data",
    rq: "deptsum",
    v: {
        table: "logical.departments"
    },
    qo: {
        depid: true,
        description: true,
        cnt: "products[r_depid=@depid]._count",
        cnt_sold_today: "products[r_depid=@depid][sold today]._count",
        revenue_today: "products[r_depid=@depid][sold today]._sum(line.totalprice)"
    }
}

Potential Output

{
    "rp":"deptsum",
    "data": {
        rows: [
            {
                depid: 17,
                description: "Fresh",
                cnt: 283,
                cnt_sold_today: 3411,
                revenue_today: 24573.29
            },
            {
                depid: 22,
                description: "Cleaning",
                cnt: 74,
                cnt_sold_today: 42,
                revenue_today: 381.10
            },
            ...

        ]
    }
}