Documentation ¶
Index ¶
- Constants
- type AtHomeService
- type AuthResponse
- type AuthService
- func (s *AuthService) GetRefreshToken() string
- func (s *AuthService) IsLoggedIn() bool
- func (s *AuthService) Login(user, pwd string) error
- func (s *AuthService) LoginContext(ctx context.Context, user, pwd string) error
- func (s *AuthService) Logout() error
- func (s *AuthService) LogoutContext(ctx context.Context) error
- func (s *AuthService) RefreshSessionToken() error
- func (s *AuthService) RefreshSessionTokenContext(ctx context.Context) error
- func (s *AuthService) SetRefreshToken(refreshToken string)
- type AuthorAttributes
- type Chapter
- type ChapterAttributes
- type ChapterList
- type ChapterReadMarkers
- type ChapterService
- func (s *ChapterService) GetMangaChapters(id string, params url.Values) (*ChapterList, error)
- func (s *ChapterService) GetMangaChaptersContext(ctx context.Context, id string, params url.Values) (*ChapterList, error)
- func (s *ChapterService) GetReadMangaChapters(id string) (*ChapterReadMarkers, error)
- func (s *ChapterService) GetReadMangaChaptersContext(ctx context.Context, id string) (*ChapterReadMarkers, error)
- func (s *ChapterService) SetReadUnreadMangaChapters(id string, read, unRead []string) (*Response, error)
- func (s *ChapterService) SetReadUnreadMangaChaptersContext(ctx context.Context, id string, read, unRead []string) (*Response, error)
- type ChaptersData
- type DexClient
- type Error
- type ErrorResponse
- type LocalisedStrings
- type MDHomeClient
- type MDHomeServerResponse
- type Manga
- type MangaAttributes
- type MangaList
- type MangaService
- func (s *MangaService) CheckIfMangaFollowed(id string) (bool, error)
- func (s *MangaService) CheckIfMangaFollowedContext(ctx context.Context, id string) (bool, error)
- func (s *MangaService) GetMangaList(params url.Values) (*MangaList, error)
- func (s *MangaService) GetMangaListContext(ctx context.Context, params url.Values) (*MangaList, error)
- func (s *MangaService) ToggleMangaFollowStatus(id string, toFollow bool) (*Response, error)
- func (s *MangaService) ToggleMangaFollowStatusContext(ctx context.Context, id string, toFollow bool) (*Response, error)
- type Relationship
- type Response
- type ResponseType
- type ScanlationGroupAttributes
- type Tag
- type TagAttributes
- type User
- type UserAttributes
- type UserResponse
- type UserService
- func (s *UserService) GetLoggedUser() (*UserResponse, error)
- func (s *UserService) GetLoggedUserContext(ctx context.Context) (*UserResponse, error)
- func (s *UserService) GetUserFollowedMangaList(limit, offset int, includes []string) (*MangaList, error)
- func (s *UserService) GetUserFollowedMangaListContext(ctx context.Context, limit, offset int, includes []string) (*MangaList, error)
Constants ¶
const ( GetMDHomeURLPath = "at-home/server/%s" MDHomeReportURL = "https://api.mangadex.network/report" )
const ( LoginPath = "auth/login" LogoutPath = "auth/logout" RefreshTokenPath = "auth/refresh" )
const ( MangaChaptersPath = "manga/%s/feed" MangaReadMarkersPath = "manga/%s/read" )
const ( MangaListPath = "manga" CheckIfMangaFollowedPath = "user/follows/manga/%s" ToggleMangaFollowPath = "manga/%s/follow" )
const ( ShonenDemographic string = "shounen" ShoujoDemographic string = "shoujo" JoseiDemographic string = "josei" SeinenDemograpic string = "seinen" )
Publication demographic
const ( OngoingStatus string = "ongoing" CompletedStatus string = "completed" HiatusStatus string = "hiatus" CancelledStatus string = "cancelled" )
Manga publication status
const ( Reading string = "reading" OnHold string = "on_hold" PlanToRead string = "plan_to_read" Dropped string = "dropped" ReReading string = "re_reading" Completed string = "completed" )
Manga reading status
const ( Safe string = "safe" Suggestive string = "suggestive" Erotica string = "erotica" Porn string = "pornographic" )
Manga content rating
const ( MangaRel string = "manga" ChapterRel string = "chapter" CoverArtRel string = "cover_art" AuthorRel string = "author" ArtistRel string = "artist" ScanlationGroupRel string = "scanlation_group" TagRel string = "tag" UserRel string = "user" CustomListRel string = "custom_list" )
Relationship types. Useful for reference expansions
const ( GetUserFollowedMangaListPath = "user/follows/manga" GetLoggedUserPath = "user/me" )
const (
BaseAPI = "https://api.mangadex.org"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtHomeService ¶
type AtHomeService service
AtHomeService : Provides MangaDex@Home services provided by the API.
func (*AtHomeService) NewMDHomeClient ¶
func (s *AtHomeService) NewMDHomeClient(chapterID string, quality string, forcePort443 bool) (*MDHomeClient, error)
NewMDHomeClient : Get MangaDex@Home client for a chapter. https://api.mangadex.org/docs.html#operation/get-at-home-server-chapterId
func (*AtHomeService) NewMDHomeClientContext ¶
func (s *AtHomeService) NewMDHomeClientContext(ctx context.Context, chapterID string, quality string, forcePort443 bool) (*MDHomeClient, error)
NewMDHomeClientContext : NewMDHomeClient with custom context.
type AuthResponse ¶
type AuthResponse struct { Result string `json:"result"` Token token `json:"token"` Message *string `json:"message,omitempty"` }
AuthResponse : Typical AuthService response.
func (AuthResponse) GetResult ¶
func (ar AuthResponse) GetResult() string
type AuthService ¶
type AuthService service
AuthService : Provides Auth services provided by the API.
func (*AuthService) GetRefreshToken ¶
func (s *AuthService) GetRefreshToken() string
GetRefreshToken : Get the current refresh token of the client.
func (*AuthService) IsLoggedIn ¶
func (s *AuthService) IsLoggedIn() bool
IsLoggedIn : Return true when client logged in and false otherwise.
func (*AuthService) Login ¶
func (s *AuthService) Login(user, pwd string) error
Login : Login to MangaDex. https://api.mangadex.org/docs.html#operation/post-auth-login
func (*AuthService) LoginContext ¶
func (s *AuthService) LoginContext(ctx context.Context, user, pwd string) error
LoginContext : Login with custom context.
func (*AuthService) Logout ¶
func (s *AuthService) Logout() error
Logout : Logout of MangaDex and invalidates all tokens. https://api.mangadex.org/docs.html#operation/post-auth-logout
func (*AuthService) LogoutContext ¶
func (s *AuthService) LogoutContext(ctx context.Context) error
LogoutContext : Logout with custom context.
func (*AuthService) RefreshSessionToken ¶
func (s *AuthService) RefreshSessionToken() error
RefreshSessionToken : Refresh session token using refresh token. https://api.mangadex.org/docs.html#operation/post-auth-refresh
func (*AuthService) RefreshSessionTokenContext ¶
func (s *AuthService) RefreshSessionTokenContext(ctx context.Context) error
RefreshSessionTokenContext : refreshToken with custom context.
func (*AuthService) SetRefreshToken ¶
func (s *AuthService) SetRefreshToken(refreshToken string)
SetRefreshToken : Set the refresh token for the client.
type AuthorAttributes ¶
type AuthorAttributes struct { Name string `json:"name"` ImageURL string `json:"imageUrl"` Biography LocalisedStrings `json:"biography"` Version int `json:"version"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` }
AuthorAttributes : Attributes for an Author.
type Chapter ¶
type Chapter struct { ID string `json:"id"` Type string `json:"type"` Attributes ChapterAttributes `json:"attributes"` Relationships []Relationship `json:"relationships"` }
Chapter : Struct containing information on a manga.
func (*Chapter) GetChapterNum ¶
GetChapterNum : Get the chapter's chapter number.
type ChapterAttributes ¶
type ChapterAttributes struct { Title string `json:"title"` Volume *string `json:"volume"` Chapter *string `json:"chapter"` TranslatedLanguage string `json:"translatedLanguage"` Uploader string `json:"uploader"` ExternalURL *string `json:"externalUrl"` Version int `json:"version"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` PublishAt string `json:"publishAt"` }
ChapterAttributes : Attributes for a Chapter.
type ChapterList ¶
type ChapterList struct { Result string `json:"result"` Response string `json:"response"` Data []Chapter `json:"data"` Limit int `json:"limit"` Offset int `json:"offset"` Total int `json:"total"` }
ChapterList : A response for getting a list of chapters.
func (*ChapterList) GetResult ¶
func (cl *ChapterList) GetResult() string
type ChapterReadMarkers ¶
ChapterReadMarkers : A response for getting a list of read chapters.
func (*ChapterReadMarkers) GetResult ¶
func (rmr *ChapterReadMarkers) GetResult() string
type ChapterService ¶
type ChapterService service
ChapterService : Provides Chapter services provided by the API.
func (*ChapterService) GetMangaChapters ¶
func (s *ChapterService) GetMangaChapters(id string, params url.Values) (*ChapterList, error)
GetMangaChapters : Get a list of chapters for a manga. https://api.mangadex.org/docs.html#operation/get-manga-id-feed
func (*ChapterService) GetMangaChaptersContext ¶
func (s *ChapterService) GetMangaChaptersContext(ctx context.Context, id string, params url.Values) (*ChapterList, error)
GetMangaChaptersContext : GetMangaChapters with custom context.
func (*ChapterService) GetReadMangaChapters ¶
func (s *ChapterService) GetReadMangaChapters(id string) (*ChapterReadMarkers, error)
GetReadMangaChapters : Get list of Chapter IDs that are marked as read for a specified manga ID. https://api.mangadex.org/docs.html#operation/get-manga-chapter-readmarkers
func (*ChapterService) GetReadMangaChaptersContext ¶
func (s *ChapterService) GetReadMangaChaptersContext(ctx context.Context, id string) (*ChapterReadMarkers, error)
GetReadMangaChaptersContext : GetReadMangaChapters with custom context.
func (*ChapterService) SetReadUnreadMangaChapters ¶
func (s *ChapterService) SetReadUnreadMangaChapters(id string, read, unRead []string) (*Response, error)
SetReadUnreadMangaChapters : Set read/unread manga chapters.
func (*ChapterService) SetReadUnreadMangaChaptersContext ¶
func (s *ChapterService) SetReadUnreadMangaChaptersContext(ctx context.Context, id string, read, unRead []string) (*Response, error)
SetReadUnreadMangaChaptersContext : SetReadUnreadMangaChapters with custom context.
type ChaptersData ¶
type ChaptersData struct { Hash string `json:"hash"` Data []string `json:"data"` DataSaver []string `json:"dataSaver"` }
ChaptersData : Struct containing data for the chapter's pages.
type DexClient ¶
type DexClient struct { // Services for MangaDex API Auth *AuthService Manga *MangaService Chapter *ChapterService User *UserService AtHome *AtHomeService // contains filtered or unexported fields }
DexClient : The MangaDex client.
func NewDexClient ¶
func NewDexClient() *DexClient
NewDexClient : New anonymous client. To login as an authenticated user, use DexClient.Login.
func (*DexClient) Request ¶
func (c *DexClient) Request(ctx context.Context, method, url string, body io.Reader) (*http.Response, error)
Request : Sends a request to the MangaDex API.
func (*DexClient) RequestAndDecode ¶
func (c *DexClient) RequestAndDecode(ctx context.Context, method, url string, body io.Reader, rt ResponseType) error
RequestAndDecode : Convenience wrapper to also decode response to required data type
type Error ¶
type Error struct { ID string `json:"id"` Status int `json:"status"` Title string `json:"title"` Detail string `json:"detail"` }
Error : Struct containing details of an error.
type ErrorResponse ¶
ErrorResponse : Typical response for errored requests.
func (*ErrorResponse) GetErrors ¶
func (er *ErrorResponse) GetErrors() string
GetErrors : Get the errors for this particular request.
func (*ErrorResponse) GetResult ¶
func (er *ErrorResponse) GetResult() string
type LocalisedStrings ¶
LocalisedStrings : A struct wrapping around a map containing each localised string.
func (*LocalisedStrings) GetLocalString ¶
func (l *LocalisedStrings) GetLocalString(langCode string) string
GetLocalString : Get the localised string for a particular language code. If the required string is not found, it will return the first entry, or an empty string otherwise.
func (*LocalisedStrings) UnmarshalJSON ¶
func (l *LocalisedStrings) UnmarshalJSON(data []byte) error
type MDHomeClient ¶
type MDHomeClient struct { Pages []string // contains filtered or unexported fields }
MDHomeClient : Client for interfacing with MangaDex@Home.
func (*MDHomeClient) GetChapterPage ¶
func (c *MDHomeClient) GetChapterPage(filename string) ([]byte, error)
GetChapterPage : Return page data for a chapter with the filename of that page.
func (*MDHomeClient) GetChapterPageWithContext ¶
func (c *MDHomeClient) GetChapterPageWithContext(ctx context.Context, filename string) ([]byte, error)
GetChapterPageWithContext : GetChapterPage with custom context.
type MDHomeServerResponse ¶
type MDHomeServerResponse struct { Result string `json:"result"` BaseURL string `json:"baseUrl"` Chapter ChaptersData `json:"chapter"` }
MDHomeServerResponse : A response for getting a server URL to get chapters.
func (*MDHomeServerResponse) GetResult ¶
func (r *MDHomeServerResponse) GetResult() string
type Manga ¶
type Manga struct { ID string `json:"id"` Type string `json:"type"` Attributes MangaAttributes `json:"attributes"` Relationships []Relationship `json:"relationships"` }
Manga : Struct containing information on a Manga.
func (*Manga) GetDescription ¶
GetDescription : Get description of the Manga.
type MangaAttributes ¶
type MangaAttributes struct { Title LocalisedStrings `json:"title"` AltTitles LocalisedStrings `json:"altTitles"` Description LocalisedStrings `json:"description"` IsLocked bool `json:"isLocked"` Links LocalisedStrings `json:"links"` OriginalLanguage string `json:"originalLanguage"` LastVolume *string `json:"lastVolume"` LastChapter *string `json:"lastChapter"` PublicationDemographic *string `json:"publicationDemographic"` Status *string `json:"status"` Year *int `json:"year"` ContentRating *string `json:"contentRating"` Tags []Tag `json:"tags"` State string `json:"state"` Version int `json:"version"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` }
MangaAttributes : Attributes for a Manga.
type MangaList ¶
type MangaList struct { Result string `json:"result"` Response string `json:"response"` Data []Manga `json:"data"` Limit int `json:"limit"` Offset int `json:"offset"` Total int `json:"total"` }
MangaList : A response for getting a list of manga.
type MangaService ¶
type MangaService service
MangaService : Provides Manga services provided by the API.
func (*MangaService) CheckIfMangaFollowed ¶
func (s *MangaService) CheckIfMangaFollowed(id string) (bool, error)
CheckIfMangaFollowed : Check if a user follows a manga.
func (*MangaService) CheckIfMangaFollowedContext ¶
CheckIfMangaFollowedContext : CheckIfMangaFollowed with custom context.
func (*MangaService) GetMangaList ¶
func (s *MangaService) GetMangaList(params url.Values) (*MangaList, error)
GetMangaList : Get a list of Manga. https://api.mangadex.org/docs.html#operation/get-search-manga
func (*MangaService) GetMangaListContext ¶
func (s *MangaService) GetMangaListContext(ctx context.Context, params url.Values) (*MangaList, error)
GetMangaListContext : GetMangaList with custom context.
func (*MangaService) ToggleMangaFollowStatus ¶
func (s *MangaService) ToggleMangaFollowStatus(id string, toFollow bool) (*Response, error)
ToggleMangaFollowStatus :Toggle follow status for a manga.
func (*MangaService) ToggleMangaFollowStatusContext ¶
func (s *MangaService) ToggleMangaFollowStatusContext(ctx context.Context, id string, toFollow bool) (*Response, error)
ToggleMangaFollowStatusContext ToggleMangaFollowStatus with custom context.
type Relationship ¶
type Relationship struct { ID string `json:"id"` Type string `json:"type"` Attributes interface{} `json:"attributes"` }
Relationship : Struct containing relationships, with optional attributes for the relation.
func (*Relationship) UnmarshalJSON ¶
func (a *Relationship) UnmarshalJSON(data []byte) error
type Response ¶
type Response struct {
Result string `json:"result"`
}
Response : Plain response struct containing only Result field.
type ResponseType ¶
type ResponseType interface {
GetResult() string
}
ResponseType : Interface for API responses.
type ScanlationGroupAttributes ¶
type ScanlationGroupAttributes struct { Name string `json:"name"` AltNames LocalisedStrings `json:"altNames"` Website *string `json:"website"` IRCServer *string `json:"ircServer"` Discord *string `json:"discord"` ContactEmail *string `json:"contactEmail"` Description *string `json:"description"` Twitter *string `json:"twitter"` FocusedLanguage []string `json:"focusedLanguage"` Locked bool `json:"locked"` Official bool `json:"official"` Inactive bool `json:"inactive"` PublishDelay string `json:"publishDelay"` Version int `json:"version"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` }
ScanlationGroupAttributes : Attributes for a scanlation group
type Tag ¶
type Tag struct { ID string `json:"id"` Type string `json:"type"` Attributes TagAttributes `json:"attributes"` Relationships []Relationship `json:"relationships"` }
Tag : Struct containing information on a tag.
type TagAttributes ¶
type TagAttributes struct { Name LocalisedStrings `json:"name"` Description LocalisedStrings `json:"description"` Group string `json:"group"` Version int `json:"version"` }
TagAttributes : Attributes for a Tag.
type User ¶
type User struct { ID string `json:"id"` Type string `json:"type"` Attributes UserAttributes `json:"attributes"` Relationships []Relationship `json:"relationships"` }
User : Info on a MangaDex user.
type UserAttributes ¶
type UserAttributes struct { Username string `json:"username"` Roles []string `json:"roles"` Version int `json:"version"` }
UserAttributes : Attributes of a User.
type UserResponse ¶
type UserResponse struct { Result string `json:"result"` Response string `json:"response"` Data User `json:"data"` }
UserResponse : Typical User response.
func (*UserResponse) GetResult ¶
func (ur *UserResponse) GetResult() string
type UserService ¶
type UserService service
UserService : Provides User services provided by the API.
func (*UserService) GetLoggedUser ¶
func (s *UserService) GetLoggedUser() (*UserResponse, error)
GetLoggedUser : Return logged UserResponse. https://api.mangadex.org/docs.html#operation/get-user-follows-group
func (*UserService) GetLoggedUserContext ¶
func (s *UserService) GetLoggedUserContext(ctx context.Context) (*UserResponse, error)
GetLoggedUserContext : GetLoggedUser with custom context.
func (*UserService) GetUserFollowedMangaList ¶
func (s *UserService) GetUserFollowedMangaList(limit, offset int, includes []string) (*MangaList, error)
GetUserFollowedMangaList : Return list of followed Manga. https://api.mangadex.org/docs.html#operation/get-user-follows-manga
func (*UserService) GetUserFollowedMangaListContext ¶
func (s *UserService) GetUserFollowedMangaListContext(ctx context.Context, limit, offset int, includes []string) (*MangaList, error)
GetUserFollowedMangaListContext : GetUserFollowedMangaListPath with custom context.