Getting Data

Data from Salsa is retrieved via calls to a series of SJS scripts that return data in XML format. These calls are very similar to the identical calls in SalsaScript, and handle all permissioning.

getObject.sjs

getObject.sjs takes 2 parameters: object and key. Object is the name of the object, such as supporter. Key is the object key.

http://sample.nodeurl.tld/api/getObject.sjs?object=supporter&key=123

getObjects.sjs

The getObjects.sjs method is useful for returning many objects. It requires an object parameter. Other parameters are optional and limit the set of results to be returned. In its simplest form, getObjects.sjs will return an array all of the objects available.

condition is a single condition, such as First_Name=Chris. There is no limit to the number of conditions that may be specified.

orderBy is an array of fields to sort the results by.

limit is a maximum number of results to return.

include is an array of fields to return. By default, all are returned.

In this example, we will request supporter objects where the Email is chris@dia.org and the supporter was last modified after May 5th, 2008. The results will be ordered by the Last_Modified date.

http://sample.nodeurl.tld/api/getObjects.sjs?object=supporter&condition=Email=chris@dia.org&condition=Last_Modified>2008-05-05&limit=5&orderBy=Last_Modified

getCount.sjs

getCount.sjs takes parameters: object, condition, countColumn and returns a simple count of items from the database. This example returns a count of the number of supporters with the email address chris@dia.org and a Last_Modified after May 5th, 2009.

http://sample.nodeurl.tld/api/getCount.sjs?object=supporter&condition=Email=chris@dia.org&condition=Last_Modified>2008-05-05&countColumn=supporter_KEY

getCounts.sjs

getCounts.sjs takes parameters: object, groupBy, condition, countColumn, orderBy, limit

Counts by group, or subset, is also a frequently used query. This is analogous to a SQL query with a "count(*)", and one or many "group by" fields.

This example will return an array of dates and counts for the number of supporters added on each date.

http://sample.nodeurl.tld/api/getCounts.sjs?object=supporter&groupBy=Date_Created&countColumn=supporter_KEY

getReport.sjs

getReport.sjs takes a report_KEY and returns the result set of an existing salsa report.

http://sample.nodeurl.tld/api/getReport.sjs?report_KEY=123