Working with Locations

About

There are three ways to work with locations in the News API.

Source Location

Description

Source location refers to the location of the source HQ i.e. where the source is based. Source location allows you to filter stories by source location.

Examples

The following example shows how to retrieve stories in English, are about Electrical Cars published by Indian sources, were published between 10 days ago and now and sorted by Reddit social shares count.

var AylienNewsApi = require('aylien-news-api');

var apiInstance = new AylienNewsApi.DefaultApi();

// Configure API key authorization: app_id
var app_id = apiInstance.apiClient.authentications['app_id'];
app_id.apiKey = "YOUR_APP_ID";

// Configure API key authorization: app_key
var app_key = apiInstance.apiClient.authentications['app_key'];
app_key.apiKey = "YOUR_APP_KEY";

var opts = {
  'sortBy': 'social_shares_count.reddit',
  'language': ['en'],
  'publishedAtStart': 'NOW-10DAYS',
  'publishedAtEnd': 'NOW', 
  'categoriesTaxonomy': 'iab-qag',
  'categoriesId': ['IAB2-10'],
  'sourceLocationsCountry': ['IN']
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.listStories(opts, callback);
import aylien_news_api
from aylien_news_api.rest import ApiException

# Configure API key authorization: app_id
aylien_news_api.configuration.api_key['X-AYLIEN-NewsAPI-Application-ID'] = 'YOUR_APP_ID'
# Configure API key authorization: app_key
aylien_news_api.configuration.api_key['X-AYLIEN-NewsAPI-Application-Key'] = 'YOUR_APP_KEY'

# create an instance of the API class
api_instance = aylien_news_api.DefaultApi()

language = ['en']
since = 'NOW-10DAYS'
until = 'NOW'
sort_by = 'social_shares_count.reddit'
categories_taxonomy = 'iab-qag'
categories_id = ['IAB2-10']
source_locations_country = ['IN']

try:
  # List stories
  api_response = api_instance.list_stories(
    language=language,
    published_at_start=since,
    published_at_end=until,
    sort_by=sort_by,
    categories_taxonomy=categories_taxonomy,
    categories_id=categories_id,
    source_locations_country=source_locations_country
  )
  print(api_response)
except ApiException as e:
  print("Exception when calling DefaultApi->list_stories: %s\n" % e)
<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: app_id
Aylien\NewsApi\Configuration::getDefaultConfiguration()->setApiKey('X-AYLIEN-NewsAPI-Application-ID', 'YOUR_APP_ID');

// Configure API key authorization: app_key
Aylien\NewsApi\Configuration::getDefaultConfiguration()->setApiKey('X-AYLIEN-NewsAPI-Application-Key', 'YOUR_APP_KEY');

$api_instance = new Aylien\NewsApi\Api\DefaultApi();

$opts = array(
  'published_at_start' => 'NOW-10DAYS',
  'published_at_end' => 'NOW',
  'language' => ['en'],
  'sort_by' => 'social_shares_count.reddit',
  'categories_taxonomy' => 'iab-qag',
  'categories_id' => ['IAB2-10'],
  'source_locations_country' => ['IN']
);

try {
  $result = $api_instance->listStories($opts);
  print_r($result);
} catch (Exception $e) {
  echo 'Exception when calling DefaultApi->listStories: ', $e->getMessage(), PHP_EOL;
}
?>
package com.aylien.newsapisample;

import com.aylien.newsapi.*;
import com.aylien.newsapi.auth.*;
import com.aylien.newsapi.models.*;
import com.aylien.newsapi.parameters.*;
import com.aylien.newsapi.api.DefaultApi;

import java.util.*;

public class Main {

  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();

    // Configure API key authorization: app_id
    ApiKeyAuth app_id = (ApiKeyAuth) defaultClient.getAuthentication("app_id");
    app_id.setApiKey("YOUR_APP_ID");

    // Configure API key authorization: app_key
    ApiKeyAuth app_key = (ApiKeyAuth) defaultClient.getAuthentication("app_key");
    app_key.setApiKey("YOUR_APP_KEY");

    DefaultApi apiInstance = new DefaultApi();

    List<String> language = Arrays.asList("en");
    String since = "NOW-10DAYS";
    String until = "NOW";
    List<String> sourceLocationsCountry = Arrays.asList("IN");
    String sortBy = "social_shares_count.reddit";
    String categoriesTaxonomy = "iab-qag";
    List<String> categoriesId = Arrays.asList("IAB2-10");

    StoriesParams.Builder storiesBuilder = StoriesParams.newBuilder();

    storiesBuilder.setPublishedAtStart(since);
    storiesBuilder.setPublishedAtEnd(until);
    storiesBuilder.setLanguage(language);
    storiesBuilder.setCategoriesTaxonomy(categoriesTaxonomy);
    storiesBuilder.setCategoriesId(categoriesId);
    storiesBuilder.setSourceLocationsCountry(sourceLocationsCountry);
    storiesBuilder.setSortBy(sortBy);

    try {
    	Stories result = apiInstance.listStories(storiesBuilder.build());
    	System.out.println(result);
    } catch (ApiException e) {
    	System.err.println("Exception when calling DefaultApi#listStories");
    	e.printStackTrace();
    }
  }
}
# Load the gem
require 'aylien_news_api'

