meta-cloud-api 2.2.0 → 2.3.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 +96 -59
- package/dist/index.d.ts +879 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +686 -9
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +16 -17
package/README.md
CHANGED
|
@@ -1,69 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="public/README.svg" alt="meta-cloud-api" width="120">
|
|
3
|
+
<h1>meta-cloud-api</h1>
|
|
4
|
+
<p><strong>WhatsApp TypeScript SDK</strong> — type-safe, modular, and production-ready.</p>
|
|
5
|
+
<p>The complete SDK for the official <a href="https://developers.facebook.com/docs/whatsapp/cloud-api">WhatsApp Business Platform Cloud API</a>.</p>
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/meta-cloud-api)
|
|
8
|
+
[](https://www.npmjs.com/package/meta-cloud-api)
|
|
9
|
+
[](https://github.com/froggy1014/meta-cloud-api/blob/main/LICENSE)
|
|
10
|
+
[](https://www.typescriptlang.org/)
|
|
11
|
+
|
|
12
|
+
<p><a href="https://meta-cloud-api.site/">Docs</a> · <a href="https://playground.meta-cloud-api.site/">Playground</a> · <a href="https://meta-cloud-api.site/getting-started/installation">Getting Started</a></p>
|
|
2
13
|
|
|
3
|
-
<div style="display: flex; align-items: center;">
|
|
4
|
-
<img src="public/README.svg" alt="Meta Cloud API" style="flex: 1; width: 100px;">
|
|
5
|
-
<div style="flex: 1; padding-left: 20px;">
|
|
6
|
-
<p>Meta Cloud API - A powerful TypeScript wrapper for Meta's Cloud API, providing a clean and type-safe interface for WhatsApp Business Platform integration.</p>
|
|
7
|
-
</div>
|
|
8
14
|
</div>
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
[](https://www.npmjs.com/package/meta-cloud-api)
|
|
12
|
-
[](https://github.com/froggy1014/meta-cloud-api/blob/main/LICENSE)
|
|
16
|
+
## Quick Start
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add meta-cloud-api
|
|
20
|
+
```
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- **[📖 API Reference](https://www.meta-cloud-api.xyz/api/messages)** - Comprehensive API documentation
|
|
19
|
-
- **[🔧 Examples](./examples/)** - Production-ready code examples
|
|
22
|
+
```typescript
|
|
23
|
+
import WhatsApp from 'meta-cloud-api';
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
const wa = new WhatsApp({
|
|
26
|
+
accessToken: process.env.CLOUD_API_ACCESS_TOKEN,
|
|
27
|
+
phoneNumberId: process.env.WA_PHONE_NUMBER_ID,
|
|
28
|
+
});
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- **[nextjs-app-router-example](./examples/nextjs-app-router-example/)** - Next.js App Router integration
|
|
26
|
-
- **[nextjs-page-router-example](./examples/nextjs-page-router-example/)** - Next.js Pages Router integration
|
|
27
|
-
|
|
28
|
-
## Local API Docs
|
|
29
|
-
|
|
30
|
-
- [Messages](./docs/messages.md)
|
|
31
|
-
- [Media](./docs/media.md)
|
|
32
|
-
- [Templates](./docs/templates.md)
|
|
33
|
-
- [Flows](./docs/flows.md)
|
|
34
|
-
- [Phone Numbers](./docs/phone-numbers.md)
|
|
35
|
-
- [Business Profile](./docs/business-profile.md)
|
|
36
|
-
- [Registration](./docs/registration.md)
|
|
37
|
-
- [Two-Step Verification](./docs/two-step-verification.md)
|
|
38
|
-
- [Encryption](./docs/encryption.md)
|
|
39
|
-
- [QR Codes](./docs/qr-codes.md)
|
|
40
|
-
- [WABA](./docs/waba.md)
|
|
41
|
-
- [Block Users](./docs/block-users.md)
|
|
42
|
-
- [Calling](./docs/calling.md)
|
|
43
|
-
- [Groups](./docs/groups.md)
|
|
44
|
-
- [Marketing Messages](./docs/marketing-messages.md)
|
|
45
|
-
- [Commerce Settings](./docs/commerce-settings.md)
|
|
46
|
-
- [Payments](./docs/payments.md)
|
|
47
|
-
|
|
48
|
-
## Features
|
|
49
|
-
|
|
50
|
-
- **🔒 Type-Safe Development** - Built with TypeScript strict mode for complete type safety and excellent IntelliSense
|
|
51
|
-
- **📦 Comprehensive Coverage** - Full support for 17+ WhatsApp Business Platform APIs including Messages, Media, Templates, Flows, and more
|
|
52
|
-
- **🏗️ Modular Architecture** - Clean separation with dedicated API classes, tree-shakeable imports, and minimal bundle size
|
|
53
|
-
- **🔌 Framework-Specific Webhooks** - Built-in adapters for Express.js and Next.js (App Router & Pages Router)
|
|
54
|
-
- **⚡ Production Ready** - Battle-tested with error handling, retry logic, rate limiting, and comprehensive logging
|
|
55
|
-
- **🎯 Advanced Features** - Support for Flows, End-to-End Encryption, QR Codes, Two-Step Verification, Groups, and WABA management
|
|
56
|
-
- **📚 Excellent Documentation** - Complete documentation site with guides, API reference, and working examples
|
|
57
|
-
- **🧪 Well Tested** - Comprehensive test coverage with unit, integration, and E2E tests
|
|
58
|
-
|
|
59
|
-
## Installation
|
|
30
|
+
// Send a text message
|
|
31
|
+
await wa.messages.text({ to: '1234567890', body: 'Hello from TypeScript!' });
|
|
60
32
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
33
|
+
// Send a template message
|
|
34
|
+
await wa.messages.template({
|
|
35
|
+
to: '1234567890',
|
|
36
|
+
name: 'hello_world',
|
|
37
|
+
language: { code: 'en_US' },
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Send an image
|
|
41
|
+
await wa.messages.image({ to: '1234567890', link: 'https://example.com/image.png' });
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Why meta-cloud-api?
|
|
45
|
+
|
|
46
|
+
| | meta-cloud-api |
|
|
47
|
+
|---|---|
|
|
48
|
+
| **Type Safety** | Full TypeScript strict mode — every request and response is typed |
|
|
49
|
+
| **17 API Modules** | Messages, Media, Templates, Flows, Groups, Calling, Payments, and more |
|
|
50
|
+
| **Webhook Adapters** | Built-in support for Express.js and Next.js (App Router & Pages Router) |
|
|
51
|
+
| **Modular** | Tree-shakeable imports, use only what you need |
|
|
52
|
+
| **Production Ready** | Error handling, typed error classes, rate limit support |
|
|
53
|
+
| **Official API** | Built on the official WhatsApp Business Platform Cloud API |
|
|
54
|
+
|
|
55
|
+
## API Coverage
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
wa.messages // Text, image, video, document, audio, sticker, location, contact, template, interactive, reaction
|
|
59
|
+
wa.media // Upload, get, delete media
|
|
60
|
+
wa.templates // Create, list, delete message templates
|
|
61
|
+
wa.flows // WhatsApp Flows management
|
|
62
|
+
wa.groups // Group management
|
|
63
|
+
wa.calling // Voice calling
|
|
64
|
+
wa.payments // Payment processing (India)
|
|
65
|
+
wa.businessProfile // Business profile management
|
|
66
|
+
wa.phoneNumbers // Phone number management
|
|
67
|
+
wa.commerce // Commerce settings
|
|
68
|
+
wa.marketingMessages // Marketing message management
|
|
69
|
+
wa.qrCode // QR code generation
|
|
70
|
+
wa.registration // Phone registration
|
|
71
|
+
wa.twoStepVerification // 2FA management
|
|
72
|
+
wa.encryption // End-to-end encryption
|
|
73
|
+
wa.blockUsers // Block/unblock users
|
|
74
|
+
wa.waba // WhatsApp Business Account management
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Webhooks
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { createExpressWebhookHandler } from 'meta-cloud-api/webhooks';
|
|
81
|
+
|
|
82
|
+
app.post('/webhook', createExpressWebhookHandler({
|
|
83
|
+
verifyToken: process.env.WEBHOOK_VERIFY_TOKEN,
|
|
84
|
+
onMessage: (message) => {
|
|
85
|
+
console.log('Received:', message);
|
|
86
|
+
},
|
|
87
|
+
}));
|
|
67
88
|
```
|
|
68
89
|
|
|
69
90
|
## Requirements
|
|
@@ -71,10 +92,26 @@ pnpm add meta-cloud-api
|
|
|
71
92
|
- **Node.js** 18 LTS or later
|
|
72
93
|
- **TypeScript** 4.5+ (for TypeScript projects)
|
|
73
94
|
|
|
95
|
+
## Resources
|
|
96
|
+
|
|
97
|
+
- **[Documentation](https://meta-cloud-api.site/)** — Guides, API reference, and examples
|
|
98
|
+
- **[Getting Started](https://meta-cloud-api.site/getting-started/installation)** — Setup in 5 minutes
|
|
99
|
+
- **[API Reference](https://meta-cloud-api.site/api/messages)** — Every endpoint documented
|
|
100
|
+
- **[Examples](./examples/)** — Express, Next.js App Router, Pages Router
|
|
101
|
+
|
|
102
|
+
## Examples
|
|
103
|
+
|
|
104
|
+
| Example | Description |
|
|
105
|
+
|---|---|
|
|
106
|
+
| [express-simple](./examples/express-simple/) | Basic Express.js integration |
|
|
107
|
+
| [express-production](./examples/express-production/) | Production-ready with conversation flows, DB, and queues |
|
|
108
|
+
| [nextjs-app-router](./examples/nextjs-app-router-example/) | Next.js App Router integration |
|
|
109
|
+
| [nextjs-pages-router](./examples/nextjs-page-router-example/) | Next.js Pages Router integration |
|
|
110
|
+
|
|
74
111
|
## Contributing
|
|
75
112
|
|
|
76
113
|
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
77
114
|
|
|
78
115
|
## License
|
|
79
116
|
|
|
80
|
-
|
|
117
|
+
MIT License - see the [LICENSE](LICENSE) file for details.
|