Apple News API PHP Client

Throttling
in package

FinalYes

Throttling information returned by Create and Update Article endpoints.

This object provides rate limit information to help you implement smart request scheduling and avoid hitting API rate limits. It is included in the Meta object of Create and Update Article responses.

Tags
see
https://developer.apple.com/documentation/applenewsapi/throttling

Table of Contents

Properties

$estimatedDelayInSeconds  : int|null
$queueSize  : int|null
$quotaAvailable  : int|null

Methods

__construct()  : mixed
Create a new Throttling instance.
fromArray()  : self
Create a Throttling instance from API response data.
isQuotaLow()  : bool
Check if quota is exhausted or nearly exhausted.
shouldDelay()  : bool
Check if we should delay before making another request.

Properties

$estimatedDelayInSeconds read-only

public int|null $estimatedDelayInSeconds = null

$queueSize read-only

public int|null $queueSize = null

$quotaAvailable read-only

public int|null $quotaAvailable = null

Methods

__construct()

Create a new Throttling instance.

public __construct([int|null $estimatedDelayInSeconds = null ][, int|null $queueSize = null ][, int|null $quotaAvailable = null ]) : mixed
Parameters
$estimatedDelayInSeconds : int|null = null

Estimated delay in seconds before the next request can be processed.

$queueSize : int|null = null

Number of requests currently queued for processing.

$quotaAvailable : int|null = null

Number of requests remaining in the current quota period.

fromArray()

Create a Throttling instance from API response data.

public static fromArray(array<string, mixed> $data) : self
Parameters
$data : array<string, mixed>

The throttling data from the API response.

Return values
self

A new Throttling instance populated with the response data.

isQuotaLow()

Check if quota is exhausted or nearly exhausted.

public isQuotaLow([int $threshold = 10 ]) : bool

Use this to proactively pause requests before hitting rate limits.

Parameters
$threshold : int = 10

The minimum quota level to consider "low". Defaults to 10.

Return values
bool

True if quotaAvailable is at or below the threshold.

shouldDelay()

Check if we should delay before making another request.

public shouldDelay() : bool

Returns true if estimatedDelayInSeconds is set and greater than zero, indicating that the API is requesting a delay before the next request.

Return values
bool

True if a delay is recommended before the next request.


        
On this page

Search results