slack_throttle v0.1.0 SlackThrottle.API

This library provides wrapper functions for the Slack Web API and automatically throttles all requests to it according to API rate limits.

Usage

Look up the API method you want to use in the Slack documentation. Function names are method names with dots replaced by underscores:

# method: channels.info
iex> SlackThrottle.API.channels_info("some token", %{channel: "C123456"})
%{"ok" => true, "channel" => %{"id" => "C123456", ...}}

If you don’t care about the response, e.g. when broadcasting a message, use :cast as the third argument:

# method: chat.postMessage
iex> SlackThrottle.API.chat_postMessage("some token", params, :cast)
:ok

Broadcasts are executed asynchronously and return :ok immediately.

Rate Limits

The Slack Web API is subject to rate limiting. Requests are only allowed at a rate of one per second on a per-access-token basis.

To comply with these restrictions, the library queues all function calls (grouped by access token) and executes them at the given rate. These queues are priority queues: Regular blocking function calls have higher priority than asynchronous broadcasts (the :cast ones).

Configuration

The API throttle rate :api_throttle can be configured as well as the timeout for blocking function calls :enqueue_sync_timeout:

config :slack_throttle,
  api_throttle: 1000, # in milliseconds
  enqueue_sync_timeout: 20000 # in milliseconds

Summary

Functions

Functions

api_test(params \\ %{})
api_test(%{optional(atom) => any}) :: %{optional(binary) => any}

api.test

