MCPcopy Index your code
hub / github.com/slackapi/python-slack-sdk / AsyncWebClient

Class AsyncWebClient

slack_sdk/web/async_client.py:39–6015  ·  view source on GitHub ↗

A WebClient allows apps to communicate with the Slack Platform's Web API. https://docs.slack.dev/reference/methods The Slack Web API is an interface for querying information from and enacting change in a Slack workspace. This client handles constructing and sending HTTP requests t

Source from the content-addressed store, hash-verified

37
38
39class AsyncWebClient(AsyncBaseClient):
40 """A WebClient allows apps to communicate with the Slack Platform's Web API.
41
42 https://docs.slack.dev/reference/methods
43
44 The Slack Web API is an interface for querying information from
45 and enacting change in a Slack workspace.
46
47 This client handles constructing and sending HTTP requests to Slack
48 as well as parsing any responses received into a `SlackResponse`.
49
50 Attributes:
51 token (str): A string specifying an `xoxp-*` or `xoxb-*` token.
52 base_url (str): A string representing the Slack API base URL.
53 Default is `'https://slack.com/api/'`
54 timeout (int): The maximum number of seconds the client will wait
55 to connect and receive a response from Slack.
56 Default is 30 seconds.
57 ssl (SSLContext): An [`ssl.SSLContext`][1] instance, helpful for specifying
58 your own custom certificate chain.
59 proxy (str): String representing a fully-qualified URL to a proxy through
60 which to route all requests to the Slack API. Even if this parameter
61 is not specified, if any of the following environment variables are
62 present, they will be loaded into this parameter: `HTTPS_PROXY`,
63 `https_proxy`, `HTTP_PROXY` or `http_proxy`.
64 headers (dict): Additional request headers to attach to all requests.
65
66 Methods:
67 `api_call`: Constructs a request and executes the API call to Slack.
68
69 Example of recommended usage:
70 ```python
71 import os
72 from slack_sdk.web.async_client import AsyncWebClient
73
74 client = AsyncWebClient(token=os.environ['SLACK_API_TOKEN'])
75 response = client.chat_postMessage(
76 channel='#random',
77 text="Hello world!")
78 assert response["ok"]
79 assert response["message"]["text"] == "Hello world!"
80 ```
81
82 Example manually creating an API request:
83 ```python
84 import os
85 from slack_sdk.web.async_client import AsyncWebClient
86
87 client = AsyncWebClient(token=os.environ['SLACK_API_TOKEN'])
88 response = client.api_call(
89 api_method='chat.postMessage',
90 json={'channel': '#random','text': "Hello world!"}
91 )
92 assert response["ok"]
93 assert response["message"]["text"] == "Hello world!"
94 ```
95
96 Note:

Callers 15

oauth_callbackFunction · 0.90
async_script.pyFile · 0.90
slack_appFunction · 0.90
oauth_callbackFunction · 0.90
oauth_callbackFunction · 0.90
slack_appFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
setUpMethod · 0.90
setUpMethod · 0.90

Calls

no outgoing calls

Tested by 15

setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72