Sync vs async¶
Sync¶
Use Affinity:
from affinity import Affinity
with Affinity(api_key="your-key") as client:
for person in client.persons.all():
print(person.first_name)
Async¶
Use AsyncAffinity:
from affinity import AsyncAffinity
async def main() -> None:
async with AsyncAffinity(api_key="your-key") as client:
async for company in client.companies.all():
print(company.name)
Parity¶
AsyncAffinity mirrors the Affinity service surface area.
| Service | Sync (Affinity) |
Async (AsyncAffinity) |
|---|---|---|
| companies | ✅ | ✅ |
| persons | ✅ | ✅ |
| lists | ✅ | ✅ |
| opportunities | ✅ | ✅ |
| tasks | ✅ | ✅ |
| notes | ✅ | ✅ |
| reminders | ✅ | ✅ |
| webhooks | ✅ | ✅ |
| interactions | ✅ | ✅ |
| fields | ✅ | ✅ |
| field_values | ✅ | ✅ |
| files | ✅ | ✅ |
| relationships | ✅ | ✅ |
| auth | ✅ | ✅ |
| rate_limits | ✅ | ✅ |