According to the Developer Portal of Discord, Discord API is based around two core layers. The first one is the HTPPS or REST API for general operations and the second one is for the persistent secure websocket based connection for sending and subscribing to real time evens. Apparently, the most common use case of the Discord API will be providing a service, or access to the platform through the OAuth2 API.
You have to know that Discord exposes he different versions of the API. You are able to specify version by including it in the request path. Please keep in mind that omitting the version number from the route will route the requests to the current default version.
This paragraph will talk about the authentication. The thing called the authentication with the Discord API can be done in one of two ways. The first one is using he bot token gained by registering the bot and the second one is using the Oauth2 bearer token gained through the Oauth2 API. For all the types of the authentication, the authentication is perfomed with the Authorization HTTP header in the format the “Authentication: TOKEN_TYPE TOKEN”.
Discord utilizes the snowflake format for uniquely identifieable descriptors or IDs. Those IDs are guaranteed to be unique across all of Discord, expect in several unique scenarios in which child objects share the ID of the parent. Due to the fact that Snowflake IDs are up to 64 bits in the size, they are always returned as strings in the HTTP API in order to prevent integer overflows in some languages.
Usually, people use snowflake IDs in a lot of API routes for pagination. The standarized paradigm that people utilize is one in which you are able to specify IDs before and after in combination with the limit in order to retrieve the desired page of the results. In the end, you will want to refer to the certain endpoint documentation for details.
It is stated that it is useful note that showflake IDs are just numbers with the time stamp, so when dealing with pagination where you want results from the beginning of time or before or after the certain time, you can generate the snowflake ID for that time.
The thing called the resource fields may contain the null value that have types that are prefixed with the question mark. Beside, resource fields that are optional have names that are suffixed with the question mark.
Discord operates at the scale when the true consistency seems impossible. Due to this fact, a lot of operations in the API and in between the services are eventually consistent. It makes the client actions can never be serialized and may be executed in any order. Along with those constraints, all the vents in Discord may never be sent to the client, may be sent exactly on time to the client, and may be sent up to N times every client. Keep in mind that clients have to operate on events and results from the API in as much of the idempotent behavior as possible.