Child pages
  • Create Query components

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


While you can invoke the Query API from your client side and pass it all the required parameters to execute your query, you will most of the time need to reuse this same logic across clients or event across server-side components. Since Apstrata always has modularity and reusability in mind, it allows you to encapsulate your query logic into components, called "Saved Queries" using the SaveQuery API
Back to the map       Next station: Geospatial queries

Example 1: load my saved game


Localtab Group
Code Block
curl "
titleApstrata script
Code Block
// We retrieve the value of the docKey parameter expected by the saved query, from the request
var docKey = request.parameters["docKey"];
var params = {
	"apsdb.queryName": "topScores" // we pass the name of the saved query

return apsdb.callApi("Query", params, null);		
Code Block
try {
	String authKey = "O763A7F690"; // Replace with your Application key
    String baseURL = "";
    // Sign your call with a signature based on your application key and secret  to authenticate against Apstrata
    // Simple signature is used in this example
    String secret = "S4A0120A6E64952FE75285BD0XD243S2"; // Replace with your application secret
    Connection ownerConnection = new OwnerConnection(baseUrl, authKey, secret);
    Client client = new Client(baseURL, authKey, ownerConnection);
    Client.AuthMode mode = Client.AuthMode.SIMPLE;
    // Prepare the parameters to send to the SaveDocument API                                 
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();               
    parameters.add(new BasicNameValuePair("apsdb.queryName","topScores"));
	// Invoke the API using the Client instance and signature mode 
	// note that since we're not passing files, we send "null" in place of the "files" parameter
	response = client.callAPIJson(Query, parameters, null, mode);
} catch (Exception e) {
	response = "Error: " + e.getMessage();

Dig deeper

Related tutorials

Navigation Map