{"id":18777750,"url":"https://github.com/planet-a-ventures/affinity-node","last_synced_at":"2025-07-29T02:33:56.565Z","repository":{"id":242875424,"uuid":"803734222","full_name":"planet-a-ventures/affinity-node","owner":"planet-a-ventures","description":"Node module for Affinity (www.affinity.co)","archived":false,"fork":false,"pushed_at":"2025-07-06T01:14:37.000Z","size":1014,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-06T02:26:13.907Z","etag":null,"topics":["affinity","node","npm"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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}},"created_at":"2024-05-21T09:35:35.000Z","updated_at":"2025-03-12T22:52:50.000Z","dependencies_parsed_at":"2024-06-27T18:21:07.985Z","dependency_job_id":"8a7dfe01-272f-4cfc-aacd-6f973f57ce93","html_url":"https://github.com/planet-a-ventures/affinity-node","commit_stats":null,"previous_names":["planet-a-ventures/affinity-node"],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/planet-a-ventures/affinity-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planet-a-ventures%2Faffinity-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planet-a-ventures%2Faffinity-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planet-a-ventures%2Faffinity-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planet-a-ventures%2Faffinity-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/planet-a-ventures","download_url":"https://codeload.github.com/planet-a-ventures/affinity-node/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planet-a-ventures%2Faffinity-node/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267618700,"owners_count":24116431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"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","node","npm"],"created_at":"2024-11-07T20:13:42.377Z","updated_at":"2025-07-29T02:33:56.519Z","avatar_url":"https://github.com/planet-a-ventures.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [![Test, Lint \u0026 Deploy](https://github.com/planet-a-ventures/affinity-node/actions/workflows/main.yml/badge.svg)](https://github.com/planet-a-ventures/affinity-node/actions/workflows/main.yml) [![NPM Version](https://img.shields.io/npm/v/%40planet-a%2Faffinity-node)](https://www.npmjs.com/package/@planet-a/affinity-node) affinity-node\n\nNode module for the [Affinity](https://www.affinity.co/) CRM.\n\nSupports both V1 and V2 of the Affinity API.\n\n\u003e This module is [incomplete](#api-completeness) for V1; not all API endpoints\n\u003e are implemented. It is in active development and the API might change without\n\u003e notice. Contributions welcome.\n\n## Usage\n\n```js\nimport { Affinity } from '@planet-a/affinity-node/v1'\n\nconst { user } = await new Affinity(YOUR_API_KEY).auth.whoAmI()\nconsole.log(`Hello ${user.firstName}`)\n```\n\nHave a look at the\n[autogenerated docs](https://planet-a-ventures.github.io/affinity-node/) for\nexamples, etc.\n\n## API completeness\n\n### V1\n\n- ✅ [Lists](src/v1/lists.ts)\n- ✅ [List Entries](src/v1/list_entries.ts)\n- ✅ [Fields](src/v1/fields.ts)\n- ✅ [Field Values](src/v1/field_values.ts)\n- ✅ [Field Value Changes](src/v1/field_value_changes.ts)\n- ✅ [Persons](src/v1/persons.ts)\n- ✅ [Organizations](src/v1/organizations.ts)\n- ❌ [Opportunities](src/v1/opportunities.ts)\n- ❌ Interactions\n- ❌ Relationship Strengths\n- ✅ [Notes](src/v1/notes.ts)\n- ✅ [Entity Files](src/v1/entity_files.ts)\n- ❌ Reminders\n- ❌ Webhooks\n- ✅ [Whoami](src/v1/auth.ts)\n- ✅ [Rate Limit](src/v1/rate_limit.ts)\n\n### V2\n\n[V2](https://developer.affinity.co/docs/v2/) is generated via\n[OpenAPITools/openapi-generator](https://github.com/OpenAPITools/openapi-generator).\n\nThe command:\n\n```sh\nnix develop --command deno task generate-v2-client\n```\n\nwill generate an OpenAPI client for Node in Typescript.\n\nSample usage:\n\n```ts\nimport { AuthApi, createConfiguration } from '@planet-a/affinity-node/v2'\n\nconst config = createConfiguration({\n    authMethods: {\n        bearerAuth: {\n            tokenProvider: {\n                getToken: async () =\u003e Promise.resolve('API_KEY'),\n            },\n        },\n    },\n})\nconst authApi = new ObjectAuthApi(config)\nconst { tenant } = await authApi.getV2AuthWhoami()\nconsole.log(tenant.name)\n```\n\nAn up-to-date OpenAPI spec can be downloaded from\n[here](https://developer.affinity.co/docs/v2/#section/Introduction). Drop it\ninto `./openapi` before you run the command above (remove the old version\nbeforehand).\n\n#### Paging\n\nThis module comes with a pagination helper for the V2 API. Sample usage:\n\n```ts\nimport { CompaniesApi, helpers } from '@planet-a/affinity-node/v2'\nconst { paginator: { paginated } } = helpers\n\nconst companiesApi = new CompaniesApi(config)\n\nfor await (\n    const page of paginated(\n        companiesApi.getV2Companies.bind(companiesApi),\n    )({\n        limit: 10,\n    })\n) {\n    // Fetch 10 companies at a time, print, repeat\n    console.log(page)\n}\n```\n\n## Similar projects\n\n- [AffinityPython](https://github.com/JustinStals/AffinityPython)\n\n## Development\n\n\u003e Note on deno: This repository is using [Deno](https://deno.com/) heavily for\n\u003e anything dev-related. The resulting node package is meant to be agnostic of\n\u003e the runtime used, so there shouldn't be any deno-specific references. For the\n\u003e tests, etc. Deno-specific APIs, libraries and imports may be used.\n\n1. Install [nix](https://nixos.org/)\n1. Run `nix develop`\n1. Run any deno task, e.g. `deno task test`\n\n\u003e Hint: you can do a live run via\n\u003e `API_KEY=\u003cyour-api-key\u003e deno task snapshot-update` to update snapshots from\n\u003e your actual Affinity instance during development.\n\u003e\n\u003e ⚠️ Make sure you do not commit any unsanitized data.\n\n### Direnv\n\nThis repo is [direnv](https://direnv.net/)-enabled. If you have Nix and direnv\non your system, you can ignore any `nix develop --command` prefixes and just\nwork in the folder as if you were inside the nix flake environment. This is the\nrecommended way, as it greatly simplifies the handling of dev tasks and\npre-commit checks.\n\n### Commands\n\n#### Build the library\n\n1. `nix develop --command deno task build`\n\n#### Run tests with coverage\n\n1. `nix develop --command deno task test:coverage`\n\n#### Format code\n\n1. `nix develop --command deno task format`\n\n#### Lint code\n\n1. `nix develop --command deno task lint`\n\n#### Generate documentation\n\n1. `nix develop --command deno task docs`\n2. `open ./docs/index.html`\n\n### Style\n\n- File names are `snake_case`\n- Symbols are `camelCase`\n- Symbols inherited from the Affinity API documentation, such as path and query\n  parameters adopt the API documentation style, `snake_case`\n- Enum values are `SNAKE_UPPERCASE`\n\n### Commits\n\nThis repo follows the\n[conventional commits](https://www.conventionalcommits.org/) format. Run\n`nix develop --command cz commit` after staging some changes to be guided\nthrough the process if you're unfamiliar with it.\n\n### Pre commit hooks\n\nPre-commit hooks are managed by Nix. Once you run your commit, it will analyze\nthe changes and run required hooks.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanet-a-ventures%2Faffinity-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplanet-a-ventures%2Faffinity-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanet-a-ventures%2Faffinity-node/lists"}