Skip to main content
POST
/
1
/
compositions
/
{compositionID}
/
run
curl
curl --request POST \
  --url https://algolia_application_id.algolia.net/1/compositions/my_composition_object_id/run \
  --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 '
{
  "params": {
    "analytics": true,
    "analyticsTags": [],
    "aroundLatLng": "40.71,-74.01",
    "aroundLatLngViaIP": false,
    "aroundRadius": 1,
    "aroundPrecision": 10,
    "clickAnalytics": false,
    "enableABTest": true,
    "enablePersonalization": false,
    "enableReRanking": true,
    "enableRules": true,
    "facetFilters": [
      [
        "category:Book",
        "category:-Movie"
      ],
      "author:John Doe"
    ],
    "facets": [
      "category",
      "disjunctive(brand)",
      "price"
    ],
    "filters": "(category:Book OR category:Ebook) AND _tags:published",
    "getRankingInfo": false,
    "hitsPerPage": 20,
    "injectedItems": {
      "my-group-key": {
        "items": [
          {
            "objectID": "my-object-1",
            "metadata": {
              "my-field": "my-value"
            }
          },
          {
            "objectID": "my-object-2",
            "metadata": {
              "my-field": "my-value-2"
            }
          }
        ]
      },
      "my-other-group-key": {
        "items": [
          {
            "objectID": "my-other-object-1"
          },
          {
            "objectID": "my-other-object-2"
          }
        ]
      }
    },
    "insideBoundingBox": "lorem",
    "insidePolygon": [
      [
        47.3165,
        4.9665,
        47.3424,
        5.0201,
        47.32,
        4.9
      ],
      [
        40.9234,
        2.1185,
        38.643,
        1.9916,
        39.2587,
        2.0104
      ]
    ],
    "minimumAroundRadius": 1,
    "naturalLanguages": [],
    "numericFilters": [
      [
        "inStock = 1",
        "deliveryDate < 1441755506"
      ],
      "price < 1000"
    ],
    "optionalFilters": [
      "category:Book",
      "author:John Doe"
    ],
    "page": 0,
    "query": "",
    "queryLanguages": [
      "es"
    ],
    "relevancyStrictness": 90,
    "ruleContexts": [
      "mobile"
    ],
    "sortBy": "Price (asc)",
    "userToken": "test-user-123"
  },
  "feedsOrder": [
    "feed-1",
    "feed-3"
  ]
}
'
// Initialize the client
var client = new CompositionClient(
new CompositionConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
);

// Call the API
var response = await client.SearchAsync<Hit>(
"foo",
new RequestBody
{
Params = new Params { Query = "batman" },
FeedsOrder = new List<string> { "feed-movies", "feed-comics" },
}
);

// 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.search(
compositionID: "foo",
requestBody: RequestBody(
params: Params(
query: "batman",
),
feedsOrder: [
"feed-movies",
"feed-comics",
],
),
);

// 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.Search(client.NewApiSearchRequest(
"foo",
composition.NewEmptyRequestBody().SetParams(
composition.NewEmptyParams().SetQuery("batman")).SetFeedsOrder(
[]string{"feed-movies", "feed-comics"})))
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
SearchResponse response = client.search(
"foo",
new RequestBody().setParams(new Params().setQuery("batman")).setFeedsOrder(Arrays.asList("feed-movies", "feed-comics")),
Hit.class
);

// 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.search({
compositionID: 'foo',
requestBody: { params: { query: 'batman' }, feedsOrder: ['feed-movies', 'feed-comics'] },
});


// 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.search(
compositionID = "foo",
requestBody =
RequestBody(
params = Params(query = "batman"),
feedsOrder = listOf("feed-movies", "feed-comics"),
),
)


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

// Call the API
$response = $client->search(
'foo',
['params' => ['query' => 'batman',
],
'feedsOrder' => [
'feed-movies',

'feed-comics',
],
],
);


// 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.search(
composition_id="foo",
request_body={
"params": {
"query": "batman",
},
"feedsOrder": [
"feed-movies",
"feed-comics",
],
},
)


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

# Call the API
response = client.search(
"foo",
Algolia::Composition::RequestBody.new(
params: Algolia::Composition::Params.new(query: "batman"),
feeds_order: ["feed-movies", "feed-comics"]
)
)


