aboutsummaryrefslogtreecommitdiff
path: root/content/docs/mal2go/v4/manga/get-manga-by-id.md
diff options
context:
space:
mode:
Diffstat (limited to 'content/docs/mal2go/v4/manga/get-manga-by-id.md')
-rw-r--r--content/docs/mal2go/v4/manga/get-manga-by-id.md44
1 files changed, 44 insertions, 0 deletions
diff --git a/content/docs/mal2go/v4/manga/get-manga-by-id.md b/content/docs/mal2go/v4/manga/get-manga-by-id.md
new file mode 100644
index 0000000..682ef29
--- /dev/null
+++ b/content/docs/mal2go/v4/manga/get-manga-by-id.md
@@ -0,0 +1,44 @@
+---
+title: "Getting a manga's information"
+description: "Specify a manga's ID to get all the data about it."
+weight: 3
+---
+
+`GetMangaById` takes in a manga's ID (which can be obtained using [`SearchManga`](#searching-for-a-manga) or through the URL of the manga's page on MAL) and returns information about it. This method takes these arguments:
+
+- `id int` The manga's ID
+- `fields []string` The fields to include in the response. [Here]() is a list of the valid fields. Just using an empty slice (`[]string{}`) will include all the fields.
+
+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,
+ }
+
+ id := 103890
+ fields := []string{"title", "my_list_status", "num_chapters"}
+
+ manga, err := myClient.GetMangaById(id, fields)
+ if err != nil {
+ log.Fatal(err) // remember kids, always handle errors
+ }
+
+ fmt.Printf("You have read %d out of %d chapters in %s. Your list status for %s is %s.\n", manga.MyListStatus.ChaptersRead, manga.NumChapters, manga.Title, manga.Title, manga.MyListStatus.Status)
+}
+```
+
+Above example prints something like
+`"You have read 7 out of 187 chapters in Bokutachi wa Benkyou ga Dekinai. Your list status for Bokutachi wa Benkyou ga Dekinai is reading."`
+
+Above output shows blank status because mushishi is not in my list. This is expected.