Categorygithub.com/goark/aozora-api
modulepackage
0.4.0
Repository: https://github.com/goark/aozora-api.git
Documentation: pkg.go.dev

# README

aozora-api -- APIs for Aozora-bunko RESTful Service by Golang

check vulns lint status GitHub license GitHub release

This package is required Go 1.16 or later.

Migrated repository to github.com/goark/aozora-api

Usage of package

Import Package

import "github.com/goark/aozora-api"

Search for Aozora-bunko Books Data

books, err := aozora.DefaultClient().SearchBooks(
    aozora.WithBookTitle("/天に積む宝/"),
    aozora.WithBookAuthor("富田倫生"),
)

Lookup Aozora-bunko Book Data

book, err := aozora.DefaultClient().LookupBook(59489)

Search for Aozora-bunko Persons Data

persons, err := aozora.DefaultClient().SearchPersons(
    aozora.WithPersonName("富田倫生"),
)

Lookup Aozora-bunko Person Data

person, err := aozora.DefaultClient().LookupPerson(55)

Search for Aozora-bunko Workers Data

workers, err := aozora.DefaultClient().SearchWorkers(
    aozora.WithWorkerName("雪森"),
)

Lookup Aozora-bunko Worker Data

worker, err := aozora.DefaultClient().LookupWorker(845)

Lookup Ranking data of Aozora-bunko

tm, err := time.Parse("2006-01", "2019-01")
ranking, err := aozora.DefaultClient().Ranking(tm)

Entities for Aozora-bunko

Book type

//Author is entity class of author and translator info.
type Author struct {
    PersonID  int    `json:"person_id"`
    LastName  string `json:"last_name"`
    FirstName string `json:"first_name"`
}

//Book is entity class of book info.
type Book struct {
    BookID                      int      `json:"book_id"`
    Title                       string   `json:"title"`
    TitleYomi                   string   `json:"title_yomi"`
    TitleSort                   string   `json:"title_sort"`
    Subtitle                    string   `json:"subtitle"`
    SubtitleYomi                string   `json:"subtitle_yomi"`
    OriginalTitle               string   `json:"original_title"`
    FirstAppearance             string   `json:"first_appearance"`
    NDCCode                     string   `json:"ndc_code"`
    FontKanaType                string   `json:"font_kana_type"`
    Copyright                   bool     `json:"copyright"`
    ReleaseDate                 Date     `json:"release_date"`
    LastModified                Date     `json:"last_modified"`
    CardURL                     string   `json:"card_url"`
    BaseBook1                   string   `json:"base_book_1"`
    BaseBookPublisher1          string   `json:"base_book_1_publisher"`
    BaseBookFirstEdition1       string   `json:"base_book_1_1st_edition"`
    BaseBookEditionInput1       string   `json:"base_book_1_edition_input"`
    BaseBookEditionProofing1    string   `json:"base_book_1_edition_proofing"`
    BaseBookParent1             string   `json:"base_book_1_parent"`
    BaseBookParentPublisher1    string   `json:"base_book_1_parent_publisher"`
    BaseBookParentFirstEdition1 string   `json:"base_book_1_parent_1st_edition"`
    BaseBook2                   string   `json:"base_book_2"`
    BaseBookPublisher2          string   `json:"base_book_2_publisher"`
    BaseBookFirstEdition2       string   `json:"base_book_2_1st_edition"`
    BaseBookEditionInput2       string   `json:"base_book_2_edition_input"`
    BaseBookEditionProofing2    string   `json:"base_book_2_edition_proofing"`
    BaseBookParent2             string   `json:"base_book_2_parent"`
    BaseBookParentPublisher2    string   `json:"base_book_2_parent_publisher"`
    BaseBookParentFirstEdition2 string   `json:"base_book_2_parent_1st_edition"`
    Input                       string   `json:"input"`
    Proofing                    string   `json:"proofing"`
    TextURL                     string   `json:"text_url"`
    TextLastModified            Date     `json:"text_last_modified"`
    TextEncoding                string   `json:"text_encoding"`
    TextCharset                 string   `json:"text_charset"`
    TextUpdated                 int      `json:"text_updated"`
    HTMLURL                     string   `json:"html_url"`
    HTMLLastModified            Date     `json:"html_last_modified"`
    HTMLEncoding                string   `json:"html_encoding"`
    HTMLCharset                 string   `json:"html_charset"`
    HTMLUpdated                 int      `json:"html_updated"`
    Translators                 []Author `json:"translators"`
    Authors                     []Author `json:"authors"`
}