# Setup authorization
AylienNewsApi.configure do |config|
  # Configure API key authorization: app_id
  config.api_key['X-AYLIEN-NewsAPI-Application-ID'] = 'YOUR_APP_ID'
  
  # Configure API key authorization: app_key
  config.api_key['X-AYLIEN-NewsAPI-Application-Key'] = 'YOUR_APP_KEY'
end

api_instance = AylienNewsApi::DefaultApi.new

opts = {
  :published_at_start => "NOW-10DAYS",
  :published_at_end => "NOW",
  :language => ['en'],
  :sort_by => 'social_shares_count.reddit',
  :categories_taxonomy => 'iab-qag',
  :categories_id => ['IAB2-10'],
  :source_locations_country => ['IN']
}


begin
  #List stories
  result = api_instance.list_stories(opts)
  puts result
rescue AylienNewsApi::ApiError => e
  puts "Exception when calling DefaultApi->list_stories: #{e}"
end
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"

	language := []string{"en"}
	publishedAtStart := "NOW-10DAYS"
	publishedAtEnd := "NOW"
	categoriesTaxonomy := "iab-qag"
	categoriesId := []string{"IAB2-10"}
	sourceLocationsCountry := []string{"IN"}
	sortBy := "social_shares_count.reddit"

	storiesParams := &newsapi.StoriesParams{
		Language:               language,
		PublishedAtStart:       publishedAtStart,
		PublishedAtEnd:         publishedAtEnd,
		CategoriesTaxonomy:     categoriesTaxonomy,
		CategoriesId:           categoriesId,
		SourceLocationsCountry: sourceLocationsCountry,
		SortBy:                 sortBy}

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

	_ = res

	fmt.Println(storiesResponse)
}
using System;
using Aylien.NewsApi.Api;
using Aylien.NewsApi.Client;
using Aylien.NewsApi.Model;
using System.Collections.Generic;

namespace ConsoleApplicationExample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Configure API key authorization: app_id
            Configuration.Default.ApiKey.Add("X-AYLIEN-NewsAPI-Application-ID", "YOUR_APP_ID");

            // Configure API key authorization: app_key
            Configuration.Default.ApiKey.Add("X-AYLIEN-NewsAPI-Application-Key", "YOUR_APP_KEY");

            var apiInstance = new DefaultApi();

            var language = new List<string> { "en" };
            var publishedAtStart = "NOW-10DAYS";
            var publishedAtEnd = "NOW";
            var categoriesTaxonomy = "iab-qag";
            var categoriesId = new List<string> { "IAB2-10" };
            var sourceLocationsCountry = new List<string> { "IN" };
            var sortBy = "social_shares_count.reddit";

            try
            {
                // List Stories
                Stories result = apiInstance.ListStories(
                    language: language,
                    publishedAtStart: publishedAtStart,
                    publishedAtEnd: publishedAtEnd,
                    categoriesTaxonomy: categoriesTaxonomy,
                    categoriesId: categoriesId,
                    sourceLocationsCountry: sourceLocationsCountry,
                    sortBy: sortBy
                );
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling DefaultApi.ListStories: " + e.Message);
            }
        }
    }
}

Source Scope

Description

Source scope refers to the geographical regions a news source covers. For example, a news source might cover local, national or international news they might also only cover news related to a particular city, state or country. The source scope allows you to filter stories by scope.

Examples

