@graph8/sdk 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,281 @@
1
+ # graph8
2
+
3
+ The most comprehensive GTM SDK. One `npm install`. Every graph8 capability.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install graph8
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### Client-side (write key)
14
+
15
+ ```typescript
16
+ import { g8 } from 'graph8';
17
+
18
+ g8.init({ writeKey: 'YOUR_WRITE_KEY' });
19
+
20
+ // Track events
21
+ g8.track('signup', { plan: 'pro' });
22
+
23
+ // Identify users
24
+ g8.identify('user@acme.com', { name: 'John', company: 'Acme' });
25
+
26
+ // Identify visitor's company from IP
27
+ const visitor = await g8.visitors.identify();
28
+ // { company_name: 'Acme Corp', industry: 'SaaS', employee_count: '200-500' }
29
+
30
+ // Listen for high-intent visitors
31
+ g8.visitors.onIntent('high', (visitor) => {
32
+ showCTABanner(`${visitor.company_name} is checking us out!`);
33
+ });
34
+
35
+ // Open AI copilot
36
+ g8.copilot.open({ greeting: 'How can I help?' });
37
+
38
+ // Open webchat
39
+ g8.chat.open();
40
+
41
+ // Show booking widget
42
+ g8.calendar.show({ username: 'thomas', eventType: 'demo-30min' });
43
+
44
+ // Progressive form enrichment
45
+ const known = await g8.forms.lookup('user@acme.com');
46
+ // { found: true, known_fields: { name: 'John' }, missing_fields: ['phone'] }
47
+ ```
48
+
49
+ ### Server-side (API key)
50
+
51
+ ```typescript
52
+ import { g8 } from 'graph8';
53
+
54
+ g8.init({ apiKey: 'YOUR_API_KEY' });
55
+
56
+ // Contacts CRUD
57
+ const { data: contacts } = await g8.contacts.list({ company_name: 'Acme', limit: 10 });
58
+ const contact = await g8.contacts.create({ work_email: 'jane@acme.com', first_name: 'Jane' });
59
+ await g8.contacts.update(contact.id, { job_title: 'VP Sales' });
60
+
61
+ // Companies
62
+ const { data: companies } = await g8.companies.list({ industry: 'SaaS' });
63
+ const { data: teamContacts } = await g8.companies.contacts(companies[0].id);
64
+
65
+ // Lists
66
+ const list = await g8.lists.create('Q2 Outbound', 'contacts');
67
+ await g8.lists.addContacts(list.id, [contact.id]);
68
+ const { data: listContacts } = await g8.lists.contacts(list.id);
69
+
70
+ // Enrich a person
71
+ const person = await g8.enrich.person({ email: 'jane@acme.com' });
72
+
73
+ // Search 300M+ contacts
74
+ const leads = await g8.enrich.search([
75
+ { field: 'seniority_level', operator: 'any_of', value: ['VP', 'Director'] },
76
+ { field: 'company_industry', operator: 'contains', value: ['SaaS'] },
77
+ ]);
78
+
79
+ // List sequences and add contacts
80
+ const sequences = await g8.sequences.list();
81
+ await g8.sequences.add({ sequenceId: sequences[0].id, contactIds: [123], listId: 637 });
82
+
83
+ // Campaign management
84
+ const campaign = await g8.campaigns.create({ name: 'Q2 Push', category: 'Outbound' });
85
+ await g8.campaigns.launch(campaign.id);
86
+
87
+ // Intent signals
88
+ const signals = await g8.signals.company('acme.com');
89
+ // { score: 87, intent: 'high', signals: ['pricing_page_3x', 'case_study'] }
90
+
91
+ // Voice AI
92
+ const call = await g8.voice.start({ agent: 'sales-discovery', contactId: 123 });
93
+ const analysis = await g8.voice.analysis(call.id);
94
+
95
+ // Landing pages
96
+ const page = await g8.pages.clone('https://competitor.com/pricing');
97
+ const { url } = await g8.pages.publish(page.id);
98
+
99
+ // Webhook events
100
+ g8.webhooks.on('reply_received', (event) => {
101
+ slack.send(`${event.contact} replied!`);
102
+ });
103
+ ```
104
+
105
+ ### React / Next.js
106
+
107
+ ```tsx
108
+ import { G8Provider, useG8 } from 'graph8/react';
109
+
110
+ // Layout
111
+ <G8Provider writeKey="YOUR_WRITE_KEY"><App /></G8Provider>
112
+
113
+ // Any component
114
+ const { track, identify, visitors, copilot, calendar } = useG8();
115
+ ```
116
+
117
+ ## Full API Reference
118
+
119
+ ### Core (write key)
120
+
121
+ | Method | Description |
122
+ |--------|-------------|
123
+ | `g8.init(config)` | Initialize SDK |
124
+ | `g8.track(event, props?)` | Track event |
125
+ | `g8.identify(userId, props?)` | Identify user |
126
+ | `g8.page(props?)` | Track page view |
127
+ | `g8.reset()` | Clear identity |
128
+
129
+ ### Contacts (API key)
130
+
131
+ | Method | Description |
132
+ |--------|-------------|
133
+ | `g8.contacts.list(params?)` | List contacts with filters |
134
+ | `g8.contacts.get(id)` | Get contact by ID |
135
+ | `g8.contacts.create(contact)` | Create a contact |
136
+ | `g8.contacts.update(id, fields)` | Update contact (partial) |
137
+ | `g8.contacts.delete(id)` | Delete contact |
138
+
139
+ ### Companies (API key)
140
+
141
+ | Method | Description |
142
+ |--------|-------------|
143
+ | `g8.companies.list(params?)` | List companies with filters |
144
+ | `g8.companies.get(id)` | Get company by ID |
145
+ | `g8.companies.contacts(id)` | Get company's contacts |
146
+ | `g8.companies.update(id, fields)` | Update company (partial) |
147
+ | `g8.companies.delete(id)` | Delete company |
148
+
149
+ ### Lists (API key)
150
+
151
+ | Method | Description |
152
+ |--------|-------------|
153
+ | `g8.lists.list(page?, limit?)` | List all lists |
154
+ | `g8.lists.create(title, type?)` | Create a list |
155
+ | `g8.lists.delete(id)` | Delete a list |
156
+ | `g8.lists.contacts(id, page?, limit?)` | Get contacts in list |
157
+ | `g8.lists.addContacts(id, contactIds)` | Add contacts to list |
158
+ | `g8.lists.removeContacts(id, contactIds)` | Remove contacts from list |
159
+
160
+ ### Visitor Intelligence (write key)
161
+
162
+ | Method | Description |
163
+ |--------|-------------|
164
+ | `g8.visitors.identify()` | IP to company resolution |
165
+ | `g8.visitors.score()` | Engagement score |
166
+ | `g8.visitors.onIntent(level, cb)` | Real-time intent listener |
167
+
168
+ ### Forms (write key)
169
+
170
+ | Method | Description |
171
+ |--------|-------------|
172
+ | `g8.forms.lookup(email)` | Progressive form enrichment |
173
+
174
+ ### Copilot (write key)
175
+
176
+ | Method | Description |
177
+ |--------|-------------|
178
+ | `g8.copilot.open(config?)` | Open AI assistant widget |
179
+ | `g8.copilot.ask(message)` | Send message programmatically |
180
+ | `g8.copilot.registerAction(name, fn)` | Register custom action |
181
+ | `g8.copilot.close()` | Close widget |
182
+
183
+ ### Webchat (write key)
184
+
185
+ | Method | Description |
186
+ |--------|-------------|
187
+ | `g8.chat.open(config?)` | Open chat widget |
188
+ | `g8.chat.send(message)` | Send message |
189
+ | `g8.chat.on(event, cb)` | Listen for events |
190
+ | `g8.chat.close()` | Close widget |
191
+
192
+ ### Calendar (write key)
193
+
194
+ | Method | Description |
195
+ |--------|-------------|
196
+ | `g8.calendar.show(config)` | Show booking modal |
197
+ | `g8.calendar.embed(selector, config)` | Inline embed |
198
+ | `g8.calendar.slots(user, slug, range)` | Get available slots |
199
+ | `g8.calendar.book(request)` | Book programmatically |
200
+
201
+ ### Enrichment (API key)
202
+
203
+ | Method | Description |
204
+ |--------|-------------|
205
+ | `g8.enrich.person(params)` | Look up a person (1 credit) |
206
+ | `g8.enrich.company(params)` | Look up a company (1 credit) |
207
+ | `g8.enrich.verifyEmail(email)` | Verify email (1 credit) |
208
+ | `g8.enrich.search(filters)` | Search 300M+ contacts |
209
+
210
+ ### Sequences (API key)
211
+
212
+ | Method | Description |
213
+ |--------|-------------|
214
+ | `g8.sequences.list()` | List sequences |
215
+ | `g8.sequences.add(config)` | Add contacts to sequence |
216
+
217
+ ### Campaigns (API key)
218
+
219
+ | Method | Description |
220
+ |--------|-------------|
221
+ | `g8.campaigns.list()` | List campaigns |
222
+ | `g8.campaigns.create(config)` | Create campaign |
223
+ | `g8.campaigns.launch(id)` | Launch campaign |
224
+ | `g8.campaigns.stats(id)` | Get campaign stats |
225
+
226
+ ### Signals (write key or API key)
227
+
228
+ | Method | Description |
229
+ |--------|-------------|
230
+ | `g8.signals.company(domain)` | Get intent signals |
231
+ | `g8.signals.stream(domains, cb)` | Stream signals (polls 30s) |
232
+
233
+ ### Analytics (API key)
234
+
235
+ | Method | Description |
236
+ |--------|-------------|
237
+ | `g8.analytics.overview(config?)` | Dashboard metrics |
238
+
239
+ ### Integrations (API key)
240
+
241
+ | Method | Description |
242
+ |--------|-------------|
243
+ | `g8.integrations.list()` | List connected CRMs |
244
+ | `g8.integrations.connect(provider)` | Connect CRM |
245
+ | `g8.integrations.sync(provider)` | Trigger sync |
246
+
247
+ ### Voice AI (API key)
248
+
249
+ | Method | Description |
250
+ |--------|-------------|
251
+ | `g8.voice.start(config)` | Start AI voice call |
252
+ | `g8.voice.analysis(sessionId)` | Get call analysis |
253
+
254
+ ### Landing Pages (API key)
255
+
256
+ | Method | Description |
257
+ |--------|-------------|
258
+ | `g8.pages.clone(url)` | Clone from URL |
259
+ | `g8.pages.create(config)` | Create from template |
260
+ | `g8.pages.publish(id)` | Publish to CDN |
261
+
262
+ ### Webhooks (API key)
263
+
264
+ | Method | Description |
265
+ |--------|-------------|
266
+ | `g8.webhooks.on(event, cb)` | Listen for events |
267
+ | `g8.webhooks.stop()` | Stop all listeners |
268
+
269
+ ## Auth Modes
270
+
271
+ | Mode | Key | Use case |
272
+ |------|-----|----------|
273
+ | **Client-side** | `writeKey` | Browser apps - tracking, visitor ID, widgets |
274
+ | **Server-side** | `apiKey` | Node.js - enrichment, sequences, campaigns, CRM |
275
+ | **Both** | `writeKey` + `apiKey` | Full access |
276
+
277
+ Get your API key at [app.graph8.com/settings](https://app.graph8.com/settings) under MCP & API > API.
278
+
279
+ ## License
280
+
281
+ MIT