Stae JS SDK
An API client for municipal.systems.
Install
npm install stae --save
Basic Examples
// create a basic readable API client, authed as youconst api = // get a list of places availableconst results = await apiplace // getting 911 calls for San Franciscoconst results = await apiplacedataTypedatum // getting traffic jams for NYC, with filtering and orderingconst results = await apiplacedataTypedatum // getting a specific 911 call for San Franciscoconst call = await apiplacedataTypedatum // creating a 311 issue for a sourceconst writer = staeawait writersourcedatum
Analytics Examples
On an analytics endpoint, complex queries can be executed. This query gets the total count of calls, calls last week, and typical response time grouped by officer for Jersey City.
const total = alias: 'total' value: function: 'count' const weekly = alias: 'weekly' value: function: 'count' filters: data: receivedAt: $gte: function: 'last' arguments: 'P1W' const typicalResponse = alias: 'response' value: function: 'median' arguments: function: 'interval' arguments: field: 'data.receivedAt' field: 'data.arrivedAt' filters: data: receivedAt: $ne: null $lt: field: 'data.arrivedAt' arrivedAt: $ne: null const results = await apiplacedataType
API List
Place APIs
- place.find({ options })
- place.findById({ placeId })
Data Types
- place.dataType.find({ placeId, options })
- place.dataType.findById({ placeId, dataTypeId })
- place.dataType.values({ placeId, dataTypeId })
- place.dataType.fields({ placeId, dataTypeId })
- place.dataType.export({ placeId, dataTypeId })
- place.dataType.analytics({ placeId, dataTypeId, options })
- place.dataType.datum.find({ placeId, dataTypeId, options })
- place.dataType.datum.findById({ placeId, dataTypeId, datumId })
- place.dataType.insight.find({ placeId, dataTypeId, options })
- place.dataType.insight.findById({ placeId, dataTypeId, insightId })
Sources
- place.source.find({ placeId, options })
- place.source.findById({ placeId, sourceId })
- place.source.values({ placeId, sourceId })
- place.source.fields({ placeId, sourceId })
- place.source.export({ placeId, sourceId })
- place.source.analytics({ placeId, sourceId, options })
- place.source.datum.find({ placeId, sourceId, options })
- place.source.datum.findById({ placeId, sourceId, datumId })
Misc APIs
Boundaries
- boundary.find({ options })
- boundary.findById({ boundaryId })
Data Types
- dataType.find({ options })
- dataType.findById({ dataTypeId })
- dataType.insight.find({ dataTypeId, options })
- dataType.insight.findById({ dataTypeId, insightId })
Sources
- source.find({ options })
- source.findById({ sourceId })
- source.values({ sourceId })
- source.fields({ sourceId })
- source.export({ sourceId, options })
- source.analytics({ sourceId, options })
- source.datum.create({ sourceId, data })
- source.datum.find({ sourceId, options })
- source.datum.findById({ sourceId, datumId })