Swiftype's Golang API released!

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Write in front

I am a golang programmer, and basically all of my stuff is developed with go. I recently wanted to give my personal site access to the search function, using the Swiftype tool. However, I found that it did not have a Golang API toolkit. On GitHub found a package, but found that a bug can not be used, so he fork the code to make a set.

Source Address: Https://github.com/mnhkahn/swiftype

Installation

go get -v gopkg.in/mnhkahn/swiftype.v1

Document

Documents can be viewed on godoc. Currently only support the search method, because my side also only use this, if the future my side of the different API requirements, will consider the update.

Type Client

    • Func Newclientwithapikey (Api_key string, host string) *client
    • Func Newclientwithusernamepassword (Username string, password string, host string) *client
    • Func (c *client) engine (engine string) ([]byte, error)
    • Func (c *client) Engines () ([]byte, error)
    • Func (c Client) Search (engine string, query string) (Swiftyperesult, error)

Type Swiftyperesult

Example

SWIFTYPE := *swiftype.ClientSWIFTYPE_APIKEY := "YOUR OWN API KEY"SWIFTYPE_HOST := "api.swiftype.com"SWIFTYPE_ENGINE := "YOUR OWN ENGINE"SWIFTYPE := swiftype.NewClientWithApiKey(SWIFTYPE_APIKEY, SWIFTYPE_HOST)data, err := SWIFTYPE.Search(SWIFTYPE_ENGINE, q)if err != nil {    panic(err)}_ = data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.