How to fetch MAL user statistics using a Discord bot?

I’m working on a Discord bot and want to pull user stats from MyAnimeList profiles. I’m stuck on how to get the data for completed shows, currently watching, dropped series, and other stats.

These details are usually found on a user’s profile page. But I can’t figure out the best way to grab this info programmatically.

Has anyone done something similar before? What’s the easiest method to extract these stats for use in a Discord bot? Any tips or code examples would be really helpful!

I’m pretty new to web scraping, so a beginner-friendly explanation would be awesome. Thanks in advance for any advice!

hey, try the jikan api for mal stats. its unofficial but workable. make http requests from your bot, handle rate limits, and cache responses to cut down on calls. hope this helps!

Having dealt with MAL data retrieval before, I can suggest using the official MyAnimeList API instead of scraping. It’s more reliable and provides cleaner data access. You’ll need to register your application to get an API key.

The endpoint you’re looking for is GET /v2/users/{username}/statistics. This returns a JSON object with all the stats you mentioned. To implement this in your Discord bot, use a library like aiohttp for asynchronous HTTP requests.

Remember to handle rate limits and errors properly. Also, consider caching results to reduce API calls, as user stats don’t change that frequently. This approach is more stable long-term and respects MAL’s terms of service.

If you need help with implementation specifics, feel free to ask for more details.

I’ve actually worked on a similar project before, and I can share what worked for me. Instead of web scraping, which can be unreliable due to site changes, I’d recommend using the Jikan API. It’s an unofficial API for MyAnimeList that’s much easier to work with.

To fetch user stats, you can use the /users/{username}/statistics endpoint. This gives you all the data you’re looking for - completed shows, watching, dropped, etc. It’s JSON formatted, so it’s simple to parse in most programming languages.

For implementation, you’ll need to make HTTP requests to the API. Most Discord bot libraries have built-in HTTP clients, or you can use a separate library like axios or requests. Just remember to handle rate limiting to avoid getting blocked.

One tip: cache the results for a short time to reduce API calls. MAL stats don’t update that frequently, so you can safely store them for a few hours between checks.