FD1 Client Protocol

FD1 Client Protocol Examples

The examples below are a random collection of various ways in which FD1 can be used. We know that most developers don't read all the docs and look at examples first, so here they are. The examples show a variety of different techniques, and not all will be relevant in all cases.

Using Curl to read all products

curl "https://example-example.fieldpine.com/fd3/products.list"

Fetching Products

Using Javascript fetch to retrieve all products for a single department. As this is not using a websocket, the authorization details will need to be sent in an HTTP header.

The field "qo" is sent in the request so that the response is an array of objects with only the fields we require

[
    { "internal_id_n": 123, "internal_guid": "ABABABABABABABABA", "description": "Pineapple Slices", "sku": "PINSLICE" },
    { "internal_id_n": 456, "internal_guid": "BABABABABABABABXX", "description": "Loose Peanuts", "sku": "PEANUTS" }
]


let Request = {
    a: "products.list",
    q: {
        department: "fresh"
    },
    qo: {
        internal_id_n: "pid",
        internal_guid: "physkey",
        description: true
        sku: true
    }
}

fetch("/fd3/products.list", {
    method: "POST",
    headers: {
        x-api-key: ....
        content-type: "application/json"
    },
    body: JSON.stringify(Request)
}).then(function(rsp) { return rsp.json() })
  .then(function (data) {
    // data.rows is an array containing results
})