Skip to content

Commit 80f2fd6

Browse files
committed
docs: keep polling guidance contract-driven
1 parent 46df27b commit 80f2fd6

2 files changed

Lines changed: 12 additions & 24 deletions

File tree

EXAMPLES.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,10 @@ def monitor_prices():
456456
elif price.value < limits['low']:
457457
send_alert(commodity, price.value, limits['low'], 'BELOW')
458458

459-
# 30 minutes fits the free plan: 48 requests/day against a 50/day
460-
# allowance. On Developer and above use 300 (5 minutes), which matches
461-
# how often spot prices actually change - nothing we publish moves
462-
# faster than ~2.5 minutes, so a shorter timer returns the same number.
459+
# Example caller-selected interval. Derive production polling from the
460+
# account's current limit/reset response and the source timestamps.
463461
# See https://docs.oilpriceapi.com/guides/rate-limiting#how-often-to-poll
464-
time.sleep(1800)
462+
time.sleep(1800)
465463

466464
if __name__ == '__main__':
467465
print("Starting price monitor...")

docs/PERFORMANCE_GUIDE.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -235,36 +235,26 @@ while True:
235235

236236
**Solution:**
237237
```python
238-
# Match the interval to your plan AND to how fast the data moves.
238+
# Match the interval to the account limit and how fast the data moves.
239239
import time
240240

241241
while True:
242242
price = client.prices.get("WTI_USD")
243243
print(f"WTI: ${price.value}")
244-
time.sleep(1800) # 30 min -> 48 requests/day, fits the free plan
245-
# Developer and above: 300 (5 minutes)
244+
# Example interval; derive this from current limit/reset metadata.
245+
time.sleep(1800)
246246
```
247247

248-
**Pick the interval from your plan:**
249-
250-
| Plan | Quota | Poll every | Requests/day |
251-
| --- | --- | --- | --- |
252-
| Free | 50 / day | **30 minutes** | 48 |
253-
| Developer | 10,000 / month | 5 minutes | 288 |
254-
| Starter | 50,000 / month | 5 minutes | 1,440 |
255-
| Professional+ | 100,000+ / month | 5 minutes | 2,880 |
256-
257-
Polling faster than the data changes cannot return new information. Measured
258-
over a week: `BRENT_CRUDE_USD` updates about every 2.5 minutes, `WTI_USD` and
259-
`NATURAL_GAS_USD` about every 5, and refined products such as `DIESEL_USD`
260-
about twice a day. Above Developer, extra quota is better spent on more
261-
commodity codes than on a shorter timer.
248+
Choose the interval from the current account response and the source timestamps
249+
returned with the data. Polling faster than the source changes cannot return new
250+
information, while a hard-coded schedule can exceed an account's current
251+
allowance when product limits change.
262252

263253
⚠️ **`get_multiple()` currently issues one HTTP request per code**, so it
264254
consumes quota per commodity rather than per call. Until that is batched
265255
(api#7240), a loop over `get()` and a call to `get_multiple()` cost the same.
266-
The REST API itself accepts up to 20 codes in a single request that counts
267-
once — see the rate-limiting guide if you are close to your quota.
256+
See the rate-limiting guide for the current REST batching contract if you are
257+
close to your quota.
268258

269259
**Better Solution (for streamed updates):**
270260
```python

0 commit comments

Comments
 (0)