# 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.search(
compositionID = "foo",
requestBody = RequestBody(
params = Some(
Params(
query = Some("batman")
)
),
feedsOrder = Some(Seq("feed-movies", "feed-comics"))
)
),
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: CompositionSearchResponse<CompositionHit> = try await client.search(
compositionID: "foo",
requestBody: RequestBody(
params: CompositionParams(query: "batman"),
feedsOrder: ["feed-movies", "feed-comics"]
)
)

// print the response
print(response)
{
  "results": [
    {
      "compositions": {},
      "_automaticInsights": true,
      "abTestID": 123,
      "abTestVariantID": 2,
      "appliedRules": [
        {}
      ],
      "aroundLatLng": "40.71,-74.01",
      "automaticRadius": "<string>",
      "exhaustive": {
        "facetsCount": true,
        "facetValues": true,
        "nbHits": true,
        "rulesMatch": true,
        "typo": true
      },
      "exhaustiveFacetsCount": true,
      "exhaustiveNbHits": true,
      "exhaustiveTypo": true,
      "facets": {
        "category": {
          "food": 1,
          "tech": 42
        }
      },
      "facets_stats": {},
      "index": "indexName",
      "indexUsed": "indexNameAlt",
      "message": "<string>",
      "nbSortedHits": 20,
      "parsedQuery": "george clo",
      "processingTimeMS": 20,
      "processingTimingsMS": {},
      "queryAfterRemoval": "<string>",
      "queryID": "a00dbc80a8d13c4565a442e7e2dca80a",
      "redirect": {
        "index": [
          {
            "data": {
              "ruleObjectID": "<string>"
            },
            "dest": "<string>",
            "reason": "<string>",
            "source": "<string>",
            "succeed": true
          }
        ]
      },
      "renderingContent": {
        "facetOrdering": {
          "facets": {
            "order": [
              "<string>"
            ]
          },
          "values": {}
        },
        "redirect": {
          "url": "<string>"
        },
        "widgets": {
          "banners": [
            {
              "image": {
                "title": "<string>",
                "urls": [
                  {
                    "url": "<string>"
                  }
                ]
              },
              "link": {
                "url": "<string>"
              }
            }
          ]
        }
      },
      "serverTimeMS": 20,
      "serverUsed": "c2-uk-3.algolia.net",
      "userData": {
        "settingID": "f2a7b51e3503acc6a39b3784ffb84300",
        "pluginVersion": "1.6.0"
      },
      "hits": [
        {
          "objectID": "test-record-123",
          "_distinctSeqID": 123,
          "_extra": {
            "_injectedItemKey": "<string>"
          },
          "_highlightResult": {},
          "_rankingInfo": {
            "firstMatchedWord": 1,
            "geoDistance": 1,
            "nbExactWords": 1,
            "nbTypos": 1,
            "userScore": 123,
            "composed": {
              "my-composition-to-sponsor-products": {
                "index": "products",
                "injectedItemKey": "sponsored-products"
              }
            },
            "filters": 1,
            "geoPrecision": 2,
            "matchedGeoLocation": {
              "distance": 123,
              "lat": 123,
              "lng": 123
            },
            "personalization": {
              "filtersScore": 123,
              "rankingScore": 123,
              "score": 123
            },
            "promoted": true,
            "promotedByReRanking": true,
            "proximityDistance": 1,
            "words": 2
          },
          "_snippetResult": {}
        }
      ],
      "hitsPerPage": 20,
      "nbHits": 20,
      "nbPages": 1,
      "page": 0,
      "params": "query=a&hitsPerPage=20",
      "query": "shoes",
      "feedID": "products-feed"
    }
  ],
  "compositions": {
    "run": [
      {
        "objectID": "comp1765458818347",
        "appliedRules": [
          {
            "objectID": "cr-1765458959657"
          }
        ]
      }
    ]
  }
}
{
"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"
}
Required ACL: search

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"

Body

application/json
feedsOrder
string[]

A list of Feed IDs that specifies the order in which to order the results in the response. The IDs should be a subset of those in the feeds object of the targeted multifeed Composition / Composition Rule, and only those specified will be processed.

The value overrides the value in the defined behavior, and when unspecified, the value defined in the behavior is used. When neither value is present, all feeds are processed.

Example:
["feed-1", "feed-3"]
params
Run composition parameters as object Ā· object

Response

OK

results
object[]
required

Search results.

compositions
object
Last modified on March 23, 2026