googlekg

package module
v0.0.0-...-f111cc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 4 Imported by: 0

README

googlekg

Google Knowledge Graph Search API bindings.

This package provides the API bindings for google knowledge graph search api.

Detailed API reference: https://developers.google.com/knowledge-graph/reference/rest/v1

Install

go get -u https://github.com/Navid2zp/googlekg

Example:

req, err := googlekg.Make("YOUR_API_KEY")
if err != nil {
    fmt.Println(err)
}
// Set a query string
req.SetQuery("github")

res, err := req.Do()
if err != nil {
    fmt.Println(err)
}

fmt.Println(res)

// Response will be a KG struct type when response status code is 200.

Methods:

// To set "limit" parameter
req.SetLimit(10)

// To set "query" parameter
req.Query("github")

// To set "indent" parameter
req.SetIndent(true)

// To set "prefix" parameter
req.SetPreFix(true)

// To set "ids" parameters
req.SetIDs([]string{"/m/0dl567"})

// To set "languages" parameters
req.SetLanguages([]string{"en", "fa"})

// To set "types" parameters
req.SetTypes([]string{"Person", "Thing"})

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KG

type KG struct {
	Context         KGContext `json:"@context"`
	Type            string    `json:"@type"`
	ItemListElement []KGItem  `json:"itemListElement"`
}

type KGContext

type KGContext struct {
	Vocab               string `json:"@vocab"`
	Goog                string `json:"goog"`
	ResultScore         string `json:"resultScore"`
	DetailedDescription string `json:"detailedDescription"`
	EntitySearchResult  string `json:"EntitySearchResult"`
	KG                  string `json:"kg"`
}

type KGDetailedDescription

type KGDetailedDescription struct {
	ArticleBody string `json:"articleBody"`
	URL         string `json:"url"`
	License     string `json:"license"`
}

type KGImage

type KGImage struct {
	ContentUrl string `json:"contentUrl"`
	URL        string `json:"url"`
	License    string `json:"license"`
}

type KGItem

type KGItem struct {
	Type        string       `json:"@type"`
	Result      KGItemResult `json:"result"`
	ResultScore float64      `json:"resultScore"`
}

type KGItemResult

type KGItemResult struct {
	ID                  string                `json:"@id"`
	Name                string                `json:"name"`
	Type                []string              `json:"@type"`
	Description         string                `json:"description"`
	Image               KGImage               `json:"image"`
	DetailedDescription KGDetailedDescription `json:"detailedDescription"`
	URL                 string                `json:"url"`
}

type KGRequest

type KGRequest struct {
	URL string
}

func Make

func Make(apiKey string) (*KGRequest, error)

func (*KGRequest) Do

func (r *KGRequest) Do() (*KG, error)

func (*KGRequest) Query

func (r *KGRequest) Query(query string)

func (*KGRequest) SetIDs

func (r *KGRequest) SetIDs(ids []string)

func (*KGRequest) SetIndent

func (r *KGRequest) SetIndent(indent bool)

func (*KGRequest) SetLanguages

func (r *KGRequest) SetLanguages(languages []string)

func (*KGRequest) SetLimit

func (r *KGRequest) SetLimit(limit int)

func (*KGRequest) SetPreFix

func (r *KGRequest) SetPreFix(prefix bool)

func (*KGRequest) SetTypes

func (r *KGRequest) SetTypes(types []string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL