-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
69 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,42 @@ | ||
# Depricated! (needs updating) | ||
# Book/EditionAPI | ||
Here you can find all the information on how to get Books and what methods the `Book` struct has. | ||
|
||
### EditionAPI Examples | ||
In these examples you will find the most useful methods/function, for more low level on Book structs you can look at the documentation. | ||
|
||
```go | ||
book := gol.GetEdition("OL4554174M") // Get the edition using the openlibrary ID | ||
book, err := gol.GetEdition("OL4554174M") // Get the edition using the openlibrary ID | ||
// Output: | ||
// gol.Book{ | ||
// Publishers: []string{"Oxford University Press"}, | ||
// ... | ||
// Key: "/books/OL4554174M", | ||
// Authors: []gol.Author{{"/authors/OL236174A"}}, | ||
// ... | ||
// Subjects: []string{"Genetics.", "Evolution (Biology)"}, | ||
// ... | ||
// Title: "The selfish gene", | ||
// ... | ||
// NumberOfPages: 224, | ||
// Languages: []gol.Languages{{"/languages/eng"}}, | ||
// ... | ||
// Isbn10: []string{"0195200004"}, | ||
// ... | ||
// OclcNumbers: []string{"3167790"}, | ||
// Works: []gol.Works{{"/works/OL1966513W"}}, | ||
// ... | ||
// Created: gol.Time{Type: "/type/datetime", Value: "2008-04-01T03:28:50.625462"}, | ||
// LastModified: gol.Time{Type: "/type/datetime", Value: "2021-03-03T05:21:06.382367"}, | ||
// } | ||
// Book, error | ||
|
||
book := gol.GetEditionISBN("978-3-16-148410-0") // Get the edition from the ISBN key | ||
book, err := gol.GetEditionISBN("978-3-16-148410-0") // Get the edition from the ISBN key | ||
// Output: | ||
// gol.Book{ | ||
// ... | ||
// } | ||
// Book, error | ||
|
||
// To load "all" information from the JSON data in the struct | ||
book.Load() | ||
|
||
// Returns all the information of the book's authors | ||
authors := book.Authors() // Alternatively you can use Authors(book) | ||
|
||
// Get the keys/ids of the book's author | ||
keyauthors, err := book.KeyAuthors() | ||
|
||
// Get the Authors of the book | ||
authors, err := book.Authors() // Alternatively you can use Authors(book) | ||
// Output: | ||
// []Author | ||
// []Author, error | ||
|
||
cover := book.Cover("S") // Returns the URL of the book's cover (size Small) | ||
// To get the cover keys/ids of the book | ||
keys, err := book.KeyCovers() | ||
// Output: | ||
// []String, error | ||
|
||
// To get the first (index 0) cover of the book | ||
key := book.FirstCoverKey() | ||
// Output: | ||
// string | ||
|
||
cover := book.Cover("S") // Returns the URL of the book's cover (size Small) | ||
// Output: | ||
// url | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,46 @@ | ||
# Depricated! (needs updating) | ||
# WorkAPI | ||
This is the documentation page related to Work pages on Open Library that begin with the URL prefix "/works". | ||
You will find here all the operations you can do on works through the `Work` struct. | ||
|
||
In it's simplest form, `GetWork` will fetch all the data and returns a filled `Work` struct. And from the struct you can make other calls to get Editions, Authors, and Covers etc. | ||
In it's simplest form, `GetWork` will fetch all the data and returns a filled* `Work` struct. And from the struct you can make other calls to get Editions, Authors, and Covers etc. | ||
|
||
\* filling the struct requires using the Load() method; When using `GetWork()`, `Load()` is called. | ||
|
||
### List of methods | ||
| Methods | Args | Returns | | ||
|---|---|--| | ||
| GetWork | WorkId | (w Work, err error) | | ||
| (w *Work) Load | | | | ||
| (w *Work) Key | | string, error | | ||
| (w *Work) Desc | | string, error | | ||
| (w *Work) Subjects | | string, error | | ||
| (w *Work) Title | | string, error | | ||
| (w *Work) KeyAuthors | | []string, error | | ||
| (w *Work) KeyCovers | | []string, error | | ||
|---|---|--| | ||
| (w Work) FirstCoverKey | | string | | ||
| (w Work) Cover | size | URL of cover | | ||
| (w Work) Authors | | []Authors, err | | ||
| (w Work) Editions | | []Book, err | | ||
|
||
### WorkAPI Examples | ||
```go | ||
work := gol.GetWork("OL45583W") | ||
work, err:= gol.GetWork("OL45583W") | ||
// Output: | ||
// gol.Work{ | ||
// Created: gol.Time{Type: "/type/datetime", Value: "2009-10-15T11:23:34.130855"}, | ||
// Subjects: []string{"History and criticism", "Russian literature", "Russian literature, history and criticism"}, | ||
// LatestRevision: 4, | ||
// Key: "/works/OL45583W", | ||
// Title: "An outline of Russian literature", | ||
// Authors: []gol.AuthorAndType{{gol.Type{"/type/author_role"}, gol.Author{"/authors/OL18295A"}}}, | ||
// ... | ||
// } | ||
// Work, error | ||
|
||
// To get fields | ||
title, err := work.Title() | ||
|
||
cover := work.Cover("L") // Get a large cover of the work | ||
// Output: | ||
// http://covers.openlibrary.org/b/id/5917705-L.jpg | ||
|
||
authors, err := work.Authors() // Get the list of authors that contributed to the work. | ||
// Output: | ||
// []Authors | ||
// []Authors, error | ||
|
||
editions, err := work.Editions() // Get the list of editions liked to the work. | ||
// Output: | ||
// []Book | ||
// []Book, error | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters