-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from RobinTTY/v10.1.0
v10.1.0
- Loading branch information
Showing
21 changed files
with
266 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: ApiRateLimits | ||
--- | ||
|
||
The `ApiRateLimits` class represents the rate limits of the GoCardless API. | ||
|
||
## Properties | ||
|
||
### `RequestLimit` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32) | ||
|
||
Indicates the maximum number of allowed requests within the defined time window. Usually populated in every response. | ||
|
||
### `RemainingRequests` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32) | ||
|
||
Indicates the number of remaining requests you can make in the current time window. Usually populated in every response. | ||
|
||
### `RemainingSecondsInTimeWindow` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32) | ||
|
||
Indicates the time remaining in the current time window (in seconds). Usually populated in every response. | ||
|
||
### `RequestLimitAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32) | ||
|
||
Indicates the maximum number of allowed requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint) within the defined time window. Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint). | ||
|
||
### `RemainingRequestsAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32) | ||
|
||
Indicates the number of remaining requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint) you can make in the current time window. Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint). | ||
|
||
### `RemainingSecondsInTimeWindowAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32) | ||
|
||
Indicates the time remaining in the current time window (in seconds) for requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint). Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint). | ||
|
||
## Constructor | ||
|
||
```csharp | ||
public ApiRateLimits(int requestLimit, int remainingRequests, int remainingTimeInTimeWindow, | ||
int maxAccountRequests, int remainingAccountRequests, int remainingTimeInAccountTimeWindow) | ||
``` | ||
|
||
### Parameters | ||
|
||
#### `requestLimit` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)? | ||
|
||
Indicates the maximum number of allowed requests within the defined time window. Usually populated in every response. | ||
|
||
#### `remainingRequests` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)? | ||
|
||
Indicates the number of remaining requests you can make in the current time window. Usually populated in every response. | ||
|
||
#### `remainingSecondsInTimeWindow` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)? | ||
|
||
Indicates the time remaining in the current time window (in seconds). Usually populated in every response. | ||
|
||
#### `requestLimitAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)? | ||
|
||
Indicates the maximum number of allowed requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint) within the defined time window. Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint). | ||
|
||
#### `remainingRequestsAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)? | ||
|
||
Indicates the number of remaining requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint) you can make in the current time window. Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint). | ||
|
||
#### `remainingSecondsInTimeWindowAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)? | ||
|
||
Indicates the time remaining in the current time window (in seconds) for requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint). Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: Handling Rate Limits | ||
--- | ||
|
||
The GoCardless API has [rate limits](https://bankaccountdata.zendesk.com/hc/en-gb/articles/11529637772188-Bank-Account-Data-API-Rate-Limits) depending on the endpoint you are using. With most endpoints you shouldn't run into problems since these limits are usually high enough for most uses. | ||
|
||
The [Accounts endpoint](/docs/api-reference/endpoints/accounts-endpoint) has very tight limitations though. It currently has a limit of 10 requests a day per access scope. That means 10 requests to each of the [details](/docs/api-reference/endpoints/accounts-endpoint#getaccountdetails), [balances](/docs/api-reference/endpoints/accounts-endpoint#getbalances) and [transactions](/docs/api-reference/endpoints/accounts-endpoint#gettransactions) endpoints. In the future this limit will be lowered to 4 per day (no date on this as of now). | ||
|
||
Unsuccessful requests to the API will count towards the general rate limits but not the more stringent limits of the [Accounts endpoint](/docs/api-reference/endpoints/accounts-endpoint). Only successful requests will count towards those. | ||
|
||
## Checking API rate limits | ||
|
||
You can check the rate limits as well as remaining requests with each request you make to the API. The property [`NordigenApiResponse.RateLimits`](/docs/api-reference/responses/nordigen-api-response#ratelimits---apiratelimits) will hold the returned information about the current API limits. | ||
|
||
You can check the limits as follows: | ||
|
||
```csharp | ||
// Execute the request you want to make: | ||
var bankAccountDetailsResponse = await client.AccountsEndpoint.GetAccountDetails(accountId); | ||
|
||
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RequestLimit); | ||
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RemainingRequests); | ||
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RemainingSecondsInTimeWindow); | ||
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RequestLimitAccountsEndpoint); | ||
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RemainingRequestsAccountsEndpoint); | ||
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RemainingSecondsInTimeWindowAccountsEndpoint); | ||
``` | ||
|
||
It's important to handle these limits so your applications user experience isn't degraded. Refreshing data from bank accounts should be handled consciously, so you don't use up all your requests in a short time frame and aren't able to update for the rest of the day. | ||
|
||
If you are a company with a contract with GoCardless you can probably get in contact with their team about increasing these limits. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
slug: v10.1.0 | ||
title: v10.1.0 | ||
date: 2024-08-19T00:00 | ||
--- | ||
|
||
Added the ability to check newly introduced rate limits in the GoCardless API. | ||
|
||
Please refer to the [documentation](/docs/handling-rate-limits) for more information. You can also see the [announcement from GoCardless](https://bankaccountdata.zendesk.com/hc/en-gb/articles/11529584398236-Bank-API-Rate-Limits-and-Rate-Limit-Headers). | ||
|
||
**Full Changelog**: [v10.0.0...v10.1.0](https://github.com/RobinTTY/NordigenApiClient/compare/v10.0.0...v10.1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...inTTY.NordigenApiClient.Tests/.idea/.idea.RobinTTY.NordigenApiClient.dir/.idea/.gitignore
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
src/RobinTTY.NordigenApiClient.Tests/.idea/.idea.RobinTTY.NordigenApiClient.dir/.idea/.name
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...TY.NordigenApiClient.Tests/.idea/.idea.RobinTTY.NordigenApiClient.dir/.idea/encodings.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
....NordigenApiClient.Tests/.idea/.idea.RobinTTY.NordigenApiClient.dir/.idea/indexLayout.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...RobinTTY.NordigenApiClient.Tests/.idea/.idea.RobinTTY.NordigenApiClient.dir/.idea/vcs.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/RobinTTY.NordigenApiClient/Models/Errors/CreateAgreementError.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/RobinTTY.NordigenApiClient/Models/Errors/CreateRequisitionError.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/RobinTTY.NordigenApiClient/Models/Responses/ApiRateLimits.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System.Net.Http.Headers; | ||
using RobinTTY.NordigenApiClient.Endpoints; | ||
|
||
namespace RobinTTY.NordigenApiClient.Models.Responses; | ||
|
||
/// <summary> | ||
/// The rate limits of the GoCardless API. | ||
/// </summary> | ||
public class ApiRateLimits | ||
{ | ||
/// <summary> | ||
/// Indicates the maximum number of allowed requests within the defined time window. | ||
/// Usually populated in every response. | ||
/// </summary> | ||
public int? RequestLimit { get; set; } | ||
/// <summary> | ||
/// Indicates the number of remaining requests you can make in the current time window. | ||
/// Usually populated in every response. | ||
/// </summary> | ||
public int? RemainingRequests { get; set; } | ||
/// <summary> | ||
/// Indicates the time remaining in the current time window (in seconds). | ||
/// Usually populated in every response. | ||
/// </summary> | ||
public int? RemainingSecondsInTimeWindow { get; set; } | ||
/// <summary> | ||
/// Indicates the maximum number of allowed requests to the <see cref="AccountsEndpoint"/> | ||
/// within the defined time window. Only populated in responses from the <see cref="AccountsEndpoint"/>. | ||
/// </summary> | ||
public int? RequestLimitAccountsEndpoint { get; set; } | ||
/// <summary> | ||
/// Indicates the number of remaining requests to the <see cref="AccountsEndpoint"/> | ||
/// you can make in the current time window. Only populated in responses from the <see cref="AccountsEndpoint"/>. | ||
/// </summary> | ||
public int? RemainingRequestsAccountsEndpoint { get; set; } | ||
/// <summary> | ||
/// Indicates the time remaining in the current time window (in seconds) for requests | ||
/// to the <see cref="AccountsEndpoint"/>. Only populated in responses from the <see cref="AccountsEndpoint"/>. | ||
/// </summary> | ||
public int? RemainingSecondsInTimeWindowAccountsEndpoint { get; set; } | ||
|
||
/// <summary> | ||
/// Creates a new instance of <see cref="ApiRateLimits" />. | ||
/// </summary> | ||
/// <param name="requestLimit">Indicates the maximum number of allowed requests within the defined time window.</param> | ||
/// <param name="remainingRequests">Indicates the number of remaining requests you can make in the current time window.</param> | ||
/// <param name="remainingSecondsInTimeWindow">Indicates the time remaining in the current time window (in seconds).</param> | ||
/// <param name="requestLimitAccountsEndpoint">Indicates the maximum number of allowed requests to the <see cref="AccountsEndpoint"/> | ||
/// within the defined time window.</param> | ||
/// <param name="remainingRequestsAccountsEndpoint">Indicates the number of remaining requests to the <see cref="AccountsEndpoint"/> | ||
/// you can make in the current time window.</param> | ||
/// <param name="remainingSecondsInTimeWindowAccountsEndpoint">Indicates the time remaining in the current time window (in seconds) for requests | ||
/// to the <see cref="AccountsEndpoint"/>.</param> | ||
public ApiRateLimits(int? requestLimit, int? remainingRequests, int? remainingSecondsInTimeWindow, int? requestLimitAccountsEndpoint, | ||
int? remainingRequestsAccountsEndpoint, int? remainingSecondsInTimeWindowAccountsEndpoint) | ||
{ | ||
RequestLimit = requestLimit; | ||
RemainingRequests = remainingRequests; | ||
RemainingSecondsInTimeWindow = remainingSecondsInTimeWindow; | ||
RequestLimitAccountsEndpoint = requestLimitAccountsEndpoint; | ||
RemainingRequestsAccountsEndpoint = remainingRequestsAccountsEndpoint; | ||
RemainingSecondsInTimeWindowAccountsEndpoint = remainingSecondsInTimeWindowAccountsEndpoint; | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance of <see cref="ApiRateLimits" />. | ||
/// </summary> | ||
/// <param name="headers">The headers of the HTTP response containing the rate limit information.</param> | ||
public ApiRateLimits(HttpHeaders headers) | ||
{ | ||
RequestLimit = TryParseApiLimit(headers, "HTTP_X_RATELIMIT_LIMIT"); | ||
RemainingRequests = TryParseApiLimit(headers, "HTTP_X_RATELIMIT_REMAINING"); | ||
RemainingSecondsInTimeWindow = TryParseApiLimit(headers, "HTTP_X_RATELIMIT_RESET"); | ||
RequestLimitAccountsEndpoint = TryParseApiLimit(headers, "HTTP_X_RATELIMIT_ACCOUNT_SUCCESS_LIMIT"); | ||
RemainingRequestsAccountsEndpoint = TryParseApiLimit(headers, "HTTP_X_RATELIMIT_ACCOUNT_SUCCESS_REMAINING"); | ||
RemainingSecondsInTimeWindowAccountsEndpoint = TryParseApiLimit(headers, "HTTP_X_RATELIMIT_ACCOUNT_SUCCESS_RESET"); | ||
} | ||
|
||
private static int? TryParseApiLimit(HttpHeaders headers, string headerName) | ||
{ | ||
headers.TryGetValues(headerName, out var values); | ||
var firstHeaderValue = values?.FirstOrDefault(); | ||
var parseSuccess = int.TryParse(firstHeaderValue, out var limitValue); | ||
|
||
return parseSuccess ? limitValue : null; | ||
} | ||
} |
Oops, something went wrong.