A DLT source for the Affinity CRM
Project description
description: dlt source for affinity.co keywords: [Affinity API, affinity.co, CRM]
dlt-source-affinity
If you don't know DLT but stumbled across this when trying to search if you can get your data out of Affinity somehow: this will do it - it basically allows you to pull mostly any (except some enriched) data out of your Affinity instance and into a different target system (Snowflake, Postgres, etc.) that is supported by DLT.
Usage
Create a .dlt/secrets.toml with your API key:
affinity_api_key="<YOUR_API_KEY>"
and then run the default source with optional list references:
from dlt_source_affinity import ListReference, source as affinity_source
pipeline = dlt.pipeline(
pipeline_name="affinity_pipeline",
destination="duckdb",
dev_mode=True,
)
affinity_data = affinity_source(
# By default the data source loads:
# - organizations
# - persons
# - lists
# - opportunities
# - notes
# And then we can optionally pass an arbitrary number of lists and list views:
list_refs=[
# Loads a list with ID 123,
# e.g. https://<your-subdomain>.affinity.co/lists/123/
ListReference(123),
# Loads a view with ID 456 in list 123,
# e.g. https://<your-subdomain>.affinity.co/lists/123/views/456-all-organizations
ListReference(123, 456),
]
)
pipeline.run(affinity_data)
Resources
Resources that can be loaded using this verified source are:
| Name | Description | API version | Permissions needed |
|---|---|---|---|
| companies | The stored companies | V2 | Requires the "Export All Organizations directory" permission. |
| persons | The stored persons | V2 | Requires the "Export All People directory" permission. |
| opportunities | The stored opportunities | V2 | Requires the "Export data from Lists" permission. |
| lists | A given list and/or a saved view of a list | V2 | Requires the "Export data from Lists" permission. |
| notes | Notes attached to companies, persons, opportunities | Legacy | n/a |
V1 vs V2
There are two versions of the Affinity API:
- Legacy which is available for all plans.
- V2 which is only available for customers with an enterprise plan.
This verified source makes use of both API endpoints. The authentication credentials for both APIs are the same, however, they differ in their authentication behavior.
Initialize the pipeline
dlt init affinity duckdb
Here, we chose duckdb as the destination. Alternatively, you can also choose redshift, bigquery, or any of the other destinations.
Add credentials
- You'll need to obtain your API key and configure the pipeline with it.
Development
This project is using devenv.
Run the sample
AFFINITY_API_KEY=[...] python affinity_pipeline.py
Regenerate V2 model
Run
generate-model
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dlt_source_affinity-0.1.2.tar.gz.
File metadata
- Download URL: dlt_source_affinity-0.1.2.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
210d91c84d2d8f5d5d9c5edfe49d745b9189117d8056ae1bd10c8715fe61b474
|
|
| MD5 |
5c3bd7a75f172adbd275c884c1eafc6e
|
|
| BLAKE2b-256 |
88fecfb7f8686a7b441d0a61632e2c201d5bc9a107832ed297eb809e070c37e0
|
Provenance
The following attestation bundles were made for dlt_source_affinity-0.1.2.tar.gz:
Publisher:
test.yml on planet-a-ventures/dlt-source-affinity
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dlt_source_affinity-0.1.2.tar.gz -
Subject digest:
210d91c84d2d8f5d5d9c5edfe49d745b9189117d8056ae1bd10c8715fe61b474 - Sigstore transparency entry: 162948348
- Sigstore integration time:
-
Permalink:
planet-a-ventures/dlt-source-affinity@7ee6523d09bc8cb48e77af775d893fd924599cca -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/planet-a-ventures
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@7ee6523d09bc8cb48e77af775d893fd924599cca -
Trigger Event:
push
-
Statement type:
File details
Details for the file dlt_source_affinity-0.1.2-py3-none-any.whl.
File metadata
- Download URL: dlt_source_affinity-0.1.2-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20a55a24566aa92373b53092673fb5cecc81669e0001fbe09dfe40090517d7ba
|
|
| MD5 |
3380a978f995c14a5ba1be0bdf259f62
|
|
| BLAKE2b-256 |
603cfaa023500f95da361ca3c19566cd5368e183c709c31f6b053f04b0ac732a
|
Provenance
The following attestation bundles were made for dlt_source_affinity-0.1.2-py3-none-any.whl:
Publisher:
test.yml on planet-a-ventures/dlt-source-affinity
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dlt_source_affinity-0.1.2-py3-none-any.whl -
Subject digest:
20a55a24566aa92373b53092673fb5cecc81669e0001fbe09dfe40090517d7ba - Sigstore transparency entry: 162948350
- Sigstore integration time:
-
Permalink:
planet-a-ventures/dlt-source-affinity@7ee6523d09bc8cb48e77af775d893fd924599cca -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/planet-a-ventures
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@7ee6523d09bc8cb48e77af775d893fd924599cca -
Trigger Event:
push
-
Statement type: