Skip to content

0.2.0

Choose a tag to compare

@subzeroid subzeroid released this 25 Apr 23:23
· 359 commits to main since this release

Breaking change: pure media-pk helpers are now synchronous.

What changed

These methods just call InstagramIdCodec.encode/decode or split a string — no IO. They were async def only because the historical mass-port mechanically turned every method into async. Sync now correctly signals "no IO", removes coroutine overhead in hot paths (parsing feed URLs, batch processing), and matches Python conventions for async libraries (httpx.URL, aiohttp.helpers.parse_mimetype, etc. — all sync helpers in async libs).

Method Before After
Client.media_pk_from_code(code) async def def
Client.media_code_from_pk(pk) async def def
Client.media_pk(media_id) (staticmethod) async def def

Client.media_pk_from_url stays async def — it does HTTP redirect-following for /share/p/ short URLs.

Migration

Drop the await:

# Before
pk = await client.media_pk_from_code("B-fKL9qpeab")

# After
pk = client.media_pk_from_code("B-fKL9qpeab")

Old code will raise TypeError: object str can't be used in 'await' expression.

Install

pip install aiograpi==0.2.0