You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For now, RPC is in a private beta. We are not currently accepting any new developers into the program at this time.
11
-
</Danger>
9
+
## RPC over IPC
12
10
13
-
All Discord clients have an RPC server running on localhost that allows control over local Discord clients.
11
+
Discord's RPC server supports IPC (Inter-Process Communication) as the primary transport for native applications and games. This allows high-performance, local communication with the Discord client without requiring network-level overhead.
| Linux/macOS |`${XDG_RUNTIME_DIR}/discord-ipc-{n}`, `${TMPDIR}/discord-ipc-{n}`, `${TMP}/discord-ipc-{n}`, `${TEMP}/discord-ipc-{n}`, or `/tmp/discord-ipc-{n}`|
21
19
22
-
## Restrictions
20
+
On Linux/macOS, Discord resolves the IPC prefix in this order: `XDG_RUNTIME_DIR`, `TMPDIR`, `TMP`, `TEMP`, then `/tmp` as a final fallback.
23
21
24
-
For connections to the RPC server, a [list of approved testers](/developers/topics/rpc#authorize) is used to restrict access while you're still developing. You can invite up to 50 people.
22
+
### Connecting to IPC
25
23
26
-
For applications/games not approved, we limit you to creating 10 guilds and 10 channels. This limit is raised to virtually unlimited after approval.
24
+
To begin a session, the application must open the IPC socket and send a `HANDSHAKE` opcode.
27
25
28
-
##Payloads
26
+
#### Handshake Payload
29
27
30
-
<ManualAnchorid="payloads-payload-structure" />
31
-
###### Payload Structure
28
+
The payload is a JSON object containing the RPC version and your application's client ID.
|`client_id`|`string`| Your application's client ID |
34
+
35
+
###### Example Handshake
36
+
37
+
```
38
+
[00 00 00 00] // Opcode 0 (Handshake)
39
+
[2D 00 00 00] // Length 45
40
+
{"v":1,"client_id":"123456789012345678"}
41
+
```
42
+
43
+
Upon success, Discord will respond with a `FRAME` (Opcode `1`) containing the `READY` event.
44
+
45
+
Once the handshake is complete, all subsequent requests and responses use the `FRAME` opcode. The internal structure of these frames follows the standard [RPC Payload structure](/developers/topics/rpc#payloads-payload-structure)
|`0`|`HANDSHAKE`| Sent by the client to initiate the connection |
52
+
|`1`|`FRAME`| Used for all standard RPC commands and events |
53
+
|`2`|`CLOSE`| Sent by either side to close the connection |
54
+
|`3`|`PING`| Sent to check if the connection is alive |
55
+
|`4`|`PONG`| Response to a `PING`|
56
+
57
+
<Accordiontitle="RPC over WebSocket (Deprecated)"icon="warning">
58
+
<Danger>
59
+
This is a deprecated way, which is only available for old participants of private beta. It is preferable to use RPC that uses IPC.
60
+
</Danger>
61
+
62
+
All Discord clients have an RPC server running on localhost that allows control over local Discord clients.
40
63
41
-
## Connecting
64
+
###Connecting to WebSocket
42
65
43
66
The local RPC server runs on localhost (`127.0.0.1`) and is set up to process WebSocket connections and proxy API requests.
44
67
@@ -61,6 +84,33 @@ If you're connecting to the RPC server from within a non-browser application (li
61
84
62
85
The port range for Discord's local RPC server is [6463, 6472]. Since the RPC server runs locally, there's a chance it might not be able to obtain its preferred port when it tries to bind to one. For this reason, the local RPC server will pick one port out of a range of these 10 ports, trying sequentially until it can bind to one. When implementing your client, you should perform the same sequential checking to find the correct port to connect to.
63
86
87
+
<ManualAnchorid="rpc-versions" />
88
+
###### RPC Versions
89
+
90
+
| Version | Out of Service |
91
+
|---------|----------------|
92
+
| 1 | no |
93
+
</Accordion>
94
+
95
+
## Restrictions
96
+
97
+
For connections to the RPC server, a [list of approved testers](/developers/topics/rpc#authorize) is used to restrict access while you're still developing. You can invite up to 50 people.
98
+
99
+
For applications/games not approved, we limit you to creating 10 guilds and 10 channels. This limit is raised to virtually unlimited after approval.
| nonce | string | unique string used once for replies from the server | In responses to commands (not subscribed events) |
110
+
| evt | enum |[subscription event](/developers/topics/rpc#commands-and-events-rpc-events)| In subscribed events, errors, and (un)subscribing events |
111
+
| data | object | event data | In responses from the server |
112
+
| args | object | command arguments | In commands sent to the server |
113
+
64
114
## Authenticating
65
115
66
116
In order to call any commands over RPC, you must be authenticated or you will receive a code `4006` error response. Thankfully, we've removed the oppressive nature of a couple commands that will let you `AUTHORIZE` and `AUTHENTICATE` new users. First, call [AUTHORIZE](/developers/topics/rpc#authorize):
@@ -105,7 +155,7 @@ Commands are requests made to the RPC socket by a client.
|[READY](/developers/topics/rpc#ready)| non-subscription event sent immediately after connecting, contains server information |
136
-
|[ERROR](/developers/topics/rpc#error)| non-subscription event sent when there is an error, including command responses |
137
-
|[GUILD_STATUS](/developers/topics/rpc#guildstatus)| sent when a subscribed server's state changes |
138
-
|[GUILD_CREATE](/developers/topics/rpc#guildcreate)| sent when a guild is created/joined on the client |
139
-
|[CHANNEL_CREATE](/developers/topics/rpc#channelcreate)| sent when a channel is created/joined on the client |
140
-
|[VOICE_CHANNEL_SELECT](/developers/topics/rpc#voicechannelselect)| sent when the client joins a voice channel |
141
-
|[VOICE_STATE_CREATE](/developers/topics/rpc#voicestatecreatevoicestateupdatevoicestatedelete)| sent when a user joins a subscribed voice channel |
142
-
|[VOICE_STATE_UPDATE](/developers/topics/rpc#voicestatecreatevoicestateupdatevoicestatedelete)| sent when a user's voice state changes in a subscribed voice channel (mute, volume, etc.) |
143
-
|[VOICE_STATE_DELETE](/developers/topics/rpc#voicestatecreatevoicestateupdatevoicestatedelete)| sent when a user parts a subscribed voice channel |
144
-
|[VOICE_SETTINGS_UPDATE](/developers/topics/rpc#voicesettingsupdate)| sent when the client's voice settings update |
145
-
|[VOICE_CONNECTION_STATUS](/developers/topics/rpc#voiceconnectionstatus)| sent when the client's voice connection status changes |
146
-
|[SPEAKING_START](/developers/topics/rpc#speakingstartspeakingstop)| sent when a user in a subscribed voice channel speaks |
147
-
|[SPEAKING_STOP](/developers/topics/rpc#speakingstartspeakingstop)| sent when a user in a subscribed voice channel stops speaking |
148
-
|[MESSAGE_CREATE](/developers/topics/rpc#messagecreatemessageupdatemessagedelete)| sent when a message is created in a subscribed text channel |
149
-
|[MESSAGE_UPDATE](/developers/topics/rpc#messagecreatemessageupdatemessagedelete)| sent when a message is updated in a subscribed text channel |
150
-
|[MESSAGE_DELETE](/developers/topics/rpc#messagecreatemessageupdatemessagedelete)| sent when a message is deleted in a subscribed text channel |
151
-
|[NOTIFICATION_CREATE](/developers/topics/rpc#notificationcreate)| sent when the client receives a notification (mention or new message in eligible channels) |
152
-
|[ACTIVITY_JOIN](/developers/topics/rpc#activityjoin)| sent when the user clicks a Rich Presence join invite in chat to join a game |
153
-
|[ACTIVITY_SPECTATE](/developers/topics/rpc#activityspectate)| sent when the user clicks a Rich Presence spectate invite in chat to spectate a game |
154
-
|[ACTIVITY_JOIN_REQUEST](/developers/topics/rpc#activityjoinrequest)| sent when the user receives a Rich Presence Ask to Join request |
|[READY](/developers/topics/rpc#ready-ready-dispatch-data-structure)| non-subscription event sent immediately after connecting, contains server information |
186
+
|[ERROR](/developers/topics/rpc#error-error-data-structure)| non-subscription event sent when there is an error, including command responses |
187
+
| CURRENT_USER_UPDATE | sent when the local user's data (avatar, username, etc.) changes |
188
+
| RELATIONSHIP_UPDATE | sent when a relationship (friend, block, etc.) is added or removed |
189
+
|[GUILD_STATUS](/developers/topics/rpc#guildstatus)| sent when a subscribed server's state changes |
190
+
|[GUILD_CREATE](/developers/topics/rpc#guildcreate)| sent when a guild is created/joined on the client |
191
+
|[CHANNEL_CREATE](/developers/topics/rpc#channelcreate)| sent when a channel is created/joined on the client |
192
+
|[VOICE_CHANNEL_SELECT](/developers/topics/rpc#voicechannelselect)| sent when the client joins a voice channel |
193
+
|[VOICE_STATE_CREATE](/developers/topics/rpc#voicestatecreate/voicestateupdate/voicestatedelete)| sent when a user joins a subscribed voice channel |
194
+
|[VOICE_STATE_UPDATE](/developers/topics/rpc#voicestatecreate/voicestateupdate/voicestatedelete)| sent when a user's voice state changes in a subscribed voice channel (mute, volume, etc.) |
195
+
|[VOICE_STATE_DELETE](/developers/topics/rpc#voicestatecreate/voicestateupdate/voicestatedelete)| sent when a user parts a subscribed voice channel |
196
+
|[VOICE_SETTINGS_UPDATE](/developers/topics/rpc#voicesettingsupdate)| sent when the client's voice settings update |
197
+
|[VOICE_CONNECTION_STATUS](/developers/topics/rpc#voiceconnectionstatus)| sent when the client's voice connection status changes |
198
+
|[SPEAKING_START](/developers/topics/rpc#speakingstart/speakingstop)| sent when a user in a subscribed voice channel speaks |
199
+
|[SPEAKING_STOP](/developers/topics/rpc#speakingstart/speakingstop)| sent when a user in a subscribed voice channel stops speaking |
200
+
|[MESSAGE_CREATE](/developers/topics/rpc#messagecreate/messageupdate/messagedelete)| sent when a message is created in a subscribed text channel |
201
+
|[MESSAGE_UPDATE](/developers/topics/rpc#messagecreate/messageupdate/messagedelete)| sent when a message is updated in a subscribed text channel |
202
+
|[MESSAGE_DELETE](/developers/topics/rpc#messagecreate/messageupdate/messagedelete)| sent when a message is deleted in a subscribed text channel |
203
+
|[NOTIFICATION_CREATE](/developers/topics/rpc#notificationcreate)| sent when the client receives a notification (mention or new message in eligible channels) |
204
+
|[ACTIVITY_JOIN](/developers/topics/rpc#activityjoin)| sent when the user clicks a Rich Presence join invite in chat to join a game |
205
+
|[ACTIVITY_SPECTATE](/developers/topics/rpc#activityspectate)| sent when the user clicks a Rich Presence spectate invite in chat to spectate a game |
206
+
|[ACTIVITY_JOIN_REQUEST](/developers/topics/rpc#activityjoinrequest)| sent when the user receives a Rich Presence Ask to Join request |
207
+
| ACTIVITY_INVITE | sent when the user receives an activity invitation |
208
+
| ENTITLEMENT_CREATE | sent when a user purchases or receives a new entitlement (SKU/Game) |
209
+
| ENTITLEMENT_DELETE | sent when an entitlement is removed |
0 commit comments