curl
curl --request POST \
--url 'https://analytics.us.algolia.com/3/patterns/scalar?index=lorem' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"domain": "core",
"metrics": [
{
"domain": "core",
"kind": "searchesCount"
}
],
"filters": [
{
"domain": "lorem",
"kind": "country",
"operator": "=",
"parameter": {
"domain": "core",
"kind": "country"
}
}
],
"parameters": [
{
"domain": "lorem",
"kind": "indices",
"value": "lorem"
}
]
}
'// Initialize the client
var client = new AnalyticsClient(
new AnalyticsConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
);
// Call the API
var response = await client.QueryPatternsScalarAsync(
new ScalarPayload
{
Metrics = new List<FieldReference> { new FieldReference { Kind = "conversionRate" } },
Parameters = new List<ParameterDefinition>
{
new ParameterDefinition
{
Kind = "indices",
Value = new ParameterValue(new List<string> { "index" }),
},
},
},
"index"
);
// print the response
Console.WriteLine(response);// Initialize the client with your application region, eg. analytics.ALGOLIA_APPLICATION_REGION
client, err := analytics.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", analytics.US)
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.QueryPatternsScalar(client.NewApiQueryPatternsScalarRequest(
analytics.NewEmptyScalarPayload().SetMetrics(
[]analytics.FieldReference{*analytics.NewEmptyFieldReference().SetKind("conversionRate")}).SetParameters(
[]analytics.ParameterDefinition{
*analytics.NewEmptyParameterDefinition().SetKind("indices").SetValue(analytics.ArrayOfStringAsParameterValue(
[]string{"index"})),
}),
).WithIndex("index"))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)// Initialize the client
AnalyticsClient client = new AnalyticsClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");
// Call the API
Map response = client.queryPatternsScalar(
new ScalarPayload()
.setMetrics(Arrays.asList(new FieldReference().setKind("conversionRate")))
.setParameters(Arrays.asList(new ParameterDefinition().setKind("indices").setValue(ParameterValue.of(Arrays.asList("index"))))),
"index"
);
// print the response
System.out.println(response);// Initialize the client
// Replace 'us' with your Algolia Application Region
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initAnalytics({ region: 'us' });
// Call the API
const response = await client.queryPatternsScalar({
scalarPayload: { metrics: [{ kind: 'conversionRate' }], parameters: [{ kind: 'indices', value: ['index'] }] },
index: 'index',
});
// print the response
console.log(response);// Initialize the client
val client =
AnalyticsClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = "ALGOLIA_APPLICATION_REGION",
)
// Call the API
var response =
client.queryPatternsScalar(
scalarPayload =
ScalarPayload(
metrics = listOf(FieldReference(kind = "conversionRate")),
parameters =
listOf(
ParameterDefinition(kind = "indices", value = ParameterValue.of(listOf("index")))
),
),
index = "index",
)
// print the response
println(response)// Initialize the client
$client = AnalyticsClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');
// Call the API
$response = $client->queryPatternsScalar(
['metrics' => [
['kind' => 'conversionRate',
],
],
'parameters' => [
['kind' => 'indices',
'value' => [
'index',
],
],
],
],
'index',
);
// print the response
var_dump($response);# Initialize the client
# In an asynchronous context, you can use AnalyticsClient instead, which exposes the exact same methods.
client = AnalyticsClientSync(
"ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
)
# Call the API
response = client.query_patterns_scalar(
scalar_payload={
"metrics": [
{
"kind": "conversionRate",
},
],
"parameters": [
{
"kind": "indices",
"value": [
"index",
],
},
],
},
index="index",
)
# print the response
print(response)# Initialize the client
client = Algolia::AnalyticsClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
# Call the API
response = client.query_patterns_scalar(
Algolia::Analytics::ScalarPayload.new(
metrics: [Algolia::Analytics::FieldReference.new(kind: "conversionRate")],
parameters: [Algolia::Analytics::ParameterDefinition.new(kind: "indices", value: ["index"])]
),
"index"
)
# print the response
puts(response)// Initialize the client
val client = AnalyticsClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = Option("ALGOLIA_APPLICATION_REGION")
)
// Call the API
val response = Await.result(
client.queryPatternsScalar(
scalarPayload = ScalarPayload(
metrics = Seq(
FieldReference(
kind = "conversionRate"
)
),
parameters = Seq(
ParameterDefinition(
kind = "indices",
value = ParameterValue(Seq("index"))
)
)
),
index = Some("index")
),
Duration(100, "sec")
)
// print the response
println(response)// Initialize the client
let client = try AnalyticsClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)
// Call the API
let response = try await client.queryPatternsScalar(
scalarPayload: ScalarPayload(
metrics: [FieldReference(kind: "conversionRate")],
parameters: [ParameterDefinition(
kind: "indices",
value: ParameterValue.arrayOfString(["index"])
)]
),
index: "index"
)
// print the response
print(response){}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}Patterns
Query single-row aggregates
Aggregates the requested metrics over the whole period and returns a single object keyed by metric kind.
POST
/
3
/
patterns
/
scalar
curl
curl --request POST \
--url 'https://analytics.us.algolia.com/3/patterns/scalar?index=lorem' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"domain": "core",
"metrics": [
{
"domain": "core",
"kind": "searchesCount"
}
],
"filters": [
{
"domain": "lorem",
"kind": "country",
"operator": "=",
"parameter": {
"domain": "core",
"kind": "country"
}
}
],
"parameters": [
{
"domain": "lorem",
"kind": "indices",
"value": "lorem"
}
]
}
'// Initialize the client
var client = new AnalyticsClient(
new AnalyticsConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
);
// Call the API
var response = await client.QueryPatternsScalarAsync(
new ScalarPayload
{
Metrics = new List<FieldReference> { new FieldReference { Kind = "conversionRate" } },
Parameters = new List<ParameterDefinition>
{
new ParameterDefinition
{
Kind = "indices",
Value = new ParameterValue(new List<string> { "index" }),
},
},
},
"index"
);
// print the response
Console.WriteLine(response);// Initialize the client with your application region, eg. analytics.ALGOLIA_APPLICATION_REGION
client, err := analytics.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", analytics.US)
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.QueryPatternsScalar(client.NewApiQueryPatternsScalarRequest(
analytics.NewEmptyScalarPayload().SetMetrics(
[]analytics.FieldReference{*analytics.NewEmptyFieldReference().SetKind("conversionRate")}).SetParameters(
[]analytics.ParameterDefinition{
*analytics.NewEmptyParameterDefinition().SetKind("indices").SetValue(analytics.ArrayOfStringAsParameterValue(
[]string{"index"})),
}),
).WithIndex("index"))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)// Initialize the client
AnalyticsClient client = new AnalyticsClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");
// Call the API
Map response = client.queryPatternsScalar(
new ScalarPayload()
.setMetrics(Arrays.asList(new FieldReference().setKind("conversionRate")))
.setParameters(Arrays.asList(new ParameterDefinition().setKind("indices").setValue(ParameterValue.of(Arrays.asList("index"))))),
"index"
);
// print the response
System.out.println(response);// Initialize the client
// Replace 'us' with your Algolia Application Region
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initAnalytics({ region: 'us' });
// Call the API
const response = await client.queryPatternsScalar({
scalarPayload: { metrics: [{ kind: 'conversionRate' }], parameters: [{ kind: 'indices', value: ['index'] }] },
index: 'index',
});
// print the response
console.log(response);// Initialize the client
val client =
AnalyticsClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = "ALGOLIA_APPLICATION_REGION",
)
// Call the API
var response =
client.queryPatternsScalar(
scalarPayload =
ScalarPayload(
metrics = listOf(FieldReference(kind = "conversionRate")),
parameters =
listOf(
ParameterDefinition(kind = "indices", value = ParameterValue.of(listOf("index")))
),
),
index = "index",
)
// print the response
println(response)// Initialize the client
$client = AnalyticsClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');
// Call the API
$response = $client->queryPatternsScalar(
['metrics' => [
['kind' => 'conversionRate',
],
],
'parameters' => [
['kind' => 'indices',
'value' => [
'index',
],
],
],
],
'index',
);
// print the response
var_dump($response);# Initialize the client
# In an asynchronous context, you can use AnalyticsClient instead, which exposes the exact same methods.
client = AnalyticsClientSync(
"ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
)
# Call the API
response = client.query_patterns_scalar(
scalar_payload={
"metrics": [
{
"kind": "conversionRate",
},
],
"parameters": [
{
"kind": "indices",
"value": [
"index",
],
},
],
},
index="index",
)
# print the response
print(response)# Initialize the client
client = Algolia::AnalyticsClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
# Call the API
response = client.query_patterns_scalar(
Algolia::Analytics::ScalarPayload.new(
metrics: [Algolia::Analytics::FieldReference.new(kind: "conversionRate")],
parameters: [Algolia::Analytics::ParameterDefinition.new(kind: "indices", value: ["index"])]
),
"index"
)
# print the response
puts(response)// Initialize the client
val client = AnalyticsClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = Option("ALGOLIA_APPLICATION_REGION")
)
// Call the API
val response = Await.result(
client.queryPatternsScalar(
scalarPayload = ScalarPayload(
metrics = Seq(
FieldReference(
kind = "conversionRate"
)
),
parameters = Seq(
ParameterDefinition(
kind = "indices",
value = ParameterValue(Seq("index"))
)
)
),
index = Some("index")
),
Duration(100, "sec")
)
// print the response
println(response)// Initialize the client
let client = try AnalyticsClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)
// Call the API
let response = try await client.queryPatternsScalar(
scalarPayload: ScalarPayload(
metrics: [FieldReference(kind: "conversionRate")],
parameters: [ParameterDefinition(
kind: "indices",
value: ParameterValue.arrayOfString(["index"])
)]
),
index: "index"
)
// print the response
print(response){}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}This is a beta feature according to Algolia’s Terms of Service (“Beta Services”).
metrics and parameters are required; filters is optional. Discover valid field kinds per
domain with /3/patterns/fields.
Required ACL: analyticsAuthorizations
Query Parameters
Body
application/json
Response
OK
Object keyed by metric kind, each mapping to its aggregate value.
Last modified on September 9, 2026
Was this page helpful?