Get Your API Credentials

If you haven't already done so, you will need to sign up.

Sign up to our free plan here: developer.aylien.com/signup.

The Free plan allows you to make 1,000 calls/day for free. For further information on paid plans please visit our plans page.

Getting Started with AYLIEN Text Analysis API Using Go

Requirements

Getting the SDK

The easiest way to get the Go SDK is to use go get:

$ go get github.com/AYLIEN/aylien_textapi_go

Using the SDK

The following example demonstrates how to calculate the sentiment of a simple sentence, and determine the language it's written in.

package main

import (
    "fmt"
    textapi "github.com/AYLIEN/aylien_textapi_go"
)

func main() {
    auth := textapi.Auth{"YourApplicationId", "YourApplicationKey"}
    client, err := textapi.NewClient(auth, true)
    if err != nil {
        panic(err)
    }
    text := "John is a very good football player!"
    sentimentParams := &textapi.SentimentParams{Text: text}
    sentiment, err := client.Sentiment(sentimentParams)
    if err != nil {
        panic(err)
    }
    fmt.Printf("%v\n", sentiment)
    languageParams := &textapi.LanguageParams{Text: text}
    language, err := client.Language(languageParams)
    if err != nil {
        panic(err)
    }
    fmt.Printf("%v\n", language)
}