---
sidebar:
  label: roboto.http.roboto_client
  order: 9
title: roboto.http.roboto_client
---
## Module Contents

### ApiRelativePath

```python
roboto.http.roboto_client.ApiRelativePath
```

`from roboto.http.roboto_client import ApiRelativePath`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L29-L29)

Route of the Roboto API, relative to the endpoint: a string such as `"v1/datasets"`, or a sequence of segments.

`RobotoClient` joins a sequence with `/` without escaping its segments, and drops any leading `/`.

### DEFAULT_HTTP_TIMEOUT

```python
roboto.http.roboto_client.DEFAULT_HTTP_TIMEOUT = 30.0
```

`from roboto.http import DEFAULT_HTTP_TIMEOUT`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L35-L35)

Seconds a client from `RobotoClient.from_config` waits on each request by default.

This default applies when the config's `default_http_timeout` is `NotSet`.

### RobotoClient

```python
class roboto.http.roboto_client.RobotoClient(
    endpoint: str,
    auth_decorator: Optional[roboto.http.request.HttpRequestDecorator],
    http_client_kwargs: Optional[dict[str, Any]] = None,
)
```

`from roboto import RobotoClient`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L42-L480)

Client that sends requests to one Roboto API endpoint with one set of credentials.

SDK methods that take a `roboto_client` send their requests through it. You can also call any Roboto API route with its request methods. Each request:

