This Node.js application provides an API for fetching Discord user avatars(pfp).
- Clone this repository.
- Install dependencies by running
npm install
.
npm install cors express node-fetch dotenv
- Create a
.env
file in the root directory and add your Discord bot token:DISCORD_BOT_TOKEN=your_discord_bot_token_here
- Start the server by running
cd api
first thennode index
.
- Endpoint:
/api/:userId
- Method: GET
- Parameters:
userId
(required): Discord user ID for which avatar is to be fetched.
- Example:
{ "id": "773952016036790272", "username": "yellowgreg", "display_name": null, "avatarUrl": "https://cdn.discordapp.com/avatars/773952016036790272/cfe9480144d80fbf9625abf9e66a0b9b.png?size=128" }
- Response: JSON object containing the avatar URL.
- Endpoint:
/api/pfp/:userId/image
- Method: GET
- Parameters:
userId
(required): Discord user ID for which avatar is to be fetched.size
(optional): Size of the avatar image. Default is 512.
- Response: Redirects to the URL of the avatar image.
- Endpoint:
/api/pfp/:userId/smallimage
- Method: GET
- Parameters:
userId
(required): Discord user ID for which avatar is to be fetched.size
(optional): Size of the avatar image. Default is 128.
- Response: Redirects to the URL of the avatar image with specified size.
- Endpoint:
/api/pfp/:userId/bigimage
- Method: GET
- Parameters:
userId
(required): Discord user ID for which avatar is to be fetched.size
(optional): Size of the avatar image. Default is 1024.
- Response: Redirects to the URL of the avatar image with specified size.
- Endpoint:
/api/pfp/:userId/superbigimage
- Method: GET
- Parameters:
userId
(required): Discord user ID for which avatar is to be fetched.size
(optional): Size of the avatar image. Default is 4096.
- Response: Redirects to the URL of the avatar image with specified size.
- express: Fast, unopinionated, minimalist web framework for Node.js.
- cors: Middleware for enabling Cross-Origin Resource Sharing (CORS) in Express.js.
- dotenv: Loads environment variables from a .env file into process.env.
- Free to use