> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom request

> Perform a custom request.

Perform a request from the given parameters and send it through the requester,
making use of the underlying retry strategy.

## Examples

<CodeGroup>
  ```cs C# theme={"system"}
  EndpointResponse response =
    client.CustomRequest<EndpointResponse, EndpointRequest>(
      new EndpointRequest {
        // parameters
      },
      "/1/custom/endpoint",
      System.Net.Http.HttpMethod.Get,
      Algolia.Search.Models.Enums.CallType.Read
    );
  ```

  ```go Go theme={"system"}
  var result map[string]interface{}
  body := map[string]interface{}{"k1": "v1", "k2": 2}
  client.CustomRequest(&result, "POST", "/customPath", body, call.Write)
  ```

  ```java Java theme={"system"}
    client
        .getTransport()
        .executeRequestAsync(
            HttpMethod.POST,
            "/customEndpoint",
            CallType.WRITE,
            Map.of("k1", "v1", "k2", 2),
            EndpointResponse.class,
            null);
  ```

  ```js JavaScript theme={"system"}
    const response =
      client.customRequest <
      EndpointResponse >
      ({
        method: "GET",
        path: "/1/custom/endpoint",
      },
      {
        data: { k1: "v1", k2: 2 },
      });
  ```

  ```kotlin Kotlin theme={"system"}
    val response = client.customRequest<JsonElement>(
        method = HttpMethod.Post,
        callType = CallType.Write,
        path = "customEndpoint",
        body = buildJsonObject {
            put("k1", JsonPrimitive("v1"))
            put("k2", JsonPrimitive(2))
        }.toString()
    )
  ```

  ```php PHP theme={"system"}
  $res = $client->custom(
    'GET',
    api_path('/1/custom/endpoint')
  );
  ```

  ```python Python theme={"system"}
  from algoliasearch.helpers import endpoint
  from algoliasearch.http.hosts import CallType
  from algoliasearch.http.verb import Verb

  res = client.custom_request(
      {}, endpoint("/1/custom/endpoint/{}", "my_parameter"), Verb.GET, CallType.READ
  )
  ```

  ```ruby Ruby theme={"system"}
  res = client.custom_request({}, "/my/custom/endpoint", :GET, CallType::READ)
  ```

  ```scala Scala theme={"system"}
    custom request CustomRequest(
      verb = POST,
      path = Seq("my", "custom", "endpoint"),
      endpoint = RequestEndpoint.Search,
      body = Some("""{"k1": "v1", "k2": 2}""")
    )
  ```

  ```swift Swift theme={"system"}
  var request = URLRequest(url: URL(string: "/customEndpoint")!)
  request.httpMethod = "POST"
  request.httpBody = try! JSONEncoder().encode(["k1": "v1", "k2": 2] as JSON)
  client.customRequest(callType: .write, request: request, requestOptions: nil) { (result: Result<JSON, Swift.Error>) in
    print(result)
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="callType" type="enum<string>" required>
  Type of HTTP method to use. One of:

  * `read`: for `GET` requests
  * `write`: for `POST`, `PUT`, `DELETE` requests

  This determines the duration of timeouts.
</ParamField>

<ParamField body="method" type="enum<string>" required>
  HTTP method to send with the query. One of: `GET`, `POST`, `PUT`, `DELETE`.
</ParamField>

<ParamField body="path" type="string" required>
  The path of the API endpoint to call, as exposed in the [documentation](/doc/rest-api).
</ParamField>

<ParamField body="requestOptions" type="object">
  A mapping of request options to send along with the request.
</ParamField>
