aboutsummaryrefslogtreecommitdiff
path: root/content/docs/mal2go/v4/manga/get-manga-ranking.md
blob: ef5435f1c75f3b6030c212645c745668d8e1054c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
title: "Get manga ranking list"
description: "Returns a list of mangas sorted by their rank"
weight: 4
---

`GetMangaRanking` returns a list of mangas sorted by their rank. It accepts these arguments:

- `rankingType string` Ranking type can be:
  + `all`
  + `manga`
  + `novels`
  + `oneshots`
  + `doujin`
  + `manhwa`
  + `manhua`
  + `bypopularity`
  + `favorite`
- `limit int` Is the max amount of results to get. Max is 500.
- `offset int` Is the "offset" for results. If offset is greater than 0 the first n number of reults will be ignored.
- `nsfw bool` Wether to include NSFW rated results
- `fields []string` The fields to include in the results. [Here]() is a list of the valid fields. Just using an empty slice (`[]string{}`) will include all the fields. Again, to get some very specific fields, [`GetMangaById`](#get-data-about-a-manga) is the most reliable option.

Example:

``` go
package main

import (
  "github.com/MikunoNaka/MAL2Go/v4/manga"
  "log"
  "fmt"
)

func main() {
  authToken := "YOUR_TOKEN_HERE"
  myClient := manga.Client {
    AuthToken: "Bearer " + authToken,
  }
    
  rankingType := "novels"
  limit, offset := 10, 0
  nsfw := true // include NSFW results
  fields := []string{"title"}
    
  ranking, err := myClient.GetMangaRanking(rankingType, limit, offset, nsfw, fields)
  if err != nil {
    log.Fatal(err) // remember kids, always handle errors
  }
    
  for _, i := range ranking {
    fmt.Printf("#%d: %s\n", i.RankNum, i.Title)
  }
}
```

Above example prints the top 10 ranked novels on MyAnimeList.