GitHub

SlackWebApiService

API reference for SlackWebApiService.

The minimal Web API client, with the bot token.

  • call posts form parameters to {base_url}/{method}. A string goes as it is, any other value as JSON, and None is left out. It succeeds with the answer once Slack says ok.
  • An ok: false answer fails with the reason for Slack's error code, which becomes the reason's detail. ratelimited and an HTTP 429 give RateLimited with the Retry-After wait.
  • A write never repeats once the request left: a transport failure, a server error or an unreadable answer is uncertain. A read retries retry failures unless retry=False, waiting out a 429's Retry-After unless it passes max_retry_after: then the call fails at once with RateLimited.
  • The error's op is the method name.

Functions

__init__

__init__(http, bot_token, base_url, max_retry_after=None) -> None
ParameterTypeDescription
httpHttpClientService[HttpClientError, Never]
bot_tokenRedacted[str]
base_urlstr
max_retry_afterDuration | None = None
def __init__(
    self,
    http: HttpClientService[HttpClientError, Never],
    bot_token: Redacted[str],
    base_url: str,
    max_retry_after: Duration | None = None,
) -> None:
    self._http = http
    self._bot_token = bot_token
    self._base_url = base_url
    self._max_retry_after = max_retry_after

call

call(method, body, *, write=False, retry=True) -> Effect[Json, ChatError]

Calls a Web API method with body as form fields and succeeds with Slack's answer when it is ok. write marks a call that may land without an answer, so a failure is uncertain rather than retried; retry retries a safe failure, as retry_safe does.

ParameterTypeDescription
methodstr
bodyMapping[str, object]
writebool = False
retrybool = True

Returns Effect[Json, ChatError]

def call(
    self, method: str, body: Mapping[str, object], *, write: bool = False, retry: bool = True
) -> Effect[Json, ChatError]:
    """Calls a Web API method with ``body`` as form fields and succeeds
    with Slack's answer when it is ``ok``. ``write`` marks a call that may
    land without an answer, so a failure is ``uncertain`` rather than
    retried; ``retry`` retries a safe failure, as ``retry_safe`` does."""
    once = self._once(method, body, write)
    return retry_safe(once, max_retry_after=self._max_retry_after) if retry else once