kgsearch
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package kgsearch provides access to the Knowledge Graph Search API.
For product documentation, see:https://developers.google.com/knowledge-graph/
Library status¶
These client libraries are officially supported by Google. However, thislibrary is considered complete and is in maintenance mode. This meansthat we will address critical bugs and security issues but will not addany new features.
When possible, we recommend using our newer[Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)that are still actively being worked and iterated on.
Creating a client¶
Usage example:
import "google.golang.org/api/kgsearch/v1"...ctx := context.Background()kgsearchService, err := kgsearch.NewService(ctx)
In this example, Google Application Default Credentials are used forauthentication. For information on how to create and obtain ApplicationDefault Credentials, seehttps://developers.google.com/identity/protocols/application-default-credentials.
Other authentication options¶
To use an API key for authentication (note: some APIs do not support APIkeys), usegoogle.golang.org/api/option.WithAPIKey:
kgsearchService, err := kgsearch.NewService(ctx, option.WithAPIKey("AIza..."))To use an OAuth token (e.g., a user token obtained via a three-legged OAuthflow, usegoogle.golang.org/api/option.WithTokenSource:
config := &oauth2.Config{...}// ...token, err := config.Exchange(ctx, ...)kgsearchService, err := kgsearch.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))Seegoogle.golang.org/api/option.ClientOption for details on options.
Index¶
- type EntitiesSearchCall
- func (c *EntitiesSearchCall) Context(ctx context.Context) *EntitiesSearchCall
- func (c *EntitiesSearchCall) Do(opts ...googleapi.CallOption) (*SearchResponse, error)
- func (c *EntitiesSearchCall) Fields(s ...googleapi.Field) *EntitiesSearchCall
- func (c *EntitiesSearchCall) Header() http.Header
- func (c *EntitiesSearchCall) Ids(ids ...string) *EntitiesSearchCall
- func (c *EntitiesSearchCall) IfNoneMatch(entityTag string) *EntitiesSearchCall
- func (c *EntitiesSearchCall) Indent(indent bool) *EntitiesSearchCall
- func (c *EntitiesSearchCall) Languages(languages ...string) *EntitiesSearchCall
- func (c *EntitiesSearchCall) Limit(limit int64) *EntitiesSearchCall
- func (c *EntitiesSearchCall) Prefix(prefix bool) *EntitiesSearchCall
- func (c *EntitiesSearchCall) Query(query string) *EntitiesSearchCall
- func (c *EntitiesSearchCall) Types(types ...string) *EntitiesSearchCall
- type EntitiesService
- type SearchResponse
- type Service
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeEntitiesSearchCall¶
type EntitiesSearchCall struct {// contains filtered or unexported fields}func (*EntitiesSearchCall)Context¶
func (c *EntitiesSearchCall) Context(ctxcontext.Context) *EntitiesSearchCall
Context sets the context to be used in this call's Do method.
func (*EntitiesSearchCall)Do¶
func (c *EntitiesSearchCall) Do(opts ...googleapi.CallOption) (*SearchResponse,error)
Do executes the "kgsearch.entities.search" call.Any non-2xx status code is an error. Response headers are in either*SearchResponse.ServerResponse.Header or (if a response was returned at all)in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to checkwhether the returned error was because http.StatusNotModified was returned.
func (*EntitiesSearchCall)Fields¶
func (c *EntitiesSearchCall) Fields(s ...googleapi.Field) *EntitiesSearchCall
Fields allows partial responses to be retrieved. Seehttps://developers.google.com/gdata/docs/2.0/basics#PartialResponse for moredetails.
func (*EntitiesSearchCall)Header¶
func (c *EntitiesSearchCall) Header()http.Header
Header returns a http.Header that can be modified by the caller to addheaders to the request.
func (*EntitiesSearchCall)Ids¶
func (c *EntitiesSearchCall) Ids(ids ...string) *EntitiesSearchCall
Ids sets the optional parameter "ids": The list of entity id to be used forsearch instead of query string. To specify multiple ids in the HTTP request,repeat the parameter in the URL as in ...?ids=A&ids=B
func (*EntitiesSearchCall)IfNoneMatch¶
func (c *EntitiesSearchCall) IfNoneMatch(entityTagstring) *EntitiesSearchCall
IfNoneMatch sets an optional parameter which makes the operation fail if theobject's ETag matches the given value. This is useful for getting updatesonly after the object has changed since the last request.
func (*EntitiesSearchCall)Indent¶
func (c *EntitiesSearchCall) Indent(indentbool) *EntitiesSearchCall
Indent sets the optional parameter "indent": Enables indenting of jsonresults.
func (*EntitiesSearchCall)Languages¶
func (c *EntitiesSearchCall) Languages(languages ...string) *EntitiesSearchCall
Languages sets the optional parameter "languages": The list of languagecodes (defined in ISO 693) to run the query with, e.g. 'en'.
func (*EntitiesSearchCall)Limit¶
func (c *EntitiesSearchCall) Limit(limitint64) *EntitiesSearchCall
Limit sets the optional parameter "limit": Limits the number of entities tobe returned.
func (*EntitiesSearchCall)Prefix¶
func (c *EntitiesSearchCall) Prefix(prefixbool) *EntitiesSearchCall
Prefix sets the optional parameter "prefix": Enables prefix match againstnames and aliases of entities
func (*EntitiesSearchCall)Query¶
func (c *EntitiesSearchCall) Query(querystring) *EntitiesSearchCall
Query sets the optional parameter "query": The literal query string forsearch.
func (*EntitiesSearchCall)Types¶
func (c *EntitiesSearchCall) Types(types ...string) *EntitiesSearchCall
Types sets the optional parameter "types": Restricts returned entities withthese types, e.g. Person (as defined inhttp://schema.org/Person). Ifmultiple types are specified, returned entities will contain one or more ofthese types.
typeEntitiesService¶
type EntitiesService struct {// contains filtered or unexported fields}funcNewEntitiesService¶
func NewEntitiesService(s *Service) *EntitiesService
func (*EntitiesService)Search¶
func (r *EntitiesService) Search() *EntitiesSearchCall
Search: Searches Knowledge Graph for entities that match the constraints. Alist of matched entities will be returned in response, which will be inJSON-LD format and compatible withhttp://schema.org
typeSearchResponse¶
type SearchResponse struct {// ItemListElement: The item list of search results.ItemListElement []interface{} `json:"itemListElement,omitempty"`// ServerResponse contains the HTTP response code and headers from the server.googleapi.ServerResponse `json:"-"`// ForceSendFields is a list of field names (e.g. "ItemListElement") to// unconditionally include in API requests. By default, fields with empty or// default values are omitted from API requests. See//https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more// details.ForceSendFields []string `json:"-"`// NullFields is a list of field names (e.g. "ItemListElement") to include in// API requests with the JSON null value. By default, fields with empty values// are omitted from API requests. See//https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.NullFields []string `json:"-"`}SearchResponse: Response message includes the context and a list of matchingresults which contain the detail of associated entities.
func (SearchResponse)MarshalJSON¶
func (sSearchResponse) MarshalJSON() ([]byte,error)
typeService¶
type Service struct {BasePathstring// API endpoint base URLUserAgentstring// optional additional User-Agent fragmentEntities *EntitiesService// contains filtered or unexported fields} funcNewdeprecated
New creates a new Service. It uses the provided http.Client for requests.
Deprecated: please use NewService instead.To provide a custom HTTP client, use option.WithHTTPClient.If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
funcNewService¶added inv0.3.0
NewService creates a new Service.