Skip to main content
GET
/
1
/
compositions
/
{compositionID}
/
rules
/
{objectID}
curl
curl --request GET \
  --url https://algolia_application_id.algolia.net/1/compositions/my_composition_object_id/rules/lorem \
  --header 'accept: application/json' \
  --header 'x-algolia-api-key: ALGOLIA_API_KEY' \
  --header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID'
// Initialize the client
var client = new CompositionClient(
new CompositionConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
);

// Call the API
var response = await client.GetRuleAsync("foo", "123");

// print the response
Console.WriteLine(response);
// Initialize the client
final client = CompositionClient(
appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');

// Call the API
final response = await client.getRule(
compositionID: "foo",
objectID: "123",
);

// print the response
print(response);
// Initialize the client
client, err := composition.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}

// Call the API
response, err := client.GetRule(client.NewApiGetRuleRequest(
"foo", "123"))
if err != nil {
// handle the eventual error
panic(err)
}


// print the response
print(response)
// Initialize the client
CompositionClient client = new CompositionClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");

// Call the API
CompositionRule response = client.getRule("foo", "123");

// print the response
System.out.println(response);
// Initialize the client
const client = compositionClient('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');

// Call the API
const response = await client.getRule({ compositionID: 'foo', objectID: '123' });


// print the response
console.log(response);
// Initialize the client
val client = CompositionClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")

// Call the API
var response = client.getRule(compositionID = "foo", objectID = "123")


// print the response
println(response)
// Initialize the client
$client = CompositionClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');

// Call the API
$response = $client->getRule(
'foo',
'123',
);


// print the response
var_dump($response);
# Initialize the client
# In an asynchronous context, you can use CompositionClient instead, which exposes the exact same methods.
client = CompositionClientSync("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")

# Call the API
response = client.get_rule(
composition_id="foo",
object_id="123",
)


# print the response
print(response)
# Initialize the client
client = Algolia::CompositionClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")

# Call the API
response = client.get_rule("foo", "123")


# print the response
puts(response)
// Initialize the client
val client = CompositionClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")

// Call the API
val response = Await.result(
client.getRule(
compositionID = "foo",
objectID = "123"
),
Duration(100, "sec")
)

// print the response
println(response)
// Initialize the client
let client = try CompositionClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY")

// Call the API
let response = try await client.getRule(compositionID: "foo", objectID: "123")

// print the response
print(response)
{
  "consequence": {
    "behavior": {
      "injection": {
        "main": {
          "source": {
            "search": {
              "index": "Products",
              "params": {
                "advancedSyntax": false,
                "advancedSyntaxFeatures": [
                  "exactPhrase",
                  "excludeWords"
                ],
                "allowTyposOnNumericTokens": true,
                "alternativesAsExact": [
                  "ignorePlurals",
                  "singleWordSynonym"
                ],
                "attributeCriteriaComputedByMinProximity": false,
                "attributesToHighlight": [
                  "author",
                  "title",
                  "conten",
                  "content"
                ],
                "attributesToRetrieve": [
                  "author",
                  "title",
                  "content"
                ],
                "attributesToSnippet": [
                  "content:80",
                  "description"
                ],
                "clickAnalytics": false,
                "disableExactOnAttributes": [
                  "description"
                ],
                "disableTypoToleranceOnAttributes": [
                  "sku"
                ],
                "distinct": 1,
                "enableABTest": true,
                "enablePersonalization": false,
                "enableReRanking": true,
                "enableRules": true,
                "exactOnSingleWordQuery": "attribute",
                "facetFilters": [
                  [
                    "category:Book",
                    "category:-Movie"
                  ],
                  "author:John Doe"
                ],
                "filters": "(category:Book OR category:Ebook) AND _tags:published",
                "getRankingInfo": false,
                "highlightPostTag": "</em>",
                "highlightPreTag": "<em>",
                "ignorePlurals": [
                  "ca",
                  "es"
                ],
                "minProximity": 1,
                "minWordSizefor1Typo": 4,
                "minWordSizefor2Typos": 8,
                "naturalLanguages": [],
                "numericFilters": [
                  [
                    "inStock = 1",
                    "deliveryDate < 1441755506"
                  ],
                  "price < 1000"
                ],
                "optionalFilters": [
                  "category:Book",
                  "author:John Doe"
                ],
                "optionalWords": "<string>",
                "percentileComputation": true,
                "personalizationImpact": 100,
                "queryLanguages": [
                  "es"
                ],
                "queryType": "prefixLast",
                "removeStopWords": [
                  "ca",
                  "es"
                ],
                "removeWordsIfNoResults": "firstWords",
                "replaceSynonymsInHighlight": false,
                "responseFields": [
                  "*"
                ],
                "restrictHighlightAndSnippetArrays": false,
                "restrictSearchableAttributes": [
                  "title",
                  "author"
                ],
                "ruleContexts": [
                  "mobile"
                ],
                "snippetEllipsisText": "…",
                "synonyms": true,
                "typoTolerance": true,
                "facetingAfterDistinct": false,
                "facets": [
                  "category",
                  "disjunctive(brand)",
                  "price"
                ],
                "hitsPerPage": 20,
                "maxValuesPerFacet": 100,
                "renderingContent": {
                  "facetOrdering": {
                    "facets": {
                      "order": [
                        "<string>"
                      ]
                    },
                    "values": {}
                  },
                  "redirect": {
                    "url": "<string>"
                  },
                  "widgets": {
                    "banners": [
                      {
                        "image": {
                          "title": "<string>",
                          "urls": [
                            {
                              "url": "<string>"
                            }
                          ]
                        },
                        "link": {
                          "url": "<string>"
                        }
                      }
                    ]
                  }
                },
                "sortFacetValuesBy": "count",
                "sumOrFiltersScores": false
              }
            }
          }
        },
        "deduplication": {
          "positioning": "highest"
        },
        "injectedItems": [
          {
            "key": "<string>",
            "length": 25,
            "position": 49,
            "source": {
              "search": {
                "index": "Products",
                "params": {
                  "advancedSyntax": false,
                  "advancedSyntaxFeatures": [
                    "exactPhrase",
                    "excludeWords"
                  ],
                  "allowTyposOnNumericTokens": true,
                  "alternativesAsExact": [
                    "ignorePlurals",
                    "singleWordSynonym"
                  ],
                  "attributeCriteriaComputedByMinProximity": false,
                  "attributesToHighlight": [
                    "author",
                    "title",
                    "conten",
                    "content"
                  ],
                  "attributesToRetrieve": [
                    "author",
                    "title",
                    "content"
                  ],
                  "attributesToSnippet": [
                    "content:80",
                    "description"
                  ],
                  "clickAnalytics": false,
                  "disableExactOnAttributes": [
                    "description"
                  ],
                  "disableTypoToleranceOnAttributes": [
                    "sku"
                  ],
                  "distinct": 1,
                  "enableABTest": true,
                  "enablePersonalization": false,
                  "enableReRanking": true,
                  "enableRules": true,
                  "exactOnSingleWordQuery": "attribute",
                  "facetFilters": [
                    [
                      "category:Book",
                      "category:-Movie"
                    ],
                    "author:John Doe"
                  ],
                  "filters": "(category:Book OR category:Ebook) AND _tags:published",
                  "getRankingInfo": false,
                  "highlightPostTag": "</em>",
                  "highlightPreTag": "<em>",
                  "ignorePlurals": [
                    "ca",
                    "es"
                  ],
                  "minProximity": 1,
                  "minWordSizefor1Typo": 4,
                  "minWordSizefor2Typos": 8,
                  "naturalLanguages": [],
                  "numericFilters": [
                    [
                      "inStock = 1",
                      "deliveryDate < 1441755506"
                    ],
                    "price < 1000"
                  ],
                  "optionalFilters": [
                    "category:Book",
                    "author:John Doe"
                  ],
                  "optionalWords": "<string>",
                  "percentileComputation": true,
                  "personalizationImpact": 100,
                  "queryLanguages": [
                    "es"
                  ],
                  "queryType": "prefixLast",
                  "removeStopWords": [
                    "ca",
                    "es"
                  ],
                  "removeWordsIfNoResults": "firstWords",
                  "replaceSynonymsInHighlight": false,
                  "responseFields": [
                    "*"
                  ],
                  "restrictHighlightAndSnippetArrays": false,
                  "restrictSearchableAttributes": [
                    "title",
                    "author"
                  ],
                  "ruleContexts": [
                    "mobile"
                  ],
                  "snippetEllipsisText": "…",
                  "synonyms": true,
                  "typoTolerance": true
                }
              }
            },
            "metadata": {
              "hits": {
                "addItemKey": true,
                "extra": {}
              }
            }
          }
        ]
      }
    }
  },
  "objectID": "my_composition_rule_object_id",
  "conditions": [
    {
      "context": "mobile",
      "filters": "genre:comedy",
      "pattern": "{facet:genre}",
      "sortBy": "price-low-to-high"
    }
  ],
  "description": "Display a promotional banner",
  "enabled": true,
  "tags": [
    "conditional"
  ],
  "validity": [
    {
      "from": 123,
      "until": 123
    }
  ]
}
{
"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"
}
To find the object ID of a rule, use the search operation. Required ACL: editSettings, settings

Authorizations

x-algolia-application-id
string
header
required

Your Algolia application ID.

x-algolia-api-key
string
header
required

Your Algolia API key with the necessary permissions to make the request. Permissions are controlled through access control lists (ACL) and access restrictions. The required ACL to make a request is listed in each endpoint's reference.

Path Parameters

compositionID
string
required

Unique Composition ObjectID. Composition unique identifier.

Example:

"my_composition_object_id"

objectID
string
required

Unique identifier of a rule object.

Response

OK

consequence
compositionRuleConsequence Ā· object
required

Effect of the rule.

objectID
string
required

Composition rule unique identifier.

Example:

"my_composition_rule_object_id"

conditions
object[]

Conditions that trigger a composition rule.

Maximum array length: 25
description
string

Description of the rule's purpose to help you distinguish between different rules.

Example:

"Display a promotional banner"

enabled
boolean
default:true

Whether the rule is active.

tags
string[]

A list of tags.

Example:
["conditional"]
validity
object[]

Time periods when the rule is active.

Last modified on March 23, 2026