The following example shows how to retrieve stories in English, are about Startup Fundraising published by sources who cover London city news, were published between 30 days ago and now and sorted by published at date time.

var AylienNewsApi = require('aylien-news-api');

var apiInstance = new AylienNewsApi.DefaultApi();

// Configure API key authorization: app_id
var app_id = apiInstance.apiClient.authentications['app_id'];
app_id.apiKey = "YOUR_APP_ID";

// Configure API key authorization: app_key
var app_key = apiInstance.apiClient.authentications['app_key'];
app_key.apiKey = "YOUR_APP_KEY";

var opts = {
  'title': 'startup AND (raise OR raised OR raising OR raises)',
  'sortBy': 'published_at',
  'language': ['en'],
  'publishedAtStart': 'NOW-30DAYS',
  'publishedAtEnd': 'NOW', 
  'categoriesTaxonomy': 'iab-qag',
  'categoriesId': ['IAB3'],
  'sourceScopesCity': ['London']
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.listStories(opts, callback);
import aylien_news_api
from aylien_news_api.rest import ApiException

# Configure API key authorization: app_id
aylien_news_api.configuration.api_key['X-AYLIEN-NewsAPI-Application-ID'] = 'YOUR_APP_ID'
# Configure API key authorization: app_key
aylien_news_api.configuration.api_key['X-AYLIEN-NewsAPI-Application-Key'] = 'YOUR_APP_KEY'

# create an instance of the API class
api_instance = aylien_news_api.DefaultApi()

title = 'startup AND (raise OR raised OR raising OR raises)'
language = ['en']
since = 'NOW-30DAYS'
until = 'NOW'
sort_by = 'published_at'
categories_taxonomy = 'iab-qag'
categories_id = ['IAB3']
source_scopes_city = ['London']

try:
  # List stories
  api_response = api_instance.list_stories(
    title=title,
    language=language,
    published_at_start=since,
    published_at_end=until,
    sort_by=sort_by,
    categories_taxonomy=categories_taxonomy,
    categories_id=categories_id,
    source_scopes_city=source_scopes_city
  )
  print(api_response)
except ApiException as e:
  print("Exception when calling DefaultApi->list_stories: %s\n" % e)
<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: app_id
Aylien\NewsApi\Configuration::getDefaultConfiguration()->setApiKey('X-AYLIEN-NewsAPI-Application-ID', 'YOUR_APP_ID');

// Configure API key authorization: app_key
Aylien\NewsApi\Configuration::getDefaultConfiguration()->setApiKey('X-AYLIEN-NewsAPI-Application-Key', 'YOUR_APP_KEY');

$api_instance = new Aylien\NewsApi\Api\DefaultApi();

$opts = array(
  'title' => 'startup AND (raise OR raised OR raising OR raises)',
  'published_at_start' => 'NOW-30DAYS',
  'published_at_end' => 'NOW',
  'language' => ['en'],
  'sort_by' => 'published_at',
  'categories_taxonomy' => 'iab-qag',
  'categories_id' => ['IAB3'],
  'source_scopes_city' => ['London']
);

try {
  $result = $api_instance->listStories($opts);
  print_r($result);
} catch (Exception $e) {
  echo 'Exception when calling DefaultApi->listStories: ', $e->getMessage(), PHP_EOL;
}
?>
package com.aylien.newsapisample;

import com.aylien.newsapi.*;
import com.aylien.newsapi.auth.*;
import com.aylien.newsapi.models.*;
import com.aylien.newsapi.parameters.*;
import com.aylien.newsapi.api.DefaultApi;

import java.util.*;

public class Main {

  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();

    // Configure API key authorization: app_id
    ApiKeyAuth app_id = (ApiKeyAuth) defaultClient.getAuthentication("app_id");
    app_id.setApiKey("YOUR_APP_ID");

    // Configure API key authorization: app_key
    ApiKeyAuth app_key = (ApiKeyAuth) defaultClient.getAuthentication("app_key");
    app_key.setApiKey("YOUR_APP_KEY");

    DefaultApi apiInstance = new DefaultApi();

    String title = "startup AND (raise OR raised OR raising OR raises)";
    List<String> language = Arrays.asList("en");
    String since = "NOW-30DAYS";
    String until = "NOW";
    List<String> sourceScopesCity = Arrays.asList("London");
    String sortBy = "published_at";
    String categoriesTaxonomy = "iab-qag";
    List<String> categoriesId = Arrays.asList("IAB3");

    StoriesParams.Builder storiesBuilder = StoriesParams.newBuilder();

    storiesBuilder.setTitle(title);
    storiesBuilder.setPublishedAtStart(since);
    storiesBuilder.setPublishedAtEnd(until);
    storiesBuilder.setLanguage(language);
    storiesBuilder.setCategoriesTaxonomy(categoriesTaxonomy);
    storiesBuilder.setCategoriesId(categoriesId);
    storiesBuilder.setSourceScopesCity(sourceScopesCity);
    storiesBuilder.setSortBy(sortBy);

    try {
    	Stories result = apiInstance.listStories(storiesBuilder.build());
    	System.out.println(result);
    } catch (ApiException e) {
    	System.err.println("Exception when calling DefaultApi#listStories");
    	e.printStackTrace();
    }
  }
}
# Load the gem
require 'aylien_news_api'

