Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
api
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

AYLIEN News API - Go SDK

The AYLIEN News API is the most powerful way of sourcing, searching and syndicating analyzed and enriched news content. It is accessed by sending HTTP requests to our server, which returns information to your client.

Sign up at https://newsapi.aylien.com/.

For more documentation see https://newsapi.aylien.com/docs/.

Installation

Install directly using go get:

go get github.com/AYLIEN/aylien_newsapi_go

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
go get github.com/antihax/optional

Put the package under your project folder and add the following in import:

import "./newsapi"

Getting Started

package main

// Import the library
import (
	"context"
	"fmt"
	newsapi "github.com/AYLIEN/aylien_newsapi_go/v4"
	"os"

	"github.com/antihax/optional"
)

func main() {
	cfg := newsapi.NewConfiguration()
	cfg.DefaultHeader["X-AYLIEN-NewsAPI-Application-ID"] = os.Getenv("NEWSAPI_APP_ID")

	// Configure API key authorization: app_key
	cfg.DefaultHeader["X-AYLIEN-NewsAPI-Application-Key"] = os.Getenv("NEWSAPI_APP_KEY")

	client := newsapi.NewAPIClient(cfg)
	api := client.DefaultApi

	storiesParams := &newsapi.ListStoriesOpts{
		Title:            optional.NewString("trump"),
		NotLanguage:      optional.NewInterface([]string{"en"}),
		PublishedAtStart: optional.NewString("NOW-7DAYS"),
		PublishedAtEnd:   optional.NewString("NOW"),
		EntitiesBodyLinksDbpedia: optional.NewInterface([]string{
			"http://dbpedia.org/resource/Donald_Trump",
		}),
	}

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

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

Documentation for API Endpoints

All URIs are relative to https://api.aylien.com/news

Class Method HTTP request Description
DefaultApi ListAutocompletes Get /autocompletes List autocompletes
DefaultApi ListClusters Get /clusters List Clusters
DefaultApi ListCoverages Get /coverages List coverages
DefaultApi ListHistograms Get /histograms List histograms
DefaultApi ListRelatedStories Get /related_stories List related stories
DefaultApi ListStories Get /stories List Stories
DefaultApi ListTimeSeries Get /time_series List time series
DefaultApi ListTrends Get /trends List trends

Documentation For Models

You can’t perform that action at this time.