microappdata

description

Returns data from a Microapp. A filter can be applied to query the Microapp. In addition a limit can be used to improve performance. A default microapp data limit is in the server settings. A maximum value must be chosen to get all the rows.

parameters

The X-Auth-Token and X-User-Id are derived from the values authToken and userId returned from the login endpoint and are used in the HTTP header.

Resource

{
	"microAppID":"<insert microapp id here>"
}

response

A JSON document with the Microapp data.

example

Only the microAppID needs to be specified, in the simplest case for fetching all the data in a Microapp. It’s value can be found on the properties page of the Microapp in the editor.

Example of fetching all data from a Microapp:

POST /api/microappdata
X-Auth-Token: <token goes here>
X-User-Id: <userID goes here>

{
	"microAppID":"<insert microapp id here>"
}

filter example

A filter can be applied to narrow the results of the fetch using the optSearchFilters array. In the optSearchFilters the resourceID is the same as the microappid. The fieldID is an identifier that corresponds to the Field Name. It can be found in the field properties in the editor.

Example of fetching data from a microapp with a filter:

POST /api/microappdata
X-Auth-Token: <token goes here>
X-User-Id: <userID goes here>

{

	"microAppID":"<enter microAppID here>",
	 "optSearchFilters": [{
		"resourceID": "<enter microAppID here>",
		"fieldID":"<get fieldID>",
		"value":"<value of field>"
      }]

}

sort example

The data fetched from the Microapp can be sorted. The order and field parameters are used in the searchFilter to specify which Microapp sort field and if it is ascending or descending. The sort fields are configured in the Microapp Results Tab. Sort field 1 corresponds to the field value 1 and so on. Where order is either 1 = ascending or -1 = descending.

Example fetching microapp rows using Sort Field 1.

POST /api/microappdata
X-Auth-Token: <token goes here>
X-User-Id: <userID goes here>

{
	"microAppID": "<enter microAppID here>",
	"searchFilter": [
		{
			"resourceID": "<microapp ID goes here>",
			"order": 1,
			"field": "1",
			"skip": "5",
			"limit": 100
		}
	]
}

paging example

Pagination is achieved using the skip and limit parameters. The skip parameter specifies the number of results to skip at the beginning. The limit parameter specifies the maximum number of results to return.

Example fetching microapp rows using pagination.

POST /api/microappdata
X-Auth-Token: <token goes here>
X-User-Id: <userID goes here>

{
	"microAppID": "<enter microAppID here>",
	"searchFilter": [
		{
			"resourceID": "<microapp ID goes here>",
			"skip": "100",
			"limit": 100
		}
	],
	"buzzyFormat":true
}

The buzzyFormat parameter is used to output raw data instead of JSON. This is used only in exceptional situations and please contact your buzzy representative for more information.

finding embedded row data example

When have Sub-Tables (1:M) you have a parent -> child relationship. So each parent row (the embeddingRow) can have many children.

For example, you have a row for each Invoice and you need to search the Seb-table for the Invoice Lines.

Example fetching microapp rows using `embeddingRowID`. As part of the example, assume "sortVal2" has row data to do with "approved". So to show all the Invoice Lines for the specific Invoice that are approved, the query will look like:

POST /api/microappdata
X-Auth-Token: <token goes here>
X-User-Id: <userID goes here>

{
    "microAppID": "<enter microAppID here>",
    
    "optViewFilters": [
        {
            "sortVal2": true
        },
        {
            "embeddingRowID": "<enter parent row ID here>"
        }
    ]
}

using mongoDB query syntax example

Buzzy is based on Mongo DB and allows you to use MongDB's query syntax, allow for more complex queries. Each object in the optViewFilters array is AND'd. Note for OR you can include that in each object.

Example fetching microapp rows using a MongoDB like query where sortVal5 is between lowVal and highVal

POST /api/microappdata
X-Auth-Token: <token goes here>
X-User-Id: <userID goes here>

{
    "microAppID": "<enter microAppID here>",
    
    "optViewFilters": [
        {sortVal5: {$gte:lowVal}},
        {sortVal5: {$lte:highVal}}
    ]
     
}

geo/spatial query examples

Buzzy supports MongoDB's geospatial queries through the sortValGeometry field. This allows you to search for data based on geographic locations and boundaries.

Example 1: Searching within a radius

This example searches for data within a circular area around a specific point (Manly, NSW in this case):

POST /api/microappdata
X-Auth-Token: <token goes here>
X-User-Id: <userID goes here>

{
    "microAppID": "ddf31524a04a4c60f3635edd",
    "parentResourceID": "ddf31524a04a4c60f3635edd",
    "optViewFilters": [
        {
            "sortValGeometry": {
                "$geoWithin": {
                    "$centerSphere": [
                        [
                            151.285,
                            -33.797
                        ], // Approximate longitude and latitude for Manly, NSW
                        0.000156786503818 // Radius in radians; divide by Earth's radius in kilometers
                    ]
                }
            }
        }
    ]
}

Example 2: Searching within a polygon

This example searches for data within a polygon boundary (roughly the outline of Australia):

POST /api/microappdata
X-Auth-Token: <token goes here>
X-User-Id: <userID goes here>

{
    "microAppID": "ddf31524a04a4c60f3635edd",
    "parentResourceID": "ddf31524a04a4c60f3635edd",
    "optViewFilters": [
        {
            "sortValGeometry": {
                "$geoWithin": {
                    "$geometry": {
                        "type": "Polygon",
                        "coordinates": [
                            [
                                [
                                    113.338953078,
                                    -43.6345972634
                                ], // southwest corner
                                [
                                    153.569469029,
                                    -43.6345972634
                                ], // southeast corner
                                [
                                    153.569469029,
                                    -10.6681857235
                                ], // northeast corner
                                [
                                    113.338953078,
                                    -10.6681857235
                                ], // northwest corner
                                [
                                    113.338953078,
                                    -43.6345972634
                                ] // back to the southwest corner to close the polygon
                            ]
                        ]
                    }
                }
            }
        }
    ]
}

Example 3: Finding data within a map's bounding box

A common use case is to find data that matches the current bounding box of a map as a user pans around. This example shows how to query for data within the current map viewport:

POST /api/microappdata
X-Auth-Token: <token goes here>
X-User-Id: <userID goes here>

{
    "microAppID": "ddf31524a04a4c60f3635edd",
    "parentResourceID": "ddf31524a04a4c60f3635edd",
    "optViewFilters": [
        {
            "sortValGeometry": {
                "$geoWithin": {
                    "$geometry": {
                        "type": "Polygon",
                        "coordinates": [
                            [
                                [mapBounds.west, mapBounds.south], // southwest corner
                                [mapBounds.east, mapBounds.south], // southeast corner
                                [mapBounds.east, mapBounds.north], // northeast corner
                                [mapBounds.west, mapBounds.north], // northwest corner
                                [mapBounds.west, mapBounds.south]  // back to southwest to close the polygon
                            ]
                        ]
                    }
                }
            }
        }
    ]
}

For a complete implementation example of a map with location data, see the Event Locations Map example.


For more info on MongoDB queries see here and for some addtional Buzzy examples with custom code widgets, including geospatial queries, see here

You can also use these geo/spatial query parameters with the Node.js API Client and the React API in Code Widgets.

Last updated