Skip to content

v1.13.0 — get_multiple batches (up to 20x less quota)

Choose a tag to compare

@karlwaldman karlwaldman released this 23 Aug 13:40
· 27 commits to main since this release
31b8d80

get_multiple() now batches — up to 20× less quota

get_multiple() previously made one HTTP request per commodity code. The REST API accepts up to 20 codes in a single request that counts once against your quota, so the method whose whole purpose is fetching several prices cost up to twenty times more than writing the call by hand.

Through this method the free plan was 50 code-reads a day. Through the raw API it is 1,000.

What changes for you

Nothing in your code. Your quota consumption drops — a get_multiple() call that consumed N requests now consumes ceil(N / 20).

 10 codes  ->  1 request   (was 10)
 30 codes  ->  2 requests  (was 30)

The per-code failure contract is unchanged. Because the API rejects the whole request when any code in it is unknown, a failed batch is retried per code — for that chunk only — so return_failures=True still reports exactly which code was at fault.

Async too, and it was worse

AsyncPricesResource.get_multiple() used asyncio.gather to fan out one request per code concurrently, which could also trip the 60-per-60-second rate limit on a long list. It now gathers chunks, so 25 codes are 2 concurrent requests rather than 25.

Documentation

Polling examples now default to an interval that fits the free plan (30 minutes), with a plan/interval table and the measured update cadence of the underlying data. Nothing we publish moves faster than about every 2.5 minutes, so a shorter timer returns the same number.

Why minor rather than patch

The public signature is unchanged, so strict semver says patch. This is a minor because it materially changes how many HTTP requests a call makes — that keeps it out of tight pins like ~=1.12.8 while staying available to ~=1.12, so anyone on a narrow pin opts in rather than being surprised.


Full changelog: https://github.com/OilpriceAPI/python-sdk/blob/main/CHANGELOG.md