# Setup authorization
AylienNewsApi.configure do |config|
  # Configure API key authorization: app_id
  config.api_key['X-AYLIEN-NewsAPI-Application-ID'] = 'YOUR_APP_ID'
  
  # Configure API key authorization: app_key
  config.api_key['X-AYLIEN-NewsAPI-Application-Key'] = 'YOUR_APP_KEY'
end

api_instance = AylienNewsApi::DefaultApi.new

opts = {
  :title => "startup AND (raise OR raised OR raising OR raises)",
  :published_at_start => "NOW-30DAYS",
  :published_at_end => "NOW",
  :language => ['en'],
  :sort_by => 'published_at',
  :categories_taxonomy => 'iab-qag',
  :categories_id => ['IAB3'],
  :source_scopes_city => ['London']
}


begin
  #List stories
  result = api_instance.list_stories(opts)
  puts result
rescue AylienNewsApi::ApiError => e
  puts "Exception when calling DefaultApi->list_stories: #{e}"
end
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"

	title := "startup AND (raise OR raised OR raising OR raises)"
	language := []string{"en"}
	publishedAtStart := "NOW-30DAYS"
	publishedAtEnd := "NOW"
	categoriesTaxonomy := "iab-qag"
	categoriesId := []string{"IAB3"}
	sourceScopesCity := []string{"London"}
	sortBy := "published_at"

	storiesParams := &newsapi.StoriesParams{
		Title:              title,
		Language:           language,
		PublishedAtStart:   publishedAtStart,
		PublishedAtEnd:     publishedAtEnd,
		CategoriesTaxonomy: categoriesTaxonomy,
		CategoriesId:       categoriesId,
		SourceScopesCity:   sourceScopesCity,
		SortBy:             sortBy}

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

	_ = res

	fmt.Println(storiesResponse)
}
using System;
using Aylien.NewsApi.Api;
using Aylien.NewsApi.Client;
using Aylien.NewsApi.Model;
using System.Collections.Generic;

namespace ConsoleApplicationExample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Configure API key authorization: app_id
            Configuration.Default.ApiKey.Add("X-AYLIEN-NewsAPI-Application-ID", "YOUR_APP_ID");

            // Configure API key authorization: app_key
            Configuration.Default.ApiKey.Add("X-AYLIEN-NewsAPI-Application-Key", "YOUR_APP_KEY");

            var apiInstance = new DefaultApi();

            var title = "startup AND (raise OR raised OR raising OR raises)";
            var language = new List<string> { "en" };
            var publishedAtStart = "NOW-30DAYS";
            var publishedAtEnd = "NOW";
            var categoriesTaxonomy = "iab-qag";
            var categoriesId = new List<string> { "IAB3" };
            var sourceScopesCity = new List<string> { "London" };
            var sortBy = "published_at";

            try
            {
                // List Stories
                Stories result = apiInstance.ListStories(
                    title: title,
                    language: language,
                    publishedAtStart: publishedAtStart,
                    publishedAtEnd: publishedAtEnd,
                    categoriesTaxonomy: categoriesTaxonomy,
                    categoriesId: categoriesId,
                    sourceScopesCity: sourceScopesCity,
                    sortBy: sortBy
                );
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling DefaultApi.ListStories: " + e.Message);
            }
        }
    }
}

Mentioned Locations

Description

Mentioned Locations is used to identify when a location as a keyword or entity is mentioned in the title or body of a story.

