Official MAL API

Information
Welcome to the official MyAnimeList's API club! This is a place where developers can talk about the API, ask questions, look for help to fix bugs, suggest new features, and showcase their projects. Join us and subscribe to the club! First time here? No worries. You can start from this topic. Don't hesitate to leave a comment or open a new discussion if you need help! Quick access


Club Members


Displaying 5 of 252 topics | See All
Club Discussion
Which endpoints support nsfw query param?
crimson-megumin - Apr 21
2 repliesby crimson-megumin »»
Yesterday, 2:29 PM
Cant build the URL
tamcio_ - Dec 4, 2022
4 repliesby Jotzy »»
Apr 22, 4:35 AM
I made a new anime recommendation system for MyAnimeList
Asudox - Mar 21
4 repliesby Asudox »»
Apr 11, 2:58 PM
API Rate Limit?
Asudox - Jan 23
7 repliesby pepeefirat »»
Mar 23, 3:57 AM
Some Animes Missing on API Reponse
Niccol0 - Jan 26
3 repliesby ZeroCrystal »»
Mar 15, 3:44 PM



Club Comments
ZeroCrystal | Mar 26, 8:27 AM
@INVADER056: It's not straightforward, but you can create a calendar from the seasonal data, with some post-processing on the client.

For example:
GET https://api.myanimelist.net/v2/anime/season/2024/winter?limit=500&fields=broadcast,start_date,end_date&nsfw=true

{
  "data": [
    {
      "node": {
        "id": 55866,
        "title": "Yubisaki to Renren",
        "main_picture": {...},
        "broadcast": {
          "day_of_the_week": "saturday",
          "start_time": "22:30"
        },
        "start_date": "2024-01-06",
        "end_date": "2024-03-23"
      }
    },
    {
      "node": {
        "id": 52701,
        "title": "Dungeon Meshi",
        "main_picture": {...},
        "broadcast": {
          "day_of_the_week": "thursday",
          "start_time": "22:30"
        },
        "start_date": "2024-01-04"
      }
    },
    [...]
}

You can retrieve all anime for a specific season with a single request. Then, you can filter them based on their airing days and store them as you prefer.

The broadcast object contains the airing day and time (Japan Standard Time) for an anime.
start_date and end_date, as the names suggest, tell you the first and last airing day for that series.

Be aware that all these fields are optional and could be missing for some anime, especially for the less popular ones.

INVADER056 | Mar 26, 3:51 AM
Hello @Zerocrystal in the api is there a wau where we can get the data for the anime episodes airing today? just like Jikan

ZeroCrystal | Mar 21, 12:47 PM
@INVADER056: The Code Verifier and the Code Challenge must be the same string since MAL only supports the plain code challenge method.
All's well that ends well.

INVADER056 | Mar 21, 11:34 AM
@ZeroCrystal tthanks for the doubt aparently the code verifer and the codechallenge should be set to same .It worked finall i can take a good sleep been trying this restlessly for 7 days

INVADER056 | Mar 21, 11:12 AM
@ZeroCrystal
The codeverifier and code challenger should be different or same I tried in both ways then also same error

ZeroCrystal | Mar 21, 11:09 AM
@INVADER056: A couple of questions:
• Are you certain that the Code Verifier you appended to the authorization URL is exactly the same as the one you're using later to issue a new access token?
• The Code Verifier and the Code Challenge are the exact same string? The Code Challenge must not be hashed (in MAL's case).

INVADER056 | Mar 21, 11:03 AM
@ZeroCrystal


private func createAuthorizationURL(codeChallenge: String) -> URL {
let baseURL = "https://myanimelist.net/v1/oauth2/authorize"
let redirectUri = "com.hemanth://something/"

let queryItems = [
URLQueryItem(name: "response_type", value: "code"),
URLQueryItem(name: "client_id", value: "5274891a3e0d34914d1cc7f5376a59e5"),
URLQueryItem(name: "code_challenge", value: generateCodeVerifier()),
URLQueryItem(name: "state", value: getState()),
URLQueryItem(name: "redirect_uri", value: redirectUri),
URLQueryItem(name: "code_challenge_method", value: "plain"),

]

var components = URLComponents(string: baseURL)!
components.queryItems = queryItems
print("Authorisation get url", components.url)
return components.url!
}

// Open the authorization URL
private func openAuthorizationURL(url: URL) {
UIApplication.shared.open(url)
}
}



func exchangeAuthorizationCodeForTokens(authorizationCode: String) {
let clientId = "5274891a3e0d34914d1cc7f5376a59e5"
let redirectUri = "com.hemanth://something/"
guard let codeVerifier = testViewModel.codeVerifier else {
print("Error: Missing code verifier")
return
}
print("Code Verifier is", codeVerifier)

let queryItems = [
URLQueryItem(name: "code", value: authorizationCode),
URLQueryItem(name: "client_id", value: clientId),
URLQueryItem(name: "grant_type", value: "authorization_code"),
URLQueryItem(name: "redirect_uri", value: redirectUri),
URLQueryItem(name: "state", value: testViewModel.state),
URLQueryItem(name: "code_verifier", value: codeVerifier)
]

guard let httpBodyData = urlEncodedFormData(from: queryItems) else {
print("Error: Failed to create HTTP body data")
return
}

var urlComponents = URLComponents(string: "https://myanimelist.net/v1/oauth2/token")
urlComponents?.queryItems = queryItems
print("URL To get token:\(urlComponents?.url)")
guard let url = urlComponents?.url else {
print("Error: Could not create URL")
return
}

var request = URLRequest(url: url)
request.httpBody = httpBodyData
request.httpMethod = "POST"
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")

INVADER056 | Mar 21, 11:01 AM
@ZeroCrystal i am getting
HTTP Error: 400
Response Data: {"error":"invalid_grant","message":"The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.","hint":"Failed to verify `code_verifier`."}

Club in App
Chat features have been enabled for this club inside the official MAL app! Click here to get it.
Club Stats
Members: 1601
Pictures:
Category: Other
Created: Jul 14, 2009


Club Staff
Kineta (Secretary)
myanimelistllc (Secretary)
ZeroCrystal (Secretary)

Club Type
This is a public club.
Anyone can join and invite others to join. Club details, pictures, comments and club discussions can be viewed by any user, regardless of whether they are a member of the club or not.

Club Secretary can change the Club Type at any time. For more information on Club Types, click here.


It’s time to ditch the text file.
Keep track of your anime easily by creating your own list.
Sign Up Login