Person type

//Person is entity class of person info.
type Person struct {
    PersonID        int    `json:"person_id"`
    LastName        string `json:"last_name"`
    FirstName       string `json:"first_name"`
    LastNameYomi    string `json:"last_name_yomi"`
    FirstNameYomi   string `json:"first_name_yomi"`
    LastNameSort    string `json:"last_name_sort"`
    FirstNameSort   string `json:"first_name_sort"`
    LastNameRoman   string `json:"last_name_roman"`
    FirstNameRoman  string `json:"first_name_roman"`
    DateOfBirth     Date   `json:"date_of_birth"`
    DateOfDeath     Date   `json:"date_of_death"`
    AuthorCopyright bool   `json:"author_copyright"`
}

Worker type

//Worker is entity class of worker info.
type Worker struct {
    WorkerID int    `json:"id"`
    Name     string `json:"name"`
}

Ranking type

//Ranking is entity class of ranking info.
type Ranking []struct {
    BookID  int      `json:"book_id"`
    Access  int      `json:"access"`
    Title   string   `json:"title"`
    Authors []string `json:"authors"`
}

Command Line Interface (Sample Code)

Install and Build

$ go get github.com/goark/aozora-api/cli/aozora-bunko

Search for Aozora-bunko Books Data

$ aozora-bunko search books -t "/天に積む宝/" -a "富田倫生"

Lookup Aozora-bunko Book Data

$ aozora-bunko lookup book 59489

Search for Aozora-bunko Persons Data

$ aozora-bunko search persons -n "富田倫生"

Lookup Aozora-bunko Person Data

$ aozora-bunko lookup person 55

Search for Aozora-bunko Workers Data

$ aozora-bunko search workers -n "雪森"

Lookup Aozora-bunko Worker Data

$ aozora-bunko lookup worker 845

Lookup Ranking data of Aozora-bunko

$ aozora-bunko ranking 2019-01

Reference

# Packages

No description provided by the author

# Functions

DecodeBook returns Book instance from byte buffer.
DecodeBooks returns array of Book instance from byte buffer.
DecodePerson returns Person instance from byte buffer.
DecodePersons returns array of Person instance from byte buffer.
DecodeRanking returns Ranking instance from byte buffer.
DecodeWorker returns Worker instance from byte buffer.
DecodeWorkers returns array of Worker instance from byte buffer.
DefaultClient returns new Client instance with default setting.
EncodeBook returns bytes encoded from Book instance.
EncodeBooks returns bytes encoded from list of Book.
EncodePersons returns bytes encoded from Person instance.
EncodePerson returns bytes encoded from list of Person.
EncodeRanking returns bytes encoded from Worker instance.
EncodeWorkers returns bytes encoded from Worker instance.
EncodeWorker returns bytes encoded from list of Worker.
New returns new Server instance.
NewDate returns Time instance.
WithBookAfter returns function for setting Marketplace.
WithBookAuthor returns function for setting Marketplace.
WithBookFields returns function for setting Marketplace.
WithBookLimit returns function for setting Marketplace.
WithBookSkip returns function for setting Marketplace.
WithBookTitle returns function for setting Marketplace.
WithContext is dummy function.
WithHttpClient returns function for setting http.Client.
WithPersonName returns function for setting Marketplace.
WithScheme returns function for setting scheme.
WithServerName returns function for setting hostname.
WithWorkerName returns function for setting Marketplace.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Author is entity class of author and translator info.
Book is entity class of book info.
Client is http.Client for Aozora API Server.
Time is wrapper class of time.Time.
Person is entity class of person info.
Server is informations of Aozora API.
Worker is entity class of worker info.

# Type aliases

ClientOptFunc is self-referential function for functional options pattern.
Format is enumrate class of content type.
Ranking is entity class of ranking info.
SearchBooksParamsFunc is self-referential function for functional options pattern.
SearchPersonsParamsFunc is self-referential function for functional options pattern.
SearchPersonsParamsFunc is self-referential function for functional options pattern.
ServerOptFunc is self-referential function for functional options pattern.
Target is enumrate class of data type.