Examples

The following example shows how to retrieve stories in English, are about Electrical Cars with San Francisco mentioned in their body, were published between 30 days ago and now and sorted by published at date time.

var AylienNewsApi = require('aylien-news-api');

var apiInstance = new AylienNewsApi.DefaultApi();

// Configure API key authorization: app_id
var app_id = apiInstance.apiClient.authentications['app_id'];
app_id.apiKey = "YOUR_APP_ID";

// Configure API key authorization: app_key
var app_key = apiInstance.apiClient.authentications['app_key'];
app_key.apiKey = "YOUR_APP_KEY";

var opts = {
  'sortBy': 'published_at',
  'language': ['en'],
  'publishedAtStart': 'NOW-30DAYS',
  'publishedAtEnd': 'NOW', 
  'categoriesTaxonomy': 'iab-qag',
  'categoriesId': ['IAB2-10'],
  'entitiesBodyLinksDbpedia': [
    'http://dbpedia.org/resource/San_Francisco'
  ]
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.listStories(opts, callback);
import aylien_news_api
from aylien_news_api.rest import ApiException

# Configure API key authorization: app_id
aylien_news_api.configuration.api_key['X-AYLIEN-NewsAPI-Application-ID'] = 'YOUR_APP_ID'
# Configure API key authorization: app_key
aylien_news_api.configuration.api_key['X-AYLIEN-NewsAPI-Application-Key'] = 'YOUR_APP_KEY'

# create an instance of the API class
api_instance = aylien_news_api.DefaultApi()

language = ['en']
since = 'NOW-30DAYS'
until = 'NOW'
sort_by = 'published_at'
categories_taxonomy = 'iab-qag'
categories_id = ['IAB2-10']
entities_body_links_dbpedia = ['http://dbpedia.org/resource/San_Francisco']

try:
  # List stories
  api_response = api_instance.list_stories(
    language=language,
    published_at_start=since,
    published_at_end=until,
    sort_by=sort_by,
    categories_taxonomy=categories_taxonomy,
    categories_id=categories_id,
    entities_body_links_dbpedia=entities_body_links_dbpedia
  )
  print(api_response)
except ApiException as e:
  print("Exception when calling DefaultApi->list_stories: %s\n" % e)
<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: app_id
Aylien\NewsApi\Configuration::getDefaultConfiguration()->setApiKey('X-AYLIEN-NewsAPI-Application-ID', 'YOUR_APP_ID');

// Configure API key authorization: app_key
Aylien\NewsApi\Configuration::getDefaultConfiguration()->setApiKey('X-AYLIEN-NewsAPI-Application-Key', 'YOUR_APP_KEY');

$api_instance = new Aylien\NewsApi\Api\DefaultApi();

$opts = array(
  'published_at_start' => 'NOW-30DAYS',
  'published_at_end' => 'NOW',
  'language' => ['en'],
  'sort_by' => 'published_at',
  'categories_taxonomy' => 'iab-qag',
  'categories_id' => ['IAB2-10'],
  'entities_body_links_dbpedia' => ['http://dbpedia.org/resource/San_Francisco']
);

try {
  $result = $api_instance->listStories($opts);
  print_r($result);
} catch (Exception $e) {
  echo 'Exception when calling DefaultApi->listStories: ', $e->getMessage(), PHP_EOL;
}
?>
package com.aylien.newsapisample;

import com.aylien.newsapi.*;
import com.aylien.newsapi.auth.*;
import com.aylien.newsapi.models.*;
import com.aylien.newsapi.parameters.*;
import com.aylien.newsapi.api.DefaultApi;

import java.util.*;

public class Main {

  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();

    // Configure API key authorization: app_id
    ApiKeyAuth app_id = (ApiKeyAuth) defaultClient.getAuthentication("app_id");
    app_id.setApiKey("YOUR_APP_ID");

    // Configure API key authorization: app_key
    ApiKeyAuth app_key = (ApiKeyAuth) defaultClient.getAuthentication("app_key");
    app_key.setApiKey("YOUR_APP_KEY");

    DefaultApi apiInstance = new DefaultApi();

    List<String> language = Arrays.asList("en");
    String since = "NOW-30DAYS";
    String until = "NOW";
    List<String> entitiesBodyLinksDbpedia = Arrays.asList("http://dbpedia.org/resource/San_Francisco");
    String sortBy = "published_at";
    String categoriesTaxonomy = "iab-qag";
    List<String> categoriesId = Arrays.asList("IAB2-10");

    StoriesParams.Builder storiesBuilder = StoriesParams.newBuilder();

    storiesBuilder.setPublishedAtStart(since);
    storiesBuilder.setPublishedAtEnd(until);
    storiesBuilder.setLanguage(language);
    storiesBuilder.setCategoriesTaxonomy(categoriesTaxonomy);
    storiesBuilder.setCategoriesId(categoriesId);
    storiesBuilder.setEntitiesBodyLinksDbpedia(entitiesBodyLinksDbpedia);
    storiesBuilder.setSortBy(sortBy);

    try {
    	Stories result = apiInstance.listStories(storiesBuilder.build());
    	System.out.println(result);
    } catch (ApiException e) {
    	System.err.println("Exception when calling DefaultApi#listStories");
    	e.printStackTrace();
    }
  }
}
# Load the gem
require 'aylien_news_api'