- names the newest API version this SDK knows, and the organizations its `caller_org_id` and `owner_org_id` arguments give;
- is retried, up to 10 attempts in all, when it fails in a way [`is_expected_to_be_transient()`](/docs/reference/python-sdk/roboto/http/http_client#roboto.http.http_client.is_expected_to_be_transient) judges transient. The `options` in `http_client_kwargs` can change both.

**Parameters**

- **endpoint** (`str`): URL of the Roboto API to send requests to, such as `https://api.roboto.ai`.
- **auth_decorator** (`Optional[roboto.http.request.HttpRequestDecorator]`): Decorator that adds credentials to each request, such as a [`BearerTokenDecorator`](/docs/reference/python-sdk/roboto/http/request_decorators#roboto.http.request_decorators.BearerTokenDecorator). `None` sends requests without credentials.
- **http_client_kwargs** (`Optional[dict[str, Any]]`): Keyword arguments for the [`HttpClient`](/docs/reference/python-sdk/roboto/http/http_client#roboto.http.http_client.HttpClient) that sends the requests, such as `default_timeout` or `options`. `None` passes none, so requests wait indefinitely.

**Properties**

- **RobotoClient.endpoint** (`str`): URL of the Roboto API this client sends requests to, such as `https://api.roboto.ai`.
- **RobotoClient.frontend_endpoint** (`str`): URL of the Roboto web app for this client's endpoint, made by replacing each `api` in it with `app`.
- **RobotoClient.http_client** (`roboto.http.http_client.HttpClient`): HTTP client that sends this client's requests, with its credentials, retry options and default timeout.

#### RobotoClient.defaulted()

```python
@classmethod
def defaulted(client: Optional[RobotoClient] = None) -> RobotoClient
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L138-L147)

Return `client`, or the client `from_env` returns when it is `None`.

The SDK's own code uses it; to get the client configured from the environment, use `from_env` instead. When `client` is `None`, the failures of `from_env` also apply.

**Parameters**

- **client** (`Optional[RobotoClient]`): Client to return. `None` returns the client configured from the environment.

**Returns**

- `RobotoClient`

#### RobotoClient.delete()

```python
def delete(
    path: ApiRelativePath,
    caller_org_id: Optional[str] = None,
    data: Any = None,
    headers: Optional[dict[str, str]] = None,
    idempotent: bool = True,
    owner_org_id: Optional[str] = None,
    query: Optional[dict[str, Any]] = None,
    retry_wait_fn: Optional[roboto.http.retry.RetryWaitFn] = None,
    timeout: roboto.env.Timeout = NotSet,
) -> roboto.http.response.HttpResponse
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L178-L233)

Send a DELETE request to a Roboto API route and return Roboto's response.

**Parameters**

- **path** (`ApiRelativePath`): Route to send the request to, relative to the endpoint, such as `"v1/datasets"`.
- **caller_org_id** (`Optional[str]`): Organization to act in. Required when the caller belongs to more than one organization; otherwise the caller's only organization.
- **data** (`Any`): Request body. A pydantic model or a dictionary is sent as JSON; [`body`](/docs/reference/python-sdk/roboto/http/request#roboto.http.request.HttpRequest.body) says how each type is encoded. `None` sends no body.
- **headers** (`Optional[dict[str, str]]`): Further headers to send. One with the name of the API version or an organization header replaces the value the client would send.
- **idempotent** (`bool`): Whether sending the request more than once has the same effect as sending it once. Only an idempotent request is retried after a connection error, a timeout, or status 408, 500 or 504.
- **owner_org_id** (`Optional[str]`): Organization that owns the resource the request reads or changes. `None` leaves Roboto to use the organization the request acts in.
- **query** (`Optional[dict[str, Any]]`): Query parameters to add to the URL, encoded by `urllib.parse.urlencode`, so a list value is sent as its string form rather than as repeated parameters. `None` adds none.
- **retry_wait_fn** (`Optional[roboto.http.retry.RetryWaitFn]`): Function that returns how long to wait before the next attempt, in milliseconds, given the `tenacity.RetryCallState` of the request. `None` waits a random time of up to 1 second after the first attempt, doubling that limit after each attempt up to 30 seconds.
- **timeout** (`roboto.env.Timeout`): Seconds each attempt waits on the connection before it times out. `None` waits indefinitely, and `NotSet` uses the client's default.

**Raises**

- [`RobotoDomainException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoDomainException): Roboto responded with status 400, 401, 403, 404, 409 or 5xx, after any retries. The exception is the subclass for the status, such as `RobotoNotFoundException` for 404.
- [`HttpError`](/docs/reference/python-sdk/roboto/exceptions/http#roboto.exceptions.http.HttpError): Roboto responded with any other error status, such as 429, after any retries.
- `ConnectionRefusedError`: Nothing at the endpoint accepted the connection.
- `urllib.error.URLError`: The last attempt could not be sent for another reason, such as a host name that does not resolve.
- `TimeoutError`: Roboto sent no response within `timeout` on the last attempt.

**Returns**

- `roboto.http.response.HttpResponse`

#### RobotoClient.for_profile()

```python
@classmethod
def for_profile(profile: str) -> RobotoClient
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L67-L88)

Build a client from a profile in the Roboto config file.

An access token in `ROBOTO_API_KEY` or `ROBOTO_BEARER_TOKEN` takes precedence over the profile, as [`from_env()`](/docs/reference/python-sdk/roboto/config#roboto.config.RobotoConfig.from_env) describes. Each call builds a new client.

**Parameters**

- **profile** (`str`): Name of the config file profile to read.

**Raises**

- `FileNotFoundError`: No access token is set and the config file does not exist.
- `OSError`: The config file exists but cannot be read.
- `ValueError`: The config file is not a JSON object, holds no valid profile, or has no profile by this name.
- [`RobotoDeprecatedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoDeprecatedException): The access token begins with `robo_pat`, a format Roboto retired in March 2024.

**Returns**

- `RobotoClient`

**Usage**

```python
from roboto.domain.datasets import Dataset
roboto_client = RobotoClient.for_profile("prod")
dataset = Dataset.from_id("ds_12345", roboto_client=roboto_client)
```

#### RobotoClient.from_config()

```python
@classmethod
def from_config(config: roboto.config.RobotoConfig) -> RobotoClient
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L91-L110)

Build a client that sends requests to the config's endpoint with its access token.

Each request waits up to the config's `default_http_timeout`: `None` waits indefinitely, and `NotSet` waits 30 seconds (`DEFAULT_HTTP_TIMEOUT`).

**Parameters**

- **config** (`roboto.config.RobotoConfig`): Endpoint, access token and default timeout to use.

**Raises**

- [`RobotoDeprecatedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoDeprecatedException): The config's access token begins with `robo_pat`, a format Roboto retired in March 2024.

**Returns**

- `RobotoClient`

#### RobotoClient.from_env()

```python
@classmethod
def from_env() -> RobotoClient
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L113-L135)

Return the client configured from the environment, building it on the first call.

The first call builds the client from [`from_env()`](/docs/reference/python-sdk/roboto/config#roboto.config.RobotoConfig.from_env), and every later call in the process returns that same client, so changes to the environment or config file after the first call do not apply to it.

**Raises**

- `FileNotFoundError`: On the first call, no access token is set and the config file does not exist.
- `OSError`: On the first call, the config file exists but cannot be read.
- `ValueError`: On the first call, the config file is not a JSON object, holds no valid profile, or has no profile by the chosen name.
- [`RobotoDeprecatedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoDeprecatedException): On the first call, the access token begins with `robo_pat`, a format Roboto retired in March 2024.

**Returns**

- `RobotoClient`

#### RobotoClient.get()

```python
def get(
    path: ApiRelativePath,
    caller_org_id: Optional[str] = None,
    headers: Optional[dict[str, str]] = None,
    idempotent: bool = True,
    owner_org_id: Optional[str] = None,
    query: Optional[dict[str, Any]] = None,
    retry_wait_fn: Optional[roboto.http.retry.RetryWaitFn] = None,
    timeout: roboto.env.Timeout = NotSet,
) -> roboto.http.response.HttpResponse
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L235-L291)

Send a GET request to a Roboto API route and return Roboto's response.

**Parameters**

- **path** (`ApiRelativePath`): Route to send the request to, relative to the endpoint, such as `"v1/datasets"`.
- **caller_org_id** (`Optional[str]`): Organization to act in. Required when the caller belongs to more than one organization; otherwise the caller's only organization.
- **headers** (`Optional[dict[str, str]]`): Further headers to send. One with the name of the API version or an organization header replaces the value the client would send.
- **idempotent** (`bool`): Whether sending the request more than once has the same effect as sending it once. Only an idempotent request is retried after a connection error, a timeout, or status 408, 500 or 504.
- **owner_org_id** (`Optional[str]`): Organization that owns the resource the request reads or changes. `None` leaves Roboto to use the organization the request acts in.
- **query** (`Optional[dict[str, Any]]`): Query parameters to add to the URL, encoded by `urllib.parse.urlencode`, so a list value is sent as its string form rather than as repeated parameters. `None` adds none.
- **retry_wait_fn** (`Optional[roboto.http.retry.RetryWaitFn]`): Function that returns how long to wait before the next attempt, in milliseconds, given the `tenacity.RetryCallState` of the request. `None` waits a random time of up to 1 second after the first attempt, doubling that limit after each attempt up to 30 seconds.
- **timeout** (`roboto.env.Timeout`): Seconds each attempt waits on the connection before it times out. `None` waits indefinitely, and `NotSet` uses the client's default.

**Raises**

- [`RobotoDomainException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoDomainException): Roboto responded with status 400, 401, 403, 404, 409 or 5xx, after any retries. The exception is the subclass for the status, such as `RobotoNotFoundException` for 404.
- [`HttpError`](/docs/reference/python-sdk/roboto/exceptions/http#roboto.exceptions.http.HttpError): Roboto responded with any other error status, such as 429, after any retries.
- `ConnectionRefusedError`: Nothing at the endpoint accepted the connection.
- `urllib.error.URLError`: The last attempt could not be sent for another reason, such as a host name that does not resolve.
- `TimeoutError`: Roboto sent no response within `timeout` on the last attempt.

**Returns**

- `roboto.http.response.HttpResponse`

**Usage**

```python
from roboto.domain.datasets import DatasetRecord
roboto_client = RobotoClient.from_env()
record = roboto_client.get(["v1", "datasets", "ds_12345"]).to_record(DatasetRecord)
```

#### RobotoClient.patch()

```python
def patch(
    path: ApiRelativePath,
    caller_org_id: Optional[str] = None,
    data: Any = None,
    headers: Optional[dict[str, str]] = None,
    idempotent: bool = True,
    owner_org_id: Optional[str] = None,
    query: Optional[dict[str, Any]] = None,
    retry_wait_fn: Optional[roboto.http.retry.RetryWaitFn] = None,
    timeout: roboto.env.Timeout = NotSet,
) -> roboto.http.response.HttpResponse
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L293-L348)

Send a PATCH request to a Roboto API route and return Roboto's response.

**Parameters**

- **path** (`ApiRelativePath`): Route to send the request to, relative to the endpoint, such as `"v1/datasets"`.
- **caller_org_id** (`Optional[str]`): Organization to act in. Required when the caller belongs to more than one organization; otherwise the caller's only organization.
- **data** (`Any`): Request body. A pydantic model or a dictionary is sent as JSON; [`body`](/docs/reference/python-sdk/roboto/http/request#roboto.http.request.HttpRequest.body) says how each type is encoded. `None` sends no body.
- **headers** (`Optional[dict[str, str]]`): Further headers to send. One with the name of the API version or an organization header replaces the value the client would send.
- **idempotent** (`bool`): Whether sending the request more than once has the same effect as sending it once. Only an idempotent request is retried after a connection error, a timeout, or status 408, 500 or 504.
- **owner_org_id** (`Optional[str]`): Organization that owns the resource the request reads or changes. `None` leaves Roboto to use the organization the request acts in.
- **query** (`Optional[dict[str, Any]]`): Query parameters to add to the URL, encoded by `urllib.parse.urlencode`, so a list value is sent as its string form rather than as repeated parameters. `None` adds none.
- **retry_wait_fn** (`Optional[roboto.http.retry.RetryWaitFn]`): Function that returns how long to wait before the next attempt, in milliseconds, given the `tenacity.RetryCallState` of the request. `None` waits a random time of up to 1 second after the first attempt, doubling that limit after each attempt up to 30 seconds.
- **timeout** (`roboto.env.Timeout`): Seconds each attempt waits on the connection before it times out. `None` waits indefinitely, and `NotSet` uses the client's default.

**Raises**

- [`RobotoDomainException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoDomainException): Roboto responded with status 400, 401, 403, 404, 409 or 5xx, after any retries. The exception is the subclass for the status, such as `RobotoNotFoundException` for 404.
- [`HttpError`](/docs/reference/python-sdk/roboto/exceptions/http#roboto.exceptions.http.HttpError): Roboto responded with any other error status, such as 429, after any retries.
- `ConnectionRefusedError`: Nothing at the endpoint accepted the connection.
- `urllib.error.URLError`: The last attempt could not be sent for another reason, such as a host name that does not resolve.
- `TimeoutError`: Roboto sent no response within `timeout` on the last attempt.

**Returns**

- `roboto.http.response.HttpResponse`

#### RobotoClient.post()

```python
def post(
    path: ApiRelativePath,
    caller_org_id: Optional[str] = None,
    data: Any = None,
    headers: Optional[dict[str, str]] = None,
    idempotent: bool = True,
    owner_org_id: Optional[str] = None,
    query: Optional[dict[str, Any]] = None,
    retry_wait_fn: Optional[roboto.http.retry.RetryWaitFn] = None,
    timeout: roboto.env.Timeout = NotSet,
) -> roboto.http.response.HttpResponse
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L350-L406)

Send a POST request to a Roboto API route and return Roboto's response.

**Parameters**

- **path** (`ApiRelativePath`): Route to send the request to, relative to the endpoint, such as `"v1/datasets"`.
- **caller_org_id** (`Optional[str]`): Organization to act in. Required when the caller belongs to more than one organization; otherwise the caller's only organization.
- **data** (`Any`): Request body. A pydantic model or a dictionary is sent as JSON; [`body`](/docs/reference/python-sdk/roboto/http/request#roboto.http.request.HttpRequest.body) says how each type is encoded. `None` sends no body.
- **headers** (`Optional[dict[str, str]]`): Further headers to send. One with the name of the API version or an organization header replaces the value the client would send.
- **idempotent** (`bool`): Whether sending the request more than once has the same effect as sending it once. Only an idempotent request is retried after a connection error, a timeout, or status 408, 500 or 504. Defaults to `True`; pass `False` for a request that must not take effect twice.
- **owner_org_id** (`Optional[str]`): Organization that owns the resource the request reads or changes. `None` leaves Roboto to use the organization the request acts in.
- **query** (`Optional[dict[str, Any]]`): Query parameters to add to the URL, encoded by `urllib.parse.urlencode`, so a list value is sent as its string form rather than as repeated parameters. `None` adds none.
- **retry_wait_fn** (`Optional[roboto.http.retry.RetryWaitFn]`): Function that returns how long to wait before the next attempt, in milliseconds, given the `tenacity.RetryCallState` of the request. `None` waits a random time of up to 1 second after the first attempt, doubling that limit after each attempt up to 30 seconds.
- **timeout** (`roboto.env.Timeout`): Seconds each attempt waits on the connection before it times out. `None` waits indefinitely, and `NotSet` uses the client's default.

**Raises**

- [`RobotoDomainException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoDomainException): Roboto responded with status 400, 401, 403, 404, 409 or 5xx, after any retries. The exception is the subclass for the status, such as `RobotoNotFoundException` for 404.
- [`HttpError`](/docs/reference/python-sdk/roboto/exceptions/http#roboto.exceptions.http.HttpError): Roboto responded with any other error status, such as 429, after any retries.
- `ConnectionRefusedError`: Nothing at the endpoint accepted the connection.
- `urllib.error.URLError`: The last attempt could not be sent for another reason, such as a host name that does not resolve.
- `TimeoutError`: Roboto sent no response within `timeout` on the last attempt.

**Returns**

- `roboto.http.response.HttpResponse`

#### RobotoClient.put()

```python
def put(
    path: ApiRelativePath,
    caller_org_id: Optional[str] = None,
    data: Any = None,
    headers: Optional[dict[str, str]] = None,
    idempotent: bool = True,
    owner_org_id: Optional[str] = None,
    query: Optional[dict[str, Any]] = None,
    retry_wait_fn: Optional[roboto.http.retry.RetryWaitFn] = None,
    timeout: roboto.env.Timeout = NotSet,
) -> roboto.http.response.HttpResponse
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L408-L463)

Send a PUT request to a Roboto API route and return Roboto's response.

**Parameters**

- **path** (`ApiRelativePath`): Route to send the request to, relative to the endpoint, such as `"v1/datasets"`.
- **caller_org_id** (`Optional[str]`): Organization to act in. Required when the caller belongs to more than one organization; otherwise the caller's only organization.
- **data** (`Any`): Request body. A pydantic model or a dictionary is sent as JSON; [`body`](/docs/reference/python-sdk/roboto/http/request#roboto.http.request.HttpRequest.body) says how each type is encoded. `None` sends no body.
- **headers** (`Optional[dict[str, str]]`): Further headers to send. One with the name of the API version or an organization header replaces the value the client would send.
- **idempotent** (`bool`): Whether sending the request more than once has the same effect as sending it once. Only an idempotent request is retried after a connection error, a timeout, or status 408, 500 or 504.
- **owner_org_id** (`Optional[str]`): Organization that owns the resource the request reads or changes. `None` leaves Roboto to use the organization the request acts in.
- **query** (`Optional[dict[str, Any]]`): Query parameters to add to the URL, encoded by `urllib.parse.urlencode`, so a list value is sent as its string form rather than as repeated parameters. `None` adds none.
- **retry_wait_fn** (`Optional[roboto.http.retry.RetryWaitFn]`): Function that returns how long to wait before the next attempt, in milliseconds, given the `tenacity.RetryCallState` of the request. `None` waits a random time of up to 1 second after the first attempt, doubling that limit after each attempt up to 30 seconds.
- **timeout** (`roboto.env.Timeout`): Seconds each attempt waits on the connection before it times out. `None` waits indefinitely, and `NotSet` uses the client's default.

**Raises**

- [`RobotoDomainException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoDomainException): Roboto responded with status 400, 401, 403, 404, 409 or 5xx, after any retries. The exception is the subclass for the status, such as `RobotoNotFoundException` for 404.
- [`HttpError`](/docs/reference/python-sdk/roboto/exceptions/http#roboto.exceptions.http.HttpError): Roboto responded with any other error status, such as 429, after any retries.
- `ConnectionRefusedError`: Nothing at the endpoint accepted the connection.
- `urllib.error.URLError`: The last attempt could not be sent for another reason, such as a host name that does not resolve.
- `TimeoutError`: Roboto sent no response within `timeout` on the last attempt.

**Returns**

- `roboto.http.response.HttpResponse`

### logger

```python
roboto.http.roboto_client.logger
```

`from roboto.http.roboto_client import logger`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/roboto_client.py#L27-L27)
