Skip to main content

Limits and Quotas

To prevent abuse, avoid slowdowns, and ensure that all users make responsible use of our APIs, we enforce quota limits. If you perform too many requests you may exceed your quota; in this case, you will receive an error as a response until when your quota will be restored.

We enforce two different kinds of limits, based on the time range that they apply to.

📆  Long-term usage limits

Long-term usage limits are meant to avoid improper usage of the APIs, by setting a limit on the maximum amount of requests in a certain period.

Long-term Usage quotas are different based on the app visibility!

If the app is public every user that has access to a specific company through a specific app shares (and consumes) the same quotas as other users that have access to the same company through the same app, if the app is private the quotas are no more related to the app but only to the company, this means that creating a new private app won't increase your quotas.

The quota limits are the following:

API limit typeLimit
Requests per hour1.000 requests per hour on a company-app couple
Requests per month40.000 requests per month on a company-app couple for public apps
Requests per month40.000 requests per month per company for private apps

Long-term limits use fixed time windows: these quotas are reset at the beginning of a new hour or month.

If the limit is exceeded, the API returns a 403 Forbidden HTTP status code; the response also includes a Retry-After header, indicating how long you should wait before retrying the request (in seconds).

  Short-term rate limits

Short-term rate limits are meant to avoid usage spikes that could affect the system availability, by preventing applications from sending too many requests in a short-time interval.

Short-term Usage quotas are company-related!!!

This means that every app and user that has access to a specific company shares (and consumes) the same quotas with other apps and users that have access to the same company.

The quota limit is the following:

API limit typeLimit
Requests every 5 minutes300 requests every 5 minutes

Short-term usage limits use a sliding-window algorithm, check the additional resources for further info.

If the limit is exceeded, the API returns a 429 Too Many Requests HTTP status code. The response also includes a Retry-After header, indicating how long you should wait before the request (in seconds).

📑  HTTP Headers and response codes

Every response contains several HTTP headers containing info about long-term usage limits.

HeaderDescription
RateLimit-HourlyRemainingThe number of requests remaining for the current hour.
RateLimit-HourlyLimitThe maximum number of requests you are permitted to make per hour.
RateLimit-MonthlyRemainingThe number of requests remaining for the current month.
RateLimit-MonthlyLimitThe maximum number of requests you are permitted to make per month.

Here you can find an example of the HTTP response:

HTTP/1.1 200 OK
Date: Tue, 05 May 2020 17:27:06 GMT
Status: 200 OK
RateLimit-HourlyRemaining: 840
RateLimit-HourlyLimit: 1000
RateLimit-MonthlyRemaining: 1430
RateLimit-MonthlyLimit: 20000

🌊  Is it still not enough?

We designed our quotas to be able to satisfy the needs of the majority of the use cases. Nevertheless, in some cases, the default quotas could prove to be scarce, and in this situation, the only way is to increment the quota limit.

If you think that your use case requires a higher quota, you can try to request us additional quota. It isn't automatic though, you'll have to explain your use case in detail to our team and demonstrate why our quotas are not sufficient to resolve it.

We can increment only the long-term usage limits.

Short-term rate quotas can't be incremented!

If you're facing an issue with short-term rate quota, e.g. you're obtaining a 429 Too Many Requests error response, it means that you're not managing our APIs correctly. If that's the case, we'll reject every additional quota request we'll receive, and you should instead read the next section.

💆‍♂️  Keep calm and deal with quotas!

As explained above, if the rate limit will be exceeded you'll receive a 429 response to your requests. This is not a fatal error and we expect you to retry the request after a short interval; if the requests will keep arriving too quickly, your requests will result in another error result, and so on.

It is then important to gradually increase the delay between requests to overcome this issue, this is usually done by applying exponential back-off to your requests.

Here you can find some code examples that you can use to introduce exponential back-off on your code:

// We apply exponential backoff to our C# SDK
// https://github.com/fattureincloud/fattureincloud-csharp-sdk/

// We suppose to use the http://www.thepollyproject.org
// and the https://github.com/Polly-Contrib/Polly.Contrib.WaitAndRetry libraries
// to implement the exponential back-off
// to install them using the .Net cli:
// dotnet add package Polly
// dotnet add package Polly.Contrib.WaitAndRetry

using System;
using Polly;
using It.FattureInCloud.Sdk.Api;
using It.FattureInCloud.Sdk.Model;
using It.FattureInCloud.Sdk.Client;
using Polly.Contrib.WaitAndRetry;

namespace Backoff
{
class Program
{
static void Main(string[] args)
{
Configuration config = new Configuration();
config.AccessToken = "YOUR_ACCESS_TOKEN";

var apiInstance = new ProductsApi(config);
var companyId = 11;

var maxRetryAttempts = 5;
var pauseBetweenFailures = Backoff.ExponentialBackoff(TimeSpan.FromSeconds(2), retryCount: maxRetryAttempts);

var retryPolicy = Policy
.Handle<ApiException>()
.WaitAndRetry(pauseBetweenFailures);

retryPolicy.Execute(() =>
{
ListProductsResponse result = apiInstance.ListProducts(companyId);
Console.Write("\n successful");
Console.Write(result);
});
}
}
}

Alternatively, you can use the Retry-After header to wait the right amount of time before sending your request again.

📚  Additional Resources