|
| 1 | +--- |
| 2 | +name: pipedrive-api |
| 3 | +description: Guide developers on using the Pipedrive REST API v1 within their integration project. Use when a developer wants to query or mutate Pipedrive data (deals, persons, organizations, leads, activities, etc.) from their app. |
| 4 | +allowed-tools: [Read, Edit, Bash] |
| 5 | +--- |
| 6 | + |
| 7 | +# Using the Pipedrive API |
| 8 | + |
| 9 | +## Overview |
| 10 | + |
| 11 | +The Pipedrive REST API v1 base URL is `https://api.pipedrive.com/v1`. It is stateless and returns JSON. Full reference: https://developers.pipedrive.com/docs/api/v1 |
| 12 | + |
| 13 | +## Authentication in this project |
| 14 | + |
| 15 | +This project uses **OAuth 2.0**. After a user authorises your app, the access token is stored in the database (`pipedrive_tokens` table). The generated `src/pipedrive-client/` module handles token retrieval and client initialisation: |
| 16 | + |
| 17 | +```ts |
| 18 | +import { getClient } from './pipedrive/client.js'; |
| 19 | + |
| 20 | +const client = await getClient(companyId); |
| 21 | +``` |
| 22 | + |
| 23 | +Use `client` to call the official Pipedrive Node.js SDK (`pipedrive` npm package), which maps directly to the REST API. |
| 24 | + |
| 25 | +## Main resource categories |
| 26 | + |
| 27 | +| Category | Resources | |
| 28 | +|----------|-----------| |
| 29 | +| CRM core | Deals, Persons, Organizations, Activities, Notes | |
| 30 | +| Lead management | Leads, Lead Fields, Lead Labels | |
| 31 | +| Sales | Pipelines, Stages, Products, Goals | |
| 32 | +| Communication | Webhooks, Call Logs, Mailbox | |
| 33 | +| Admin | Users, Roles, Permission Sets | |
| 34 | + |
| 35 | +## Common usage patterns |
| 36 | + |
| 37 | +**List deals:** |
| 38 | +```ts |
| 39 | +const deals = await client.deals.getDeals({ limit: 50 }); |
| 40 | +``` |
| 41 | + |
| 42 | +**Get a person:** |
| 43 | +```ts |
| 44 | +const person = await client.persons.getPerson({ id: personId }); |
| 45 | +``` |
| 46 | + |
| 47 | +**Create an activity:** |
| 48 | +```ts |
| 49 | +await client.activities.addActivity({ |
| 50 | + subject: 'Follow-up call', |
| 51 | + type: 'call', |
| 52 | + due_date: '2026-06-01', |
| 53 | +}); |
| 54 | +``` |
| 55 | + |
| 56 | +## Adding a new API call |
| 57 | + |
| 58 | +1. Read `src/pipedrive-client/` to understand the existing wrapper pattern |
| 59 | +2. Use `client.<resource>.<method>()` following the SDK method names |
| 60 | +3. Handle token expiry — the client wrapper in this project manages token refresh automatically |
| 61 | + |
| 62 | +## Rate limits and pagination |
| 63 | + |
| 64 | +- Rate limits apply per API token / OAuth token — check response headers for `X-RateLimit-*` values |
| 65 | +- Paginate large result sets using the `start` and `limit` query parameters |
| 66 | +- The SDK returns a `data` array and `additional_data.pagination` object for paginated resources |
| 67 | + |
| 68 | +## Further reading |
| 69 | + |
| 70 | +- API reference: https://developers.pipedrive.com/docs/api/v1 |
| 71 | +- Node.js SDK: https://github.com/pipedrive/client-nodejs |
| 72 | +- OAuth guide: https://pipedrive.readme.io/docs/marketplace-oauth-authorization |
0 commit comments