# Setup authorization
AylienNewsApi.configure do |config|
  # Configure API key authorization: app_id
  config.api_key['X-AYLIEN-NewsAPI-Application-ID'] = 'YOUR_APP_ID'
  
  # Configure API key authorization: app_key
  config.api_key['X-AYLIEN-NewsAPI-Application-Key'] = 'YOUR_APP_KEY'
end

api_instance = AylienNewsApi::DefaultApi.new

opts = {
  :published_at_start => "NOW-30DAYS",
  :published_at_end => "NOW",
  :language => ['en'],
  :sort_by => 'published_at',
  :categories_taxonomy => 'iab-qag',
  :categories_id => ['IAB2-10'],
  :entities_body_links_dbpedia => ['http://dbpedia.org/resource/San_Francisco']
}


begin
  #List stories
  result = api_instance.list_stories(opts)
  puts result
rescue AylienNewsApi::ApiError => e
  puts "Exception when calling DefaultApi->list_stories: #{e}"
end
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"

	language := []string{"en"}
	publishedAtStart := "NOW-30DAYS"
	publishedAtEnd := "NOW"
	categoriesTaxonomy := "iab-qag"
	categoriesId := []string{"IAB2-10"}
	entitiesBodyLinksDbpedia := []string{"http://dbpedia.org/resource/San_Francisco"}
	sortBy := "published_at"

	storiesParams := &newsapi.StoriesParams{
		Language:                  language,
		PublishedAtStart:          publishedAtStart,
		PublishedAtEnd:            publishedAtEnd,
		CategoriesTaxonomy:        categoriesTaxonomy,
		CategoriesId:              categoriesId,
		EntitiesBodyLinksDbpedia: entitiesBodyLinksDbpedia,
		SortBy: sortBy}

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

	_ = res

	fmt.Println(storiesResponse)
}
using System;
using Aylien.NewsApi.Api;
using Aylien.NewsApi.Client;
using Aylien.NewsApi.Model;
using System.Collections.Generic;

namespace ConsoleApplicationExample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Configure API key authorization: app_id
            Configuration.Default.ApiKey.Add("X-AYLIEN-NewsAPI-Application-ID", "YOUR_APP_ID");

            // Configure API key authorization: app_key
            Configuration.Default.ApiKey.Add("X-AYLIEN-NewsAPI-Application-Key", "YOUR_APP_KEY");

            var apiInstance = new DefaultApi();

            var language = new List<string> { "en" };
            var publishedAtStart = "NOW-30DAYS";
            var publishedAtEnd = "NOW";
            var categoriesTaxonomy = "iab-qag";
            var categoriesId = new List<string> { "IAB2-10" };
            var entitiesBodyLinksDbpedia = new List<string> {
                "http://dbpedia.org/resource/San_Francisco"
            };
            var sortBy = "published_at";

            try
            {
                // List Stories
                Stories result = apiInstance.ListStories(
                    language: language,
                    publishedAtStart: publishedAtStart,
                    publishedAtEnd: publishedAtEnd,
                    categoriesTaxonomy: categoriesTaxonomy,
                    categoriesId: categoriesId,
                    entitiesBodyLinksDbpedia: entitiesBodyLinksDbpedia,
                    sortBy: sortBy
                );
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling DefaultApi.ListStories: " + e.Message);
            }
        }
    }
}