Skip to content

Commit 976f6b5

Browse files
makowskidclaude
andcommitted
Add requests_per_minute to quota response
The /quota endpoint now returns requests_per_minute (int). Added the field to SubscriptionInfo DTO, quota() method, and documented in README. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent a71ebe0 commit 976f6b5

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,34 @@ See more at [SharpAPI.com Website &raquo;](https://sharpapi.com/)
1010

1111
---
1212

13+
## Quota Method
14+
15+
The `quota()` method returns a `SubscriptionInfo` DTO with the following fields:
16+
17+
| Field | Type | Description |
18+
|---|---|---|
19+
| `timestamp` | `Carbon` | Timestamp of the subscription check |
20+
| `on_trial` | `bool` | Whether the account is on a trial period |
21+
| `trial_ends` | `Carbon` | End date of the trial period |
22+
| `subscribed` | `bool` | Whether the user is currently subscribed |
23+
| `current_subscription_start` | `Carbon` | Start of the current subscription period |
24+
| `current_subscription_end` | `Carbon` | End of the current subscription period |
25+
| `current_subscription_reset` | `Carbon` | Quota reset timestamp |
26+
| `subscription_words_quota` | `int` | Total word quota for the period |
27+
| `subscription_words_used` | `int` | Words used in the current period |
28+
| `subscription_words_used_percentage` | `float` | Percentage of word quota used |
29+
| `requests_per_minute` | `int` | Maximum API requests allowed per minute |
30+
31+
```php
32+
$client = new SharpApiClient('your-api-key');
33+
$quota = $client->quota();
34+
35+
echo $quota->subscription_words_quota;
36+
echo $quota->requests_per_minute;
37+
```
38+
39+
---
40+
1341
## Credits
1442

1543
- [A2Z WEB LTD](https://github.com/a2zwebltd)

src/Client/SharpApiClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ public function quota(): ?SubscriptionInfo
170170
current_subscription_reset: new Carbon($info['current_subscription_reset']),
171171
subscription_words_quota: $info['subscription_words_quota'],
172172
subscription_words_used: $info['subscription_words_used'],
173-
subscription_words_used_percentage: $info['subscription_words_used_percentage']
173+
subscription_words_used_percentage: $info['subscription_words_used_percentage'],
174+
requests_per_minute: $info['requests_per_minute']
174175
);
175176
}
176177

src/DTO/SubscriptionInfo.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class SubscriptionInfo
2323
* @param int $subscription_words_used Number of words used in the current subscription period.
2424
* @param float $subscription_words_used_percentage Percentage of the word quota used
2525
* in the current subscription period.
26+
* @param int $requests_per_minute Maximum number of API requests allowed per minute.
2627
*/
2728
public function __construct(
2829
public Carbon $timestamp,
@@ -34,7 +35,8 @@ public function __construct(
3435
public Carbon $current_subscription_reset,
3536
public int $subscription_words_quota,
3637
public int $subscription_words_used,
37-
public float $subscription_words_used_percentage
38+
public float $subscription_words_used_percentage,
39+
public int $requests_per_minute
3840
)
3941
{
4042
}
@@ -57,6 +59,7 @@ public function toArray(): array
5759
'subscription_words_quota' => $this->subscription_words_quota,
5860
'subscription_words_used' => $this->subscription_words_used,
5961
'subscription_words_used_percentage' => $this->subscription_words_used_percentage,
62+
'requests_per_minute' => $this->requests_per_minute,
6063
];
6164
}
6265
}

0 commit comments

Comments
 (0)