Endpoint
The MyAnimeList API v2 is accessed via:mal_id is obtained from the AniList API response (idMal field).
Authentication
Annie Mei authenticates requests with theX-MAL-CLIENT-ID header. The current implementation uses a single environment variable:
MAL_CLIENT_ID- Your MyAnimeList API client ID
Response Model
The API response is deserialized into theMalResponse struct:
Song Text Format
TheSongInfo.text field contains structured information in this format:
Parsing Logic
The bot parses the following components from each song text:- Song Number: Extracted from
#N:prefix - Song Name: Text between quotes (
"or') - Romaji vs Kana: Text before parentheses is romaji, text in parentheses is kana/native
- Artists: Text after “by” and before episode range
- Episode Range: Text in parentheses starting with “(ep”
Example Response
Data Transformations
Display Formatting
Songs are formatted for Discord embeds with the following features:Spotify Integration
For each song, the bot attempts to find a matching Spotify track:Artist Name Truncation
When more than 3 artists are listed, the display truncates to the first 3 and adds “and more”:List Truncation
Only the first 10 opening and ending themes are displayed to avoid Discord embed size limits:Usage Example
Error Handling
When song data is unavailable or parsing fails:- Missing opening/ending themes return
"No information available" - Failed song name parsing returns
"No information available" - Missing artist names are omitted from display
- Missing episode ranges are omitted from display
Rate Limiting
MyAnimeList enforces API rate limits. The bot should implement:- Request throttling
- Response caching (especially for popular anime)
- Graceful error handling for 429 Too Many Requests