auth_revoke(token, params \\ %{}, type \\ :call)
auth_revoke(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

auth.revoke

auth_test(token, params \\ %{}, type \\ :call)
auth_test(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

auth.test

bots_info(token, params \\ %{}, type \\ :call)
bots_info(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

bots.info

channels_archive(token, params \\ %{}, type \\ :call)
channels_archive(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.archive

channels_close(token, params \\ %{}, type \\ :call)
channels_close(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.close

channels_create(token, params \\ %{}, type \\ :call)
channels_create(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.create

channels_createChild(token, params \\ %{}, type \\ :call)
channels_createChild(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.createChild

channels_history(token, params \\ %{}, type \\ :call)
channels_history(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.history

channels_info(token, params \\ %{}, type \\ :call)
channels_info(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.info

channels_invite(token, params \\ %{}, type \\ :call)
channels_invite(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.invite

channels_kick(token, params \\ %{}, type \\ :call)
channels_kick(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.kick

channels_leave(token, params \\ %{}, type \\ :call)
channels_leave(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.leave

channels_list(token, params \\ %{}, type \\ :call)
channels_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.list

channels_mark(token, params \\ %{}, type \\ :call)
channels_mark(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.mark

channels_open(token, params \\ %{}, type \\ :call)
channels_open(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.open

channels_rename(token, params \\ %{}, type \\ :call)
channels_rename(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.rename

channels_replies(token, params \\ %{}, type \\ :call)
channels_replies(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.replies

channels_setPurpose(token, params \\ %{}, type \\ :call)
channels_setPurpose(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.setPurpose

channels_setTopic(token, params \\ %{}, type \\ :call)
channels_setTopic(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.setTopic

channels_unarchive(token, params \\ %{}, type \\ :call)
channels_unarchive(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

channels.unarchive

chat_delete(token, params \\ %{}, type \\ :call)
chat_delete(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

chat.delete

chat_meMessage(token, params \\ %{}, type \\ :call)
chat_meMessage(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

chat.meMessage

chat_postMessage(token, params \\ %{}, type \\ :call)
chat_postMessage(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

chat.postMessage

chat_update(token, params \\ %{}, type \\ :call)
chat_update(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

chat.update

dnd_info(token, params \\ %{}, type \\ :call)
dnd_info(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

dnd.info

dnd_teamInfo(token, params \\ %{}, type \\ :call)
dnd_teamInfo(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

dnd.teamInfo

emoji_list(token, params \\ %{}, type \\ :call)
emoji_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

emoji.list

files_comments_add(token, params \\ %{}, type \\ :call)
files_comments_add(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

files.comments.add

files_comments_delete(token, params \\ %{}, type \\ :call)
files_comments_delete(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

files.comments.delete

files_comments_edit(token, params \\ %{}, type \\ :call)
files_comments_edit(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

files.comments.edit

files_delete(token, params \\ %{}, type \\ :call)
files_delete(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

files.delete

files_info(token, params \\ %{}, type \\ :call)
files_info(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

files.info

files_list(token, params \\ %{}, type \\ :call)
files_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

files.list

files_revokePublicURL(token, params \\ %{}, type \\ :call)
files_revokePublicURL(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

files.revokePublicURL

files_sharedPublicURL(token, params \\ %{}, type \\ :call)
files_sharedPublicURL(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

files.sharedPublicURL

files_upload(token, params \\ %{}, type \\ :call)
files_upload(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

files.upload

groups_archive(token, params \\ %{}, type \\ :call)
groups_archive(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.archive

groups_close(token, params \\ %{}, type \\ :call)
groups_close(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.close

groups_create(token, params \\ %{}, type \\ :call)
groups_create(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.create

groups_createChild(token, params \\ %{}, type \\ :call)
groups_createChild(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.createChild

groups_history(token, params \\ %{}, type \\ :call)
groups_history(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.history

groups_info(token, params \\ %{}, type \\ :call)
groups_info(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.info

groups_invite(token, params \\ %{}, type \\ :call)
groups_invite(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.invite

groups_kick(token, params \\ %{}, type \\ :call)
groups_kick(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.kick

groups_leave(token, params \\ %{}, type \\ :call)
groups_leave(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.leave

groups_list(token, params \\ %{}, type \\ :call)
groups_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.list

groups_mark(token, params \\ %{}, type \\ :call)
groups_mark(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.mark

groups_open(token, params \\ %{}, type \\ :call)
groups_open(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.open

groups_rename(token, params \\ %{}, type \\ :call)
groups_rename(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.rename

groups_replies(token, params \\ %{}, type \\ :call)
groups_replies(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.replies

groups_setPurpose(token, params \\ %{}, type \\ :call)
groups_setPurpose(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.setPurpose

groups_setTopic(token, params \\ %{}, type \\ :call)
groups_setTopic(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.setTopic

groups_unarchive(token, params \\ %{}, type \\ :call)
groups_unarchive(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

groups.unarchive

im_close(token, params \\ %{}, type \\ :call)
im_close(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

im.close

im_history(token, params \\ %{}, type \\ :call)
im_history(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

im.history

im_list(token, params \\ %{}, type \\ :call)
im_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

im.list

im_mark(token, params \\ %{}, type \\ :call)
im_mark(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

im.mark

im_open(token, params \\ %{}, type \\ :call)
im_open(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

im.open

im_replies(token, params \\ %{}, type \\ :call)
im_replies(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

im.replies

mpim_close(token, params \\ %{}, type \\ :call)
mpim_close(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

mpim.close

mpim_history(token, params \\ %{}, type \\ :call)
mpim_history(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

mpim.history

mpim_list(token, params \\ %{}, type \\ :call)
mpim_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

mpim.list

mpim_mark(token, params \\ %{}, type \\ :call)
mpim_mark(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

mpim.mark

mpim_open(token, params \\ %{}, type \\ :call)
mpim_open(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

mpim.open

mpim_replies(token, params \\ %{}, type \\ :call)
mpim_replies(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

mpim.replies

oauth_access(params \\ %{})
oauth_access(%{optional(atom) => any}) :: %{optional(binary) => any}

oauth.access

pins_add(token, params \\ %{}, type \\ :call)
pins_add(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

pins.add

pins_list(token, params \\ %{}, type \\ :call)
pins_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

pins.list

pins_remove(token, params \\ %{}, type \\ :call)
pins_remove(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

pins.remove

reactions_add(token, params \\ %{}, type \\ :call)
reactions_add(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

reactions.add

reactions_get(token, params \\ %{}, type \\ :call)
reactions_get(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

reactions.get

reactions_list(token, params \\ %{}, type \\ :call)
reactions_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

reactions.list

reactions_remove(token, params \\ %{}, type \\ :call)
reactions_remove(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

reactions.remove

reminders_add(token, params \\ %{}, type \\ :call)
reminders_add(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

reminders.add

reminders_complete(token, params \\ %{}, type \\ :call)
reminders_complete(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

reminders.complete

reminders_delete(token, params \\ %{}, type \\ :call)
reminders_delete(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

reminders.delete

reminders_info(token, params \\ %{}, type \\ :call)
reminders_info(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

reminders.info

reminders_list(token, params \\ %{}, type \\ :call)
reminders_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

reminders.list

rtm_start(token, params \\ %{}, type \\ :call)
rtm_start(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

rtm.start

search_all(token, params \\ %{}, type \\ :call)
search_all(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

search.all

search_files(token, params \\ %{}, type \\ :call)
search_files(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

search.files

search_messages(token, params \\ %{}, type \\ :call)
search_messages(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

search.messages

stars_add(token, params \\ %{}, type \\ :call)
stars_add(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

stars.add

stars_list(token, params \\ %{}, type \\ :call)
stars_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

stars.list

stars_remove(token, params \\ %{}, type \\ :call)
stars_remove(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

stars.remove

team_accessLogs(token, params \\ %{}, type \\ :call)
team_accessLogs(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

team.accessLogs

team_billableInfo(token, params \\ %{}, type \\ :call)
team_billableInfo(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

team.billableInfo

team_info(token, params \\ %{}, type \\ :call)
team_info(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

team.info

team_integrationLogs(token, params \\ %{}, type \\ :call)
team_integrationLogs(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

team.integrationLogs

team_profile_get(token, params \\ %{}, type \\ :call)
team_profile_get(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

team.profile.get

usergroups_create(token, params \\ %{}, type \\ :call)
usergroups_create(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

usergroups.create

usergroups_disable(token, params \\ %{}, type \\ :call)
usergroups_disable(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

usergroups.disable

usergroups_enable(token, params \\ %{}, type \\ :call)
usergroups_enable(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

usergroups.enable

usergroups_list(token, params \\ %{}, type \\ :call)
usergroups_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

usergroups.list

usergroups_update(token, params \\ %{}, type \\ :call)
usergroups_update(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

usergroups.update

usergroups_users_list(token, params \\ %{}, type \\ :call)
usergroups_users_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

usergroups.users.list

usergroups_users_update(token, params \\ %{}, type \\ :call)
usergroups_users_update(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

usergroups.users.update

users_deletePhoto(token, params \\ %{}, type \\ :call)
users_deletePhoto(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

users.deletePhoto

users_getPresence(token, params \\ %{}, type \\ :call)
users_getPresence(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

users.getPresence

users_identity(token, params \\ %{}, type \\ :call)
users_identity(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

users.identity

users_info(token, params \\ %{}, type \\ :call)
users_info(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

users.info

users_list(token, params \\ %{}, type \\ :call)
users_list(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

users.list

users_profile_get(token, params \\ %{}, type \\ :call)
users_profile_get(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

users.profile.get

users_profile_set(token, params \\ %{}, type \\ :call)
users_profile_set(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

users.profile.set

users_setActive(token, params \\ %{}, type \\ :call)
users_setActive(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

users.setActive

users_setPhoto(token, params \\ %{}, type \\ :call)
users_setPhoto(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

users.setPhoto

users_setPresence(token, params \\ %{}, type \\ :call)
users_setPresence(binary, %{optional(atom) => any}, :call | :cast) ::
  %{optional(binary) => any} |
  :ok

users.setPresence