News API SDK - Go Go project version

About

This is the Go client for AYLIEN News API.

Installation

To install, simply use go get:

go get github.com/AYLIEN/aylien_newsapi_go

Getting Started

Please follow the installation instruction and execute the following code:

package main

// Import the library
import (
	"fmt"
	newsapi "github.com/AYLIEN/aylien_newsapi_go"
)

func main() {
	api := newsapi.NewDefaultApi()

	// Configure API key authorization: app_id
	api.Configuration.APIKeyPrefix["X-AYLIEN-NewsAPI-Application-ID"] = "YOUR_APP_ID"

	// Configure API key authorization: app_key
	api.Configuration.APIKeyPrefix["X-AYLIEN-NewsAPI-Application-Key"] = "YOUR_APP_KEY"

	storiesParams := &newsapi.StoriesParams{
		Title:            "trump",
		Language:         []string{"en"},
		NotLanguage:      []string{"it", "es"},
		PublishedAtStart: "NOW-7DAYS",
		PublishedAtEnd:   "NOW",
		EntitiesBodyLinksDbpedia: []string{
			"http://dbpedia.org/resource/Donald_Trump",
			"http://dbpedia.org/resource/Hillary_Rodham_Clinton",
		},
		SortBy: "social_shares_count.facebook"}

	storiesResponse, res, err := api.ListStories(storiesParams)
	if err != nil {
		panic(err)
	}
	_ = res

	for _, story := range storiesResponse.Stories {
		fmt.Println(story.Title, " / ", story.Source.Name)
	}
}