News API - Rate Limits

About

Rate limiting of the API is primarily considered on a per-application basis — or more accurately described, per application ID you control.

Hits

Each endpoint is subject to 60 hits per minute and 3 hits per second is the rate limit on all endpoints.

Story Volumes

There are no limits on stories volume for paid users unless they've asked for Capped Spend. Trial users have a total volume limit of 14,000 stories during their trial period.

Response

When an application exceeds the rate limit for a given API endpoint, the AYLIEN News API will now return an HTTP 429 "Too Many Requests" response code. There are three response headers you can use to check your quota allowance, the number of hits remaining on your quota and the time and date your quota will be reset:

  • X-RateLimit-Limit : The number of allowed requests in the current period
  • X-RateLimit-Remaining : The number of remaining requests in the current period
  • X-RateLimit-Reset : The remaining window before the rate limit resets in UTC epoch seconds

What happens if you get rate limited a lot?

If you're continually getting rate limited, we may block your application or IP. For repeat offenders, we may block your other applications as well, and disallow you from creating new applications.

If you're using one of our SDKs, you can use the following methods to retrieve the above values:

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': 'trump',
  'sortBy': 'social_shares_count.facebook',
  'language': ['en'],
  'publishedAtStart': 'NOW-7DAYS',
  'publishedAtEnd': 'NOW', 
  'entitiesBodyLinksDbpedia': [
    'http://dbpedia.org/resource/Donald_Trump',
    'http://dbpedia.org/resource/Hillary_Rodham_Clinton'
  ]
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Rate limit headers are as follows:');
    console.log('X-RateLimit-Limit:', response.headers['x-ratelimit-limit']);
    console.log('X-RateLimit-Remaining:', response.headers['x-ratelimit-remaining']);
    console.log('X-RateLimit-Reset:', response.headers['x-ratelimit-reset']);
  }
};
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()

opts = {
  'title': 'trump',
  'sort_by': 'social_shares_count.facebook',
  'language': ['en'],
  'published_at_start': 'NOW-7DAYS',
  'published_at_end': 'NOW',
  'entities_body_links_dbpedia': [
    'http://dbpedia.org/resource/Donald_Trump',
    'http://dbpedia.org/resource/Hillary_Rodham_Clinton'
  ]
}

try:
    # List stories
    api_response = api_instance.list_stories_with_http_info(**opts)
    
    print('API called successfully. Rate limit headers are as follows:')
    print("X-RateLimit-Limit: %s" % api_response[2]['X-RateLimit-Limit'])
    print("X-RateLimit-Remaining: %s" % api_response[2]['X-RateLimit-Remaining'])
    print("X-RateLimit-Reset: %s" % api_response[2]['X-RateLimit-Reset'])
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' => 'trump',
  'published_at_start' => 'NOW-7DAYS',
  'published_at_end' => 'NOW',
  'entities_body_links_dbpedia' => [
    'http://dbpedia.org/resource/Donald_Trump',
    'http://dbpedia.org/resource/Hillary_Rodham_Clinton'
  ],
  'language' => ['en'],
  'sort_by' => 'social_shares_count.facebook'
);

try {
    $result = $api_instance->listStoriesWithHttpInfo($opts);
    print_r("API called successfully. Rate limit headers are as follows:\n"); 
    print_r("X-RateLimit-Limit: " . $result[2]['X-RateLimit-Limit'] . "\n");
    print_r("X-RateLimit-Remaining: " . $result[2]['X-RateLimit-Remaining'] . "\n");
    print_r("X-RateLimit-Reset: " . $result[2]['X-RateLimit-Reset'] . "\n");
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->listStories: ', $e->getMessage(), "\n";
}
?>
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();

        StoriesParams.Builder storiesBuilder = StoriesParams.newBuilder();

        storiesBuilder.setTitle("trump");
        storiesBuilder.setSortBy("social_shares_count.facebook");
        storiesBuilder.setLanguage(Arrays.asList("en"));
        storiesBuilder.setPublishedAtStart("NOW-7DAYS");
        storiesBuilder.setPublishedAtEnd("NOW");
        storiesBuilder.setEntitiesBodyLinksDbpedia(Arrays.asList(
                "http://dbpedia.org/resource/Donald_Trump",
                "http://dbpedia.org/resource/Hillary_Rodham_Clinton"
        ));

        try {
            Stories result = apiInstance.listStories(storiesBuilder.build());
            Map<String, List<String>> responseHeaders = defaultClient.getResponseHeaders();

            System.out.println("API called successfully. Rate limit headers are as follows:");
            System.out.println("X-RateLimit-Limit: " + responseHeaders.get("X-RateLimit-Limit").get(0));
            System.out.println("X-RateLimit-Remaining: " + responseHeaders.get("X-RateLimit-Remaining").get(0));
            System.out.println("X-RateLimit-Reset: " + responseHeaders.get("X-RateLimit-Reset").get(0));
        } 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 => 'trump',
  :published_at_start => "NOW-7DAYS",
  :published_at_end => "NOW",
  :entities_body_links_dbpedia => [
    'http://dbpedia.org/resource/Donald_Trump',
    'http://dbpedia.org/resource/Hillary_Rodham_Clinton'
  ],
  :language => ['en'],
  :sort_by => 'social_shares_count.facebook'
}


begin
  #List stories
  result = api_instance.list_stories_with_http_info(opts)
  puts 'API called successfully. Rate limit headers are as follows:'
  puts "X-RateLimit-Limit: #{result[2]['X-RateLimit-Limit']}"
  puts "X-RateLimit-Remaining: #{result[2]['X-RateLimit-Remaining']}"
  puts "X-RateLimit-Reset: #{result[2]['X-RateLimit-Reset']}"
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"

	storiesParams := &newsapi.StoriesParams{
		Title:            "trump",
		Language:         []string{"en"},
		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)
	}
	_ = storiesResponse

	fmt.Println("API called successfully. Rate limit headers are as follows:")
	fmt.Println("X-Ratelimit-Limit: " + res.Header["X-Ratelimit-Limit"][0])
	fmt.Println("X-Ratelimit-Remaining: " + res.Header["X-Ratelimit-Remaining"][0])
	fmt.Println("X-Ratelimit-Reset: " + res.Header["X-Ratelimit-Reset"][0])
}
using System;
using Aylien.NewsApi.Api;
using Aylien.NewsApi.Client;
using Aylien.NewsApi.Model;
using System.Collections.Generic;

namespace RateLimitExample
{
    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();

            try
            {
                var result = apiInstance.ListStoriesWithHttpInfo(
                    title: "trump",
                    publishedAtStart: "NOW-7DAYS",
                    publishedAtEnd: "NOW",
                    language: new List<String> { "en" },
                    entitiesBodyLinksDbpedia: new List<String> {
                        "http://dbpedia.org/resource/Donald_Trump",
                        "http://dbpedia.org/resource/Hillary_Rodham_Clinton"
                    },
                    sortBy: "social_shares_count.facebook"
                );

                Console.WriteLine("API called successfully. Rate limit headers are as follows:");
                Console.WriteLine("X-RateLimit-Limit: " + result.Headers["X-RateLimit-Limit"]);
                Console.WriteLine("X-RateLimit-Remaining: " + result.Headers["X-RateLimit-Remaining"]);
                Console.WriteLine("X-RateLimit-Reset: " + result.Headers["X-RateLimit-Reset"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling DefaultApi.ListStories: " + e.Message);
            }
        }
    }
}