Models¶
Affinity data models.
All Pydantic models are available from this module.
Tip
ID types and enums live in affinity.types.
AffinityList
¶
Bases: AffinityModel
A list (spreadsheet) in Affinity.
Named AffinityList to avoid collision with Python's list type.
Note
client.lists.get() reads the list from V2, so fields is None (use
client.lists.get_fields(list_id)) and additional_permissions is empty. Use
client.lists.get_size(list_id) for the number of entries (read from V1).
Source code in affinity/models/entities.py
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | |
model_post_init(__context: Any) -> None
¶
Transfer list_size_temp to _list_size_hint private attr.
Source code in affinity/models/entities.py
693 694 695 696 697 698 | |
AffinityModel
¶
Bases: BaseModel
Base model with common configuration.
Source code in affinity/models/entities.py
58 59 60 61 62 63 64 65 66 | |
AsyncPageIterator
¶
Bases: Generic[T]
Asynchronous iterator that automatically fetches all pages.
Usage
async for item in client.companies.all(): print(item.name)
Source code in affinity/models/pagination.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
all(*, limit: int | None = _DEFAULT_LIMIT) -> list[T]
async
¶
Fetch all items across all pages into a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int | None
|
Maximum items to fetch. Default 100,000. Set to None for unlimited. |
_DEFAULT_LIMIT
|
Returns:
| Type | Description |
|---|---|
list[T]
|
List of all items. |
Raises:
| Type | Description |
|---|---|
TooManyResultsError
|
If results exceed limit. |
Note
The check occurs after extending results, so the final list may exceed limit by up to one page before the error is raised.
Example
Default - safe for most use cases¶
persons = [p async for p in client.persons.all()] # Using async iterator
Or use .all() method with limit check¶
it = AsyncPageIterator(fetch_page) persons = await it.all() # Returns list, raises if > 100k
Explicit unlimited for large exports¶
all_persons = await it.all(limit=None)
Custom limit¶
persons = await it.all(limit=500_000)
Source code in affinity/models/pagination.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
pages(*, on_progress: Callable[[PaginationProgress], None] | None = None) -> AsyncIterator[PaginatedResponse[T]]
async
¶
Iterate through pages (not individual items).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
on_progress
|
Callable[[PaginationProgress], None] | None
|
Optional callback fired after fetching each page. Receives PaginationProgress with page_number, items_in_page, items_so_far, and has_next. Callbacks should be lightweight; heavy processing should happen outside the callback to avoid blocking iteration. |
None
|
Yields:
| Type | Description |
|---|---|
AsyncIterator[PaginatedResponse[T]]
|
PaginatedResponse objects for each page. |
Example
def report(p: PaginationProgress): print(f"Page {p.page_number}: {p.items_so_far} items so far")
async for page in client.persons.all().pages(on_progress=report): process(page.data)
Source code in affinity/models/pagination.py
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
BatchOperationResponse
¶
Bases: AffinityModel
Response from batch field operations.
Affinity's update-fields PATCH returns {"operation": "update-fields"} on success and
an error for the whole batch otherwise (all-or-nothing), so results is usually empty.
Source code in affinity/models/pagination.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | |
BatchOperationResult
¶
Bases: AffinityModel
Result of a single operation in a batch.
Source code in affinity/models/pagination.py
535 536 537 538 539 540 | |
CallV2
¶
Bases: _Event
A call (V2 GET /v2/calls).
Source code in affinity/models/interactions_v2.py
53 54 | |
ChatMessageV2
¶
Bases: AffinityModel
A chat message (V2 GET /v2/chat-messages).
Source code in affinity/models/interactions_v2.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
Company
¶
Bases: AffinityModel
Full company representation.
Note: Called Organization in V1 API.
Source code in affinity/models/entities.py
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
CompanyCreate
¶
Bases: AffinityModel
Data for creating a new company (V1 API).
Source code in affinity/models/entities.py
522 523 524 525 526 527 | |
CompanyDuplicateSuggestion
¶
Bases: AffinityModel
Two company profiles Affinity thinks are the same company.
Merge duplicates[0] into primary with companies.merge(primary.id, duplicate.id).
match_criteria: domain-match (high confidence), domain-redirect (medium),
name (low).
Source code in affinity/models/discovery.py
33 34 35 36 37 38 39 40 41 42 43 44 45 | |
CompanyMergeState
¶
Bases: AffinityModel
One company merge (V2 GET /v2/company-merges).
Source code in affinity/models/secondary.py
667 668 669 670 671 672 673 674 675 676 677 | |
CompanyRef
¶
Bases: AffinityModel
A bare company reference ({"id": …}).
Source code in affinity/models/secondary.py
265 266 267 268 | |
CompanyUpdate
¶
Bases: AffinityModel
Data for updating a company (V1 API).
Source code in affinity/models/entities.py
530 531 532 533 534 535 | |
ConnectionCompany
¶
Bases: AffinityModel
A company in an inferred connection.
Source code in affinity/models/discovery.py
62 63 64 65 66 67 | |
ConnectionTarget
¶
Bases: AffinityModel
Someone outside your Affinity data you'd like to know.
full_name is always set when known; API 2024-01-01 sends first_name/last_name
instead (later versions send only the full name).
Source code in affinity/models/discovery.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
CoworkerConnection
¶
Bases: AffinityModel
Someone you know (source) who worked with the target at shared_employer.
Source code in affinity/models/discovery.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
CoworkerConnectionGroup
¶
Bases: AffinityModel
A target and the people you know who worked with them, strongest first.
Source code in affinity/models/discovery.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
DealRole
¶
Bases: AffinityModel
A person's role in a deal.
Source code in affinity/models/discovery.py
114 115 116 117 118 119 120 121 | |
DropdownOption
¶
Bases: AffinityModel
A selectable option in a dropdown field.
type ("dropdown", "ranked-dropdown" or "status-dropdown"), status_category
and win_rate come from the V2 dropdown-options endpoints; V1 payloads leave them None
and use integer colours.
Source code in affinity/models/entities.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
DuplicateCompanyProfile
¶
Bases: AffinityModel
A company in a duplicate suggestion.
Source code in affinity/models/discovery.py
22 23 24 25 26 27 28 29 30 | |
EmailV2
¶
Bases: AffinityModel
An email (V2 GET /v2/emails). A subject the user may not see is "********".
Source code in affinity/models/interactions_v2.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
EntityFile
¶
Bases: AffinityModel
A file attached to an entity.
Source code in affinity/models/secondary.py
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | |
FieldCreate
¶
Bases: AffinityModel
Data for creating a new field (V1 API).
Source code in affinity/models/entities.py
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | |
FieldMetadata
¶
Bases: AffinityModel
Metadata about a field (column) in Affinity.
Includes both V1 numeric IDs and V2 string IDs for enriched fields.
Source code in affinity/models/entities.py
915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 | |
FieldValue
¶
Bases: AffinityModel
A single field value (cell data).
The value can be various types depending on the field's value_type.
Source code in affinity/models/entities.py
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | |
FieldValueChange
¶
Bases: AffinityModel
Historical change to a field value.
Source code in affinity/models/entities.py
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | |
FieldValueChangeEntity
¶
Bases: AffinityModel
The entity (person, company or opportunity) whose field value changed.
Source code in affinity/models/secondary.py
541 542 543 544 | |
FieldValueChangeField
¶
Bases: AffinityModel
The field a V2 field value change belongs to.
Source code in affinity/models/secondary.py
532 533 534 535 536 537 538 | |
FieldValueChangeListEntry
¶
Bases: AffinityModel
The list entry a V2 field value change occurred in.
Source code in affinity/models/secondary.py
547 548 549 550 551 | |
FieldValueChangeV2
¶
Bases: AffinityModel
A field value change from GET /v2/field-value-changes (all entities and fields).
action_type is "add", "update" or "delete" (V2 names; V1 uses create/update/
delete). value_type is the field's value type (e.g. "ranked-dropdown") and value
is kept as the API sends it (its shape depends on value_type; a deleted dropdown option
or entity comes back as a reference with a displayValue snapshot). changer is
None for system changes such as enrichment.
Source code in affinity/models/secondary.py
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
FieldValueCreate
¶
Bases: AffinityModel
Data for creating a field value (V1 API).
Source code in affinity/models/entities.py
1036 1037 1038 1039 1040 1041 1042 | |
FileRef
¶
Bases: AffinityModel
The file matched by a file search (file in a result).
Source code in affinity/models/search.py
33 34 35 36 37 | |
FileSearchResult
¶
Bases: AffinityModel
One file search hit: the file, the page of the passage, and the passage.
Source code in affinity/models/search.py
40 41 42 43 44 45 46 | |
FileV2
¶
Bases: AffinityModel
A file's metadata from V2 (files.feed).
V2 files carry no person/company/opportunity; download_url (single-file reads only) is
a signed URL that expires 60 seconds after the response.
Source code in affinity/models/secondary.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
FundingRound
¶
Bases: AffinityModel
The funding round behind an investor-executive connection.
Source code in affinity/models/discovery.py
124 125 126 127 128 129 130 | |
Grant
¶
Bases: AffinityModel
API key grant information.
Source code in affinity/models/secondary.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | |
scope: str | None
property
¶
Backwards-compatible convenience for older response shapes.
Returns the first scope string when present, otherwise None.
Interaction
¶
Bases: AffinityModel
An interaction (email, meeting, call, or chat message).
Different interaction types have different fields available.
Source code in affinity/models/secondary.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
InteractionAttendee
¶
Bases: AffinityModel
A participant: an email address, and the Affinity person when one matches.
Source code in affinity/models/interactions_v2.py
19 20 21 22 23 | |
InteractionCreate
¶
Bases: AffinityModel
Data for creating an interaction (V1 API).
Note: The API only supports person IDs as participants. The Affinity UI's "Also add to... search for an entity" feature (associating an interaction with a company or opportunity) has no API equivalent.
Source code in affinity/models/secondary.py
230 231 232 233 234 235 236 237 238 239 240 241 242 | |
InteractionUpdate
¶
Bases: AffinityModel
Data for updating an interaction (V1 API).
Source code in affinity/models/secondary.py
245 246 247 248 249 250 251 | |
InvestorExecutiveConnection
¶
Bases: AffinityModel
Someone you know (source, the investor) who invested in a company where the target
was an executive.
Source code in affinity/models/discovery.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
InvestorExecutiveConnectionGroup
¶
Bases: AffinityModel
A target (an executive) and the investors you know who backed their company.
Source code in affinity/models/discovery.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
ListCreate
¶
Bases: AffinityModel
A list to create (V2). The caller becomes its creator and owner.
owner_id and additional_permissions can only be set through V1: with either, the
list is created through the V1 API.
Source code in affinity/models/entities.py
717 718 719 720 721 722 723 724 725 726 727 728 | |
ListEntry
¶
Bases: AffinityModel
A row in a list, linking an entity to a list.
Holds the list-specific field values and which entity the row is for (entity_id,
entity_type). entity (a summary of that entity) is filled only where the endpoint
embeds it, e.g. a list's entries; it is None from companies.get_list_entries() and
persons.get_list_entries().
Source code in affinity/models/entities.py
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | |
ListEntryCreate
¶
Bases: AffinityModel
Data for adding an entity to a list (V1 API).
Source code in affinity/models/entities.py
883 884 885 886 887 | |
ListEntryWithEntity
¶
Bases: AffinityModel
List entry with full entity data included (V2 response format).
Source code in affinity/models/entities.py
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 | |
ListPermission
¶
Bases: AffinityModel
Additional permission on a list.
Source code in affinity/models/entities.py
638 639 640 641 642 | |
ListSummary
¶
Bases: AffinityModel
Minimal list reference used by relationship endpoints.
Source code in affinity/models/entities.py
701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |
MeetingV2
¶
Bases: _Event
A meeting (V2 GET /v2/meetings).
Source code in affinity/models/interactions_v2.py
57 58 59 60 | |
Note
¶
Bases: AffinityModel
A note attached to one or more entities.
Notes can be plain text, HTML, or AI-generated meeting summaries.
Source code in affinity/models/secondary.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
NoteContent
¶
Bases: AffinityModel
Note content in V2 format.
Source code in affinity/models/secondary.py
127 128 129 130 | |
NoteCreate
¶
Bases: AffinityModel
A note to create (V2 API).
Attach it to at least one person, company or opportunity, or make it a reply with
parent_id (a reply has no attachments of its own). type says how content is
written: PLAIN_TEXT (default; escaped and wrapped in paragraphs) or HTML.
Source code in affinity/models/secondary.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
NoteRef
¶
Bases: AffinityModel
The note matched by a note search (note in a result).
Source code in affinity/models/search.py
17 18 19 20 21 22 | |
NoteSearchResult
¶
Bases: AffinityModel
One note search hit: the note and its best-matching passage.
Source code in affinity/models/search.py
25 26 27 28 29 30 | |
NoteUpdate
¶
Bases: AffinityModel
Changes to a note: only what is set is sent.
type says how content is written (PLAIN_TEXT by default, or HTML), whatever
the note was before; V2 stores both as HTML. person_ids/company_ids/
opportunity_ids replace the note's attachments of that kind ([] clears them; root
notes only).
Source code in affinity/models/secondary.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
NoteV2
¶
Bases: AffinityModel
V2 API note format.
replies_count and the attached companies / persons / opportunities (first ones,
with *_total) are filled only when requested with includes (notes.feed /
notes.get); otherwise they are None.
Source code in affinity/models/secondary.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
Opportunity
¶
Bases: AffinityModel
Deal/opportunity in a pipeline.
Note
The V2 API returns empty person_ids and company_ids arrays even
when associations exist. Use client.opportunities.get_associated_person_ids()
or client.opportunities.get_details() to retrieve association data.
See the opportunity-associations guide for details.
Source code in affinity/models/entities.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |
OpportunityCreate
¶
Bases: AffinityModel
Data for creating a new opportunity (V1 API).
Source code in affinity/models/entities.py
604 605 606 607 608 609 610 | |
OpportunityRef
¶
Bases: AffinityModel
A bare opportunity reference ({"id": …}).
Source code in affinity/models/secondary.py
271 272 273 274 | |
OpportunitySummary
¶
Bases: AffinityModel
Minimal opportunity data returned in nested contexts.
Source code in affinity/models/entities.py
626 627 628 629 630 | |
OpportunityUpdate
¶
Bases: AffinityModel
Data for updating an opportunity (V1 API).
Source code in affinity/models/entities.py
613 614 615 616 617 618 | |
PageIterator
¶
Bases: Generic[T]
Synchronous iterator that automatically fetches all pages.
Usage
for item in client.companies.all(): print(item.name)
Source code in affinity/models/pagination.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
all(*, limit: int | None = _DEFAULT_LIMIT) -> list[T]
¶
Fetch all items across all pages into a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int | None
|
Maximum items to fetch. Default 100,000. Set to None for unlimited. |
_DEFAULT_LIMIT
|
Returns:
| Type | Description |
|---|---|
list[T]
|
List of all items. |
Raises:
| Type | Description |
|---|---|
TooManyResultsError
|
If results exceed limit. |
Note
The check occurs after extending results, so the final list may exceed limit by up to one page before the error is raised.
Example
Default - safe for most use cases¶
persons = list(client.persons.all()) # Using iterator
Or use .all() method with limit check¶
it = PageIterator(fetch_page) persons = it.all() # Returns list, raises if > 100k
Explicit unlimited for large exports¶
all_persons = it.all(limit=None)
Custom limit¶
persons = it.all(limit=500_000)
Source code in affinity/models/pagination.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
pages(*, on_progress: Callable[[PaginationProgress], None] | None = None) -> Iterator[PaginatedResponse[T]]
¶
Iterate through pages (not individual items).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
on_progress
|
Callable[[PaginationProgress], None] | None
|
Optional callback fired after fetching each page. Receives PaginationProgress with page_number, items_in_page, items_so_far, and has_next. Callbacks should be lightweight; heavy processing should happen outside the callback to avoid blocking iteration. |
None
|
Yields:
| Type | Description |
|---|---|
PaginatedResponse[T]
|
PaginatedResponse objects for each page. |
Example
def report(p: PaginationProgress): print(f"Page {p.page_number}: {p.items_so_far} items so far")
for page in client.persons.all().pages(on_progress=report): process(page.data)
Source code in affinity/models/pagination.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
PaginatedResponse
¶
Bases: AffinityModel, Generic[T]
A paginated response from the API.
Provides access to the current page of results and pagination info. Works with all Affinity API endpoints transparently.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
list[T]
|
List of items in the current page. |
has_next |
bool
|
Whether more pages are available. |
next_cursor |
str | None
|
Cursor for fetching the next page (use this for pagination). |
Example
page = client.companies.list(limit=100)
while page.has_next:
process(page.data)
page = client.companies.list(limit=100, cursor=page.next_cursor)
Tip
Always use next_cursor for pagination. Avoid accessing
pagination.next_cursor or next_page_token directly.
Source code in affinity/models/pagination.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
filter_stats: FilterStats | None
property
¶
Stats for client-side filtered queries (scanned/matched counts).
has_next: bool
property
¶
Whether there are more pages.
next_cursor: str | None
property
¶
Cursor for the next page, if any.
Returns the V2 pagination URL or V1 page token, whichever is present.
Always use this property instead of accessing pagination.next_cursor
or next_page_token directly.
total_count: int | None
property
¶
Total number of matching items, for endpoints that report it (else None).
__len__() -> int
¶
Number of items in current page.
Source code in affinity/models/pagination.py
127 128 129 | |
PaginationInfo
¶
Bases: AffinityModel
V2 pagination info returned in responses.
Source code in affinity/models/pagination.py
64 65 66 67 68 | |
PaginationProgress
dataclass
¶
Progress information for pagination callbacks.
Source code in affinity/models/pagination.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
Person
¶
Bases: AffinityModel
Full person representation.
Note: Companies are called Organizations in V1 API.
Source code in affinity/models/entities.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
full_name: str
property
¶
Get the person's full name.
PersonCreate
¶
Bases: AffinityModel
Data for creating a new person.
Note: "Current Organization" and "Current Job Title" cannot be set during creation. "Current Organization" is a derived/system-managed field (read-only via API, driven by enrichment and email domain). "Current Job Title" can be updated after creation via the field-values endpoint.
Source code in affinity/models/entities.py
430 431 432 433 434 435 436 437 438 439 440 441 442 | |
PersonDuplicateSuggestion
¶
Bases: AffinityModel
Two person profiles Affinity thinks are the same person.
Merge duplicates[0] into primary with persons.merge(primary.id, duplicate.id).
match_criteria: intelligent (medium confidence: email matching across sources),
name (low).
Source code in affinity/models/discovery.py
48 49 50 51 52 53 54 55 56 57 58 59 | |
PersonMergeState
¶
Bases: AffinityModel
One person merge (V2 GET /v2/person-merges).
Source code in affinity/models/secondary.py
680 681 682 683 684 685 686 687 688 689 690 | |
PersonRef
¶
Bases: AffinityModel
A bare person reference ({"id": …}).
Source code in affinity/models/secondary.py
259 260 261 262 | |
PersonUpdate
¶
Bases: AffinityModel
Data for updating a person (V1 API).
Source code in affinity/models/entities.py
445 446 447 448 449 450 451 | |
RateLimitBucket
¶
Bases: AffinityModel
A single rate limit bucket (quota window).
Source code in affinity/models/rate_limit_snapshot.py
20 21 22 23 24 25 26 | |
RateLimitInfo
¶
Bases: AffinityModel
Rate limit information for an API key.
Source code in affinity/models/secondary.py
619 620 621 622 623 624 625 | |
RateLimitSnapshot
¶
Bases: AffinityModel
A best-effort snapshot of rate limit state.
Notes:
- source="headers" means the snapshot is derived from tracked HTTP response headers.
- source="endpoint" means the snapshot is derived from a dedicated endpoint response payload.
- source="unknown" means no reliable rate limit information has been observed yet.
Source code in affinity/models/rate_limit_snapshot.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
RateLimits
¶
Bases: AffinityModel
Current rate limit status.
Source code in affinity/models/secondary.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | |
Relationship
¶
Bases: AffinityModel
How strongly two people are connected.
interaction_score runs from 0.0 to 1.0 (higher is stronger); a relationship known only
from LinkedIn has score 0 and linkedin_connected_on set.
Source code in affinity/models/relationships_v2.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
RelationshipPerson
¶
Bases: AffinityModel
One side of a relationship.
Source code in affinity/models/relationships_v2.py
13 14 15 16 17 18 19 | |
RelationshipStrength
¶
Bases: AffinityModel
Relationship strength between internal and external persons.
Source code in affinity/models/secondary.py
502 503 504 505 506 507 | |
Reminder
¶
Bases: AffinityModel
A reminder (V2 shape). At most one of person, company, opportunity is set.
Source code in affinity/models/secondary.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
ReminderCreate
¶
Bases: AffinityModel
A reminder to create.
One-time reminders need due_date; recurring ones need reset_type and
reminder_days (1-3650; due_date optional). Attach it to exactly one of
person_id, company_id, opportunity_id.
Source code in affinity/models/secondary.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
ReminderRecurrence
¶
Bases: AffinityModel
How a recurring reminder repeats: every period_days days, reset by reset_type.
Source code in affinity/models/secondary.py
306 307 308 309 310 | |
ReminderUpdate
¶
Bases: AffinityModel
Changes to a reminder: fields left as None are not changed.
clear_content=True removes the content. is_completed=True completes the reminder
(a recurring one moves to its next due date); False reopens a one-time reminder.
Setting type sends the whole update through the V1 API (V2 can't change the type).
Source code in affinity/models/secondary.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
SavedView
¶
Bases: AffinityModel
A saved view configuration for a list.
Source code in affinity/models/entities.py
895 896 897 898 899 900 901 902 903 904 905 906 907 | |
SemanticCompany
¶
Bases: AffinityModel
A company returned by semantic search.
Source code in affinity/models/search.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
score_float: float | None
property
¶
The score as a float, or None when missing or not a number.
SemanticSearchResult
¶
Bases: AffinityModel
Semantic search response: matches plus the API's explanation of the search.
Source code in affinity/models/search.py
71 72 73 74 75 76 | |
Team
¶
Bases: AffinityModel
A team (V2).
members and accessible_lists (the first ones, up to 10, with *_total) are filled
only when requested with includes; otherwise they are None. privacy_type needs
the "Manage Teams" permission and team privacy settings; otherwise it is None.
Source code in affinity/models/org.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
TeamMember
¶
Bases: AffinityModel
A member of a team (from Team.members).
Source code in affinity/models/org.py
44 45 46 47 48 49 50 51 52 | |
Tenant
¶
Bases: AffinityModel
Affinity tenant (organization/team) information.
Source code in affinity/models/secondary.py
515 516 517 518 519 520 | |
Transcript
¶
Bases: AffinityModel
A meeting transcript.
note is the AI Notetaker note it belongs to (with interaction, the meeting).
fragments_preview holds the first fragments (only from transcripts.get(); the list
endpoint returns metadata only) and fragments_total how many there are in all; use
transcripts.fragments() / iter_fragments() for the rest.
Source code in affinity/models/transcripts.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
TranscriptFragment
¶
Bases: AffinityModel
One piece of dialogue. Timestamps are offsets from the start, e.g. "00:00:06".
Source code in affinity/models/transcripts.py
14 15 16 17 18 19 20 | |
UserAccount
¶
Bases: AffinityModel
An internal user of the organization (V2 UserData).
A user's id is also their person id: persons.get(PersonId(user.id)) works.
emails and role are filled only for callers with the "Manage Users" permission.
Source code in affinity/models/org.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
UserStatus
¶
Bases: OpenStrEnum
Whether a user's account is in use.
Source code in affinity/models/org.py
19 20 21 22 23 24 | |
Webhook
¶
Bases: AffinityModel
A webhook: event notifications delivered to an external URL (V2 webhooks.Webhook).
Source code in affinity/models/secondary.py
416 417 418 419 420 421 422 423 424 425 426 427 428 | |
WebhookCreate
¶
Bases: AffinityModel
A webhook to create.
subscriptions is required. An empty list subscribes the webhook to every event type,
so every change in the organization is sent to url; name the events you need.
Source code in affinity/models/secondary.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 | |
WebhookUpdate
¶
Bases: AffinityModel
Changes to a webhook: only the fields you set are sent.
subscriptions=[] subscribes the webhook to every event type.
Source code in affinity/models/secondary.py
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | |
WhoAmI
¶
Bases: AffinityModel
Response from whoami endpoint.
Source code in affinity/models/secondary.py
606 607 608 609 610 611 | |
FieldResolver¶
Helper for extracting field values by name from entities.
Caches field metadata internally for efficient repeated lookups.
Example
Fetch field metadata once¶
resolver = FieldResolver(client.companies.get_fields())
Use throughout your code¶
for company in companies: ... status = resolver.get(company, "Status") ... industry = resolver.get(company, "Industry") ... print(f"{company.name}: {status}, {industry}")
Source code in affinity/field_resolver.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
__init__(fields: Sequence[FieldMetadata]) -> None
¶
Create a resolver from field metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fields
|
Sequence[FieldMetadata]
|
Field metadata from client.companies.get_fields(), client.persons.get_fields(), etc. |
required |
Source code in affinity/field_resolver.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
field_names() -> list[str]
¶
Get all available field names (including source-qualified names for ambiguous fields).
Source code in affinity/field_resolver.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
find_field(field_name: str) -> FieldMetadata | None
¶
Find field metadata by name (case-insensitive).
Useful for getting the FieldId needed by write operations like
update_field_value(). Supports source-qualified names like
'dealroom:Description' for ambiguous fields.
Returns:
| Type | Description |
|---|---|
FieldMetadata | None
|
The FieldMetadata, or None if no field matches. |
Raises:
| Type | Description |
|---|---|
AmbiguousFieldError
|
If the name matches multiple fields. Use a source-qualified name or get_by_id() to disambiguate. |
Source code in affinity/field_resolver.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
get(entity: Company | Person | Opportunity | ListEntry | ListEntryWithEntity, field_name: str, *, resolve: ResolveMode = ResolveMode.RAW) -> Any
¶
Get a field value by name from an entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity
|
Company | Person | Opportunity | ListEntry | ListEntryWithEntity
|
The entity (Company, Person, Opportunity, or ListEntry) |
required |
field_name
|
str
|
The field display name (case-insensitive) |
required |
resolve
|
ResolveMode
|
ResolveMode.RAW returns extracted values as-is. ResolveMode.TEXT resolves all complex types to strings (dropdowns to text, persons to names, etc.). |
RAW
|
Returns:
| Type | Description |
|---|---|
Any
|
The extracted field value, or None if field not found or not populated. |
Example
status = resolver.get(company, "Status") print(status) # "Active"
Resolve complex types to text¶
stage = resolver.get(opportunity, "Stage", resolve=ResolveMode.TEXT) print(stage) # "Negotiation" instead of 12345
Source code in affinity/field_resolver.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
get_by_id(entity: Company | Person | Opportunity | ListEntry | ListEntryWithEntity, field_id: str | AnyFieldId, *, resolve: ResolveMode = ResolveMode.RAW) -> Any
¶
Get a field value by ID (unambiguous, for duplicate field names).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity
|
Company | Person | Opportunity | ListEntry | ListEntryWithEntity
|
The entity |
required |
field_id
|
str | AnyFieldId
|
The field ID (e.g., "field-123" or FieldId(123)) |
required |
resolve
|
ResolveMode
|
ResolveMode.RAW or ResolveMode.TEXT |
RAW
|
Returns:
| Type | Description |
|---|---|
Any
|
The extracted field value, or None if not found. |
Source code in affinity/field_resolver.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
get_many(entity: Company | Person | Opportunity | ListEntry | ListEntryWithEntity, field_names: Sequence[str], *, resolve: ResolveMode = ResolveMode.RAW) -> dict[str, Any]
¶
Get multiple field values by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity
|
Company | Person | Opportunity | ListEntry | ListEntryWithEntity
|
The entity (Company, Person, Opportunity, or ListEntry) |
required |
field_names
|
Sequence[str]
|
List of field names to extract |
required |
resolve
|
ResolveMode
|
ResolveMode.RAW or ResolveMode.TEXT |
RAW
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict mapping field_name -> value (None for missing/unpopulated fields) |
Example
values = resolver.get_many(company, ["Status", "Industry", "Size"]) print(values) {'Status': 'Active', 'Industry': 'Tech', 'Size': None}
Source code in affinity/field_resolver.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
has_field(field_name: str) -> bool
¶
Check if a field exists by name.
Supports source-qualified names like 'dealroom:Description'.
Source code in affinity/field_resolver.py
345 346 347 348 349 350 | |