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
The list_size field was removed in v0.13.0 because the V2 API returns
incorrect values (often 0 for non-empty lists). Use
client.lists.get_size(list_id) to get accurate list size via V1 API.
Source code in affinity/models/entities.py
542 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 | |
model_post_init(__context: Any) -> None
¶
Transfer list_size_temp to _list_size_hint private attr.
Source code in affinity/models/entities.py
591 592 593 594 595 596 | |
AffinityModel
¶
Bases: BaseModel
Base model with common configuration.
Source code in affinity/models/entities.py
46 47 48 49 50 51 52 53 54 | |
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
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 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 | |
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
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 | |
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
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 | |
BatchOperationResponse
¶
Bases: AffinityModel
Response from batch field operations.
Source code in affinity/models/pagination.py
532 533 534 535 536 537 538 539 540 541 542 543 | |
BatchOperationResult
¶
Bases: AffinityModel
Result of a single operation in a batch.
Source code in affinity/models/pagination.py
524 525 526 527 528 529 | |
Company
¶
Bases: AffinityModel
Full company representation.
Note: Called Organization in V1 API.
Source code in affinity/models/entities.py
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 | |
CompanyCreate
¶
Bases: AffinityModel
Data for creating a new company (V1 API).
Source code in affinity/models/entities.py
433 434 435 436 437 438 | |
CompanyUpdate
¶
Bases: AffinityModel
Data for updating a company (V1 API).
Source code in affinity/models/entities.py
441 442 443 444 445 446 | |
DropdownOption
¶
Bases: AffinityModel
A selectable option in a dropdown field.
Source code in affinity/models/entities.py
238 239 240 241 242 243 244 | |
EntityFile
¶
Bases: AffinityModel
A file attached to an entity.
Source code in affinity/models/secondary.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
FieldCreate
¶
Bases: AffinityModel
Data for creating a new field (V1 API).
Source code in affinity/models/entities.py
837 838 839 840 841 842 843 844 845 846 847 848 | |
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
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 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 | |
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
856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 | |
FieldValueChange
¶
Bases: AffinityModel
Historical change to a field value.
Source code in affinity/models/entities.py
896 897 898 899 900 901 902 903 904 905 906 | |
FieldValueCreate
¶
Bases: AffinityModel
Data for creating a field value (V1 API).
Source code in affinity/models/entities.py
876 877 878 879 880 881 882 | |
Grant
¶
Bases: AffinityModel
API key grant information.
Source code in affinity/models/secondary.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
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
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 | |
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
157 158 159 160 161 162 163 164 165 166 167 168 169 | |
InteractionUpdate
¶
Bases: AffinityModel
Data for updating an interaction (V1 API).
Source code in affinity/models/secondary.py
172 173 174 175 176 177 178 | |
ListCreate
¶
Bases: AffinityModel
Data for creating a new list (V1 API).
Source code in affinity/models/entities.py
619 620 621 622 623 624 625 626 | |
ListEntry
¶
Bases: AffinityModel
A row in a list, linking an entity to a list.
Contains the entity data and list-specific field values.
Source code in affinity/models/entities.py
634 635 636 637 638 639 640 641 642 643 644 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 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 | |
ListEntryCreate
¶
Bases: AffinityModel
Data for adding an entity to a list (V1 API).
Source code in affinity/models/entities.py
747 748 749 750 751 | |
ListEntryWithEntity
¶
Bases: AffinityModel
List entry with full entity data included (V2 response format).
Source code in affinity/models/entities.py
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 | |
ListPermission
¶
Bases: AffinityModel
Additional permission on a list.
Source code in affinity/models/entities.py
535 536 537 538 539 | |
ListSummary
¶
Bases: AffinityModel
Minimal list reference used by relationship endpoints.
Source code in affinity/models/entities.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | |
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
40 41 42 43 44 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 | |
NoteCreate
¶
Bases: AffinityModel
Data for creating a new note (V1 API).
Source code in affinity/models/secondary.py
75 76 77 78 79 80 81 82 83 84 85 | |
NoteUpdate
¶
Bases: AffinityModel
Data for updating a note (V1 API).
Source code in affinity/models/secondary.py
88 89 90 91 | |
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
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 | |
OpportunityCreate
¶
Bases: AffinityModel
Data for creating a new opportunity (V1 API).
Source code in affinity/models/entities.py
501 502 503 504 505 506 507 | |
OpportunitySummary
¶
Bases: AffinityModel
Minimal opportunity data returned in nested contexts.
Source code in affinity/models/entities.py
523 524 525 526 527 | |
OpportunityUpdate
¶
Bases: AffinityModel
Data for updating an opportunity (V1 API).
Source code in affinity/models/entities.py
510 511 512 513 514 515 | |
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
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 | |
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
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 | |
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
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 | |
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 | |
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.
__len__() -> int
¶
Number of items in current page.
Source code in affinity/models/pagination.py
122 123 124 | |
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
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 | |
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
344 345 346 347 348 349 350 351 352 353 354 355 356 | |
PersonUpdate
¶
Bases: AffinityModel
Data for updating a person (V1 API).
Source code in affinity/models/entities.py
359 360 361 362 363 364 365 | |
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
377 378 379 380 381 382 383 | |
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
386 387 388 389 390 | |
RelationshipStrength
¶
Bases: AffinityModel
Relationship strength between internal and external persons.
Source code in affinity/models/secondary.py
303 304 305 306 307 308 | |
Reminder
¶
Bases: AffinityModel
A reminder attached to an entity.
Source code in affinity/models/secondary.py
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 | |
ReminderCreate
¶
Bases: AffinityModel
Data for creating a reminder (V1 API).
Source code in affinity/models/secondary.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
ReminderUpdate
¶
Bases: AffinityModel
Data for updating a reminder (V1 API).
Source code in affinity/models/secondary.py
230 231 232 233 234 235 236 237 238 239 | |
SavedView
¶
Bases: AffinityModel
A saved view configuration for a list.
Source code in affinity/models/entities.py
759 760 761 762 763 764 765 766 767 768 769 770 771 | |
Tenant
¶
Bases: AffinityModel
Affinity tenant (organization/team) information.
Source code in affinity/models/secondary.py
316 317 318 319 320 321 | |
WebhookCreate
¶
Bases: AffinityModel
Data for creating a webhook subscription (V1 API).
Source code in affinity/models/secondary.py
257 258 259 260 261 | |
WebhookSubscription
¶
Bases: AffinityModel
A webhook subscription for real-time events.
Source code in affinity/models/secondary.py
247 248 249 250 251 252 253 254 | |
WebhookUpdate
¶
Bases: AffinityModel
Data for updating a webhook subscription (V1 API).
Source code in affinity/models/secondary.py
264 265 266 267 268 269 | |
WhoAmI
¶
Bases: AffinityModel
Response from whoami endpoint.
Source code in affinity/models/secondary.py
364 365 366 367 368 369 | |
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
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 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 | |
__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
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 | |
field_names() -> list[str]
¶
Get all available field names (including source-qualified names for ambiguous fields).
Source code in affinity/field_resolver.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
get(entity: Company | Person | Opportunity | 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 | 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
73 74 75 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 | |
get_by_id(entity: Company | Person | Opportunity | 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 | 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
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 | |
get_many(entity: Company | Person | Opportunity | 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 | 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
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
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
282 283 284 285 286 287 | |