{"id":23388454,"url":"https://github.com/planet-a-ventures/dlt-source-affinity","last_synced_at":"2026-06-08T21:31:55.025Z","repository":{"id":268463585,"uuid":"904252307","full_name":"planet-a-ventures/dlt-source-affinity","owner":"planet-a-ventures","description":"DLT (www.github.com/dlt-hub/dlt) Source for Affinity (www.affinity.co)","archived":false,"fork":false,"pushed_at":"2025-11-25T15:54:02.000Z","size":402,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-28T20:36:27.457Z","etag":null,"topics":["affinity","data-engineering","data-load-tool","data-loading","dlt","dlthub","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/planet-a-ventures.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-16T14:33:21.000Z","updated_at":"2025-11-25T15:54:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"26e824a2-630a-4575-8d29-8172cd9e4681","html_url":"https://github.com/planet-a-ventures/dlt-source-affinity","commit_stats":null,"previous_names":["planet-a-ventures/dlt-source-affinity"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/planet-a-ventures/dlt-source-affinity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planet-a-ventures%2Fdlt-source-affinity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planet-a-ventures%2Fdlt-source-affinity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planet-a-ventures%2Fdlt-source-affinity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planet-a-ventures%2Fdlt-source-affinity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/planet-a-ventures","download_url":"https://codeload.github.com/planet-a-ventures/dlt-source-affinity/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planet-a-ventures%2Fdlt-source-affinity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34082130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["affinity","data-engineering","data-load-tool","data-loading","dlt","dlthub","python"],"created_at":"2024-12-22T02:20:17.857Z","updated_at":"2026-06-08T21:31:55.019Z","avatar_url":"https://github.com/planet-a-ventures.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ndescription: dlt source for affinity.co\nkeywords: [Affinity API, affinity.co, CRM]\n---\n\n# dlt-source-affinity\n\n[![PyPI version](https://img.shields.io/pypi/v/dlt-source-affinity)](https://pypi.org/project/dlt-source-affinity/)\n\n[DLT](htps://www.github.com/dlt-hub/dlt) source for [Affinity](https://www.affinity.co/).\n\n\u003e If you don't know DLT but stumbled across this when trying to search if you can\n\u003e get your data out of Affinity somehow: this will do it - it basically allows\n\u003e you to pull mostly any (except some enriched) data out of your Affinity instance\n\u003e and into a different [target system (Snowflake, Postgres, etc.) that is supported\n\u003e by DLT](https://dlthub.com/docs/dlt-ecosystem/destinations/).\n\n## Usage\n\nCreate a `.dlt/secrets.toml` with your [API key](https://support.affinity.co/s/article/How-to-obtain-your-Affinity-API-key):\n\n```toml\naffinity_api_key=\"\u003cYOUR_API_KEY\u003e\"\n```\n\nand then run the default source with optional list references:\n\n```py\nfrom dlt_source_affinity import ListReference, source as affinity_source\n\npipeline = dlt.pipeline(\n   pipeline_name=\"affinity_pipeline\",\n   destination=\"duckdb\",\n   dev_mode=True,\n)\naffinity_data = affinity_source(\n   # By default the data source loads:\n   # - organizations\n   # - persons\n   # - lists\n   # - opportunities\n   # - notes\n   # And then we can optionally pass an arbitrary number of lists and list views:\n   list_refs=[\n      # Loads a list with ID 123,\n      # e.g. https://\u003cyour-subdomain\u003e.affinity.co/lists/123/\n      ListReference(123),\n      # Loads a view with ID 456 in list 123,\n      # e.g. https://\u003cyour-subdomain\u003e.affinity.co/lists/123/views/456-all-organizations\n      ListReference(123, 456),\n   ]\n)\npipeline.run(affinity_data)\n```\n\n## Resources\n\nResources that can be loaded using this verified source are:\n\n| Name | Description | API version | [Permissions](https://developer.affinity.co/#section/Getting-Started/Permissions) needed |\n| -- | -- | -- | -- |\n| [companies](https://developer.affinity.co/#tag/companies) | The stored companies | V2 | Requires the \"Export All Organizations directory\" permission. |\n| [persons](https://developer.affinity.co/#tag/persons) | The stored persons | V2 | Requires the \"Export All People directory\" permission. |\n| [opportunities](https://developer.affinity.co/#tag/opportunities) | The stored opportunities | V2 | Requires the \"Export data from Lists\" permission. |\n| [lists](https://developer.affinity.co/#tag/lists) | A given list and/or a saved view of a list | V2 | Requires the \"Export data from Lists\" permission. |\n| [notes](https://api-docs.affinity.co/#notes) | Notes attached to companies, persons, opportunities | Legacy | n/a |\n\n## V1 vs V2\n\nThere are two versions of the Affinity API:\n\n1. [Legacy](https://api-docs.affinity.co/) which is available for all plans.\n1. [V2](https://developer.affinity.co/) which is only available for customers\n   with an enterprise plan.\n\nThis verified source makes use of both API endpoints.\nThe authentication credentials for both APIs are the same, however,\nthey [differ in their authentication behavior](https://support.affinity.co/s/article/How-to-obtain-your-Affinity-API-key#h_01HMF147N699N2V6A9KPFMSBR6).\n\n## Initialize the pipeline\n\n```bash\ndlt init affinity duckdb\n```\n\nHere, we chose duckdb as the destination. Alternatively, you can also choose redshift,\nbigquery, or any of the other [destinations](https://dlthub.com/docs/dlt-ecosystem/destinations/).\n\n## Add credentials\n\n1. You'll need to [obtain your API key](https://support.affinity.co/s/article/How-to-obtain-your-Affinity-API-key)\n   and configure the pipeline with it.\n\n## Development\n\nThis project is using [devenv](https://devenv.sh/).\n\n### Run the sample\n\n```sh\nAFFINITY_API_KEY=[...] python affinity_pipeline.py\n```\n\n### Regenerate V2 model\n\nRun\n\n```sh\ngenerate-model\n```\n\n## 🚀 Development Workflow\n\n1. **Make changes** to your code\n1. **Format code** with `format` before committing\n1. **Commit changes** - pre-commit hooks will run automatically\n1. **Push to GitHub** - CI will run tests on multiple platforms\n1. **Create release** by pushing a tag (format: `vX.X.X`)\n\n## 📦 Publishing\n\nPublishing to PyPI is fully automated:\n\n1. Create a new tag: `git tag v1.0.0`\n1. Push the tag: `git push origin v1.0.0`\n1. GitHub Actions will automatically build and publish to PyPI\n\nThe project uses trusted publishing, so no API keys are required.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanet-a-ventures%2Fdlt-source-affinity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplanet-a-ventures%2Fdlt-source-affinity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanet-a-ventures%2Fdlt-source-affinity/lists"}