chub-dev 0.1.0 → 0.1.2-beta.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 +55 -0
- package/bin/chub-mcp +2 -0
- package/dist/airtable/docs/database/javascript/DOC.md +1437 -0
- package/dist/airtable/docs/database/python/DOC.md +1735 -0
- package/dist/amplitude/docs/analytics/javascript/DOC.md +1282 -0
- package/dist/amplitude/docs/analytics/python/DOC.md +1199 -0
- package/dist/anthropic/docs/claude-api/javascript/DOC.md +503 -0
- package/dist/anthropic/docs/claude-api/python/DOC.md +389 -0
- package/dist/asana/docs/tasks/DOC.md +1396 -0
- package/dist/assemblyai/docs/transcription/DOC.md +1043 -0
- package/dist/atlassian/docs/confluence/javascript/DOC.md +1347 -0
- package/dist/atlassian/docs/confluence/python/DOC.md +1604 -0
- package/dist/auth0/docs/identity/javascript/DOC.md +968 -0
- package/dist/auth0/docs/identity/python/DOC.md +1199 -0
- package/dist/aws/docs/s3/javascript/DOC.md +1773 -0
- package/dist/aws/docs/s3/python/DOC.md +1807 -0
- package/dist/binance/docs/trading/javascript/DOC.md +1315 -0
- package/dist/binance/docs/trading/python/DOC.md +1454 -0
- package/dist/braintree/docs/gateway/javascript/DOC.md +1278 -0
- package/dist/braintree/docs/gateway/python/DOC.md +1179 -0
- package/dist/chromadb/docs/embeddings-db/javascript/DOC.md +1263 -0
- package/dist/chromadb/docs/embeddings-db/python/DOC.md +1707 -0
- package/dist/clerk/docs/auth/javascript/DOC.md +1220 -0
- package/dist/clerk/docs/auth/python/DOC.md +274 -0
- package/dist/cloudflare/docs/workers/javascript/DOC.md +918 -0
- package/dist/cloudflare/docs/workers/python/DOC.md +994 -0
- package/dist/cockroachdb/docs/distributed-db/DOC.md +1500 -0
- package/dist/cohere/docs/llm/DOC.md +1335 -0
- package/dist/datadog/docs/monitoring/javascript/DOC.md +1740 -0
- package/dist/datadog/docs/monitoring/python/DOC.md +1815 -0
- package/dist/deepgram/docs/speech/javascript/DOC.md +885 -0
- package/dist/deepgram/docs/speech/python/DOC.md +685 -0
- package/dist/deepl/docs/translation/javascript/DOC.md +887 -0
- package/dist/deepl/docs/translation/python/DOC.md +944 -0
- package/dist/deepseek/docs/llm/DOC.md +1220 -0
- package/dist/directus/docs/headless-cms/javascript/DOC.md +1128 -0
- package/dist/directus/docs/headless-cms/python/DOC.md +1276 -0
- package/dist/discord/docs/bot/javascript/DOC.md +1090 -0
- package/dist/discord/docs/bot/python/DOC.md +1130 -0
- package/dist/elasticsearch/docs/search/DOC.md +1634 -0
- package/dist/elevenlabs/docs/text-to-speech/javascript/DOC.md +336 -0
- package/dist/elevenlabs/docs/text-to-speech/python/DOC.md +552 -0
- package/dist/firebase/docs/auth/DOC.md +1015 -0
- package/dist/gemini/docs/genai/javascript/DOC.md +691 -0
- package/dist/gemini/docs/genai/python/DOC.md +555 -0
- package/dist/github/docs/octokit/DOC.md +1560 -0
- package/dist/google/docs/bigquery/javascript/DOC.md +1688 -0
- package/dist/google/docs/bigquery/python/DOC.md +1503 -0
- package/dist/hubspot/docs/crm/javascript/DOC.md +1805 -0
- package/dist/hubspot/docs/crm/python/DOC.md +2033 -0
- package/dist/huggingface/docs/transformers/DOC.md +948 -0
- package/dist/intercom/docs/messaging/javascript/DOC.md +1844 -0
- package/dist/intercom/docs/messaging/python/DOC.md +1797 -0
- package/dist/jira/docs/issues/javascript/DOC.md +1420 -0
- package/dist/jira/docs/issues/python/DOC.md +1492 -0
- package/dist/kafka/docs/streaming/javascript/DOC.md +1671 -0
- package/dist/kafka/docs/streaming/python/DOC.md +1464 -0
- package/dist/landingai-ade/docs/api/DOC.md +620 -0
- package/dist/landingai-ade/docs/sdk/python/DOC.md +489 -0
- package/dist/landingai-ade/docs/sdk/typescript/DOC.md +542 -0
- package/dist/landingai-ade/skills/SKILL.md +489 -0
- package/dist/launchdarkly/docs/feature-flags/javascript/DOC.md +1191 -0
- package/dist/launchdarkly/docs/feature-flags/python/DOC.md +1671 -0
- package/dist/linear/docs/tracker/DOC.md +1554 -0
- package/dist/livekit/docs/realtime/javascript/DOC.md +303 -0
- package/dist/livekit/docs/realtime/python/DOC.md +163 -0
- package/dist/mailchimp/docs/marketing/DOC.md +1420 -0
- package/dist/meilisearch/docs/search/DOC.md +1241 -0
- package/dist/microsoft/docs/onedrive/javascript/DOC.md +1421 -0
- package/dist/microsoft/docs/onedrive/python/DOC.md +1549 -0
- package/dist/mongodb/docs/atlas/DOC.md +2041 -0
- package/dist/notion/docs/workspace-api/javascript/DOC.md +1435 -0
- package/dist/notion/docs/workspace-api/python/DOC.md +1400 -0
- package/dist/okta/docs/identity/javascript/DOC.md +1171 -0
- package/dist/okta/docs/identity/python/DOC.md +1401 -0
- package/dist/openai/docs/chat/javascript/DOC.md +407 -0
- package/dist/openai/docs/chat/python/DOC.md +568 -0
- package/dist/paypal/docs/checkout/DOC.md +278 -0
- package/dist/pinecone/docs/sdk/javascript/DOC.md +984 -0
- package/dist/pinecone/docs/sdk/python/DOC.md +1395 -0
- package/dist/plaid/docs/banking/javascript/DOC.md +1163 -0
- package/dist/plaid/docs/banking/python/DOC.md +1203 -0
- package/dist/playwright-community/skills/login-flows/SKILL.md +108 -0
- package/dist/postmark/docs/transactional-email/DOC.md +1168 -0
- package/dist/prisma/docs/orm/javascript/DOC.md +1419 -0
- package/dist/prisma/docs/orm/python/DOC.md +1317 -0
- package/dist/qdrant/docs/vector-search/javascript/DOC.md +1221 -0
- package/dist/qdrant/docs/vector-search/python/DOC.md +1653 -0
- package/dist/rabbitmq/docs/message-queue/javascript/DOC.md +1193 -0
- package/dist/rabbitmq/docs/message-queue/python/DOC.md +1243 -0
- package/dist/razorpay/docs/payments/javascript/DOC.md +1219 -0
- package/dist/razorpay/docs/payments/python/DOC.md +1330 -0
- package/dist/redis/docs/key-value/javascript/DOC.md +1851 -0
- package/dist/redis/docs/key-value/python/DOC.md +2054 -0
- package/dist/registry.json +2817 -0
- package/dist/replicate/docs/model-hosting/DOC.md +1318 -0
- package/dist/resend/docs/email/DOC.md +1271 -0
- package/dist/salesforce/docs/crm/javascript/DOC.md +1241 -0
- package/dist/salesforce/docs/crm/python/DOC.md +1183 -0
- package/dist/search-index.json +1 -0
- package/dist/sendgrid/docs/email-api/javascript/DOC.md +371 -0
- package/dist/sendgrid/docs/email-api/python/DOC.md +656 -0
- package/dist/sentry/docs/error-tracking/javascript/DOC.md +1073 -0
- package/dist/sentry/docs/error-tracking/python/DOC.md +1309 -0
- package/dist/shopify/docs/storefront/DOC.md +457 -0
- package/dist/slack/docs/workspace/javascript/DOC.md +933 -0
- package/dist/slack/docs/workspace/python/DOC.md +271 -0
- package/dist/square/docs/payments/javascript/DOC.md +1855 -0
- package/dist/square/docs/payments/python/DOC.md +1728 -0
- package/dist/stripe/docs/api/DOC.md +1727 -0
- package/dist/stripe/docs/payments/DOC.md +1726 -0
- package/dist/stytch/docs/auth/javascript/DOC.md +1813 -0
- package/dist/stytch/docs/auth/python/DOC.md +1962 -0
- package/dist/supabase/docs/client/DOC.md +1606 -0
- package/dist/twilio/docs/messaging/python/DOC.md +469 -0
- package/dist/twilio/docs/messaging/typescript/DOC.md +946 -0
- package/dist/vercel/docs/platform/DOC.md +1940 -0
- package/dist/weaviate/docs/vector-db/javascript/DOC.md +1268 -0
- package/dist/weaviate/docs/vector-db/python/DOC.md +1388 -0
- package/dist/zendesk/docs/support/javascript/DOC.md +2150 -0
- package/dist/zendesk/docs/support/python/DOC.md +2297 -0
- package/package.json +22 -6
- package/skills/get-api-docs/SKILL.md +84 -0
- package/src/commands/annotate.js +83 -0
- package/src/commands/build.js +12 -1
- package/src/commands/feedback.js +150 -0
- package/src/commands/get.js +83 -42
- package/src/commands/search.js +7 -0
- package/src/index.js +43 -17
- package/src/lib/analytics.js +90 -0
- package/src/lib/annotations.js +57 -0
- package/src/lib/bm25.js +170 -0
- package/src/lib/cache.js +69 -6
- package/src/lib/config.js +8 -3
- package/src/lib/identity.js +99 -0
- package/src/lib/registry.js +103 -20
- package/src/lib/telemetry.js +86 -0
- package/src/mcp/server.js +177 -0
- package/src/mcp/tools.js +251 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"1.0.0","algorithm":"bm25","params":{"k1":1.5,"b":0.75},"totalDocs":71,"avgFieldLengths":{"name":1.2253521126760563,"description":11.71830985915493,"tags":5.549295774647887},"idf":{"database":2.02537432040956,"airtable":3.8712010109078907,"javascript":0.48117692984386073,"sdk":0.39510232107261783,"js":1.0779930014653738,"official":1.4144652380865868,"npm":3.3603753871419,"package":3.3603753871419,"api":0.7651206801850345,"operations":2.57191802677763,"low":3.8712010109078907,"code":3.0239031505206873,"spreadsheet":3.3603753871419,"analytics":3.3603753871419,"amplitude":3.8712010109078907,"browser":2.772588722239781,"based":3.3603753871419,"event":3.8712010109078907,"tracking":3.0239031505206873,"product":3.8712010109078907,"events":2.772588722239781,"claude":3.8712010109078907,"ai":1.9252908618525777,"assistant":3.8712010109078907,"text":2.1365999555197845,"generation":2.772588722239781,"analysis":3.8712010109078907,"conversation":3.8712010109078907,"streaming":3.0239031505206873,"tool":3.8712010109078907,"vision":3.3603753871419,"batch":3.3603753871419,"processing":2.772588722239781,"anthropic":3.8712010109078907,"llm":2.57191802677763,"tasks":3.8712010109078907,"asana":3.8712010109078907,"coding":1.0779930014653738,"guide":1.9252908618525777,"project":3.0239031505206873,"management":1.7509374747077997,"workflow":3.8712010109078907,"transcription":3.3603753871419,"assemblyai":3.8712010109078907,"speech":3.0239031505206873,"audio":2.772588722239781,"confluence":3.8712010109078907,"cloud":3.0239031505206873,"guidelines":1.4144652380865868,"typescript":1.1631508098056809,"library":2.404863942114464,"atlassian":3.3603753871419,"wiki":3.8712010109078907,"documentation":3.8712010109078907,"collaboration":3.8712010109078907,"identity":2.772588722239781,"auth0":3.8712010109078907,"node":1.2086131838824383,"oauth":3.0239031505206873,"oidc":3.8712010109078907,"server":3.3603753871419,"side":3.8712010109078907,"applications":2.57191802677763,"authentication":2.2617630984737906,"s3":3.8712010109078907,"aws":3.8712010109078907,"v3":3.3603753871419,"complete":3.3603753871419,"projects":3.0239031505206873,"storage":2.57191802677763,"bucket":3.8712010109078907,"trading":3.8712010109078907,"binance":3.8712010109078907,"libraries":2.772588722239781,"sdks":3.0239031505206873,"crypto":3.8712010109078907,"exchange":3.8712010109078907,"gateway":3.3603753871419,"braintree":3.8712010109078907,"payment":2.772588722239781,"paypal":3.3603753871419,"subscriptions":2.404863942114464,"payments":2.2617630984737906,"embeddings":2.404863942114464,"db":2.772588722239781,"chromadb":3.8712010109078907,"vector":2.57191802677763,"powered":3.8712010109078907,"search":2.404863942114464,"auth":2.772588722239781,"clerk":3.8712010109078907,"user":3.3603753871419,"session":3.3603753871419,"workflows":3.8712010109078907,"workers":3.8712010109078907,"cloudflare":3.8712010109078907,"building":2.57191802677763,"edge":3.0239031505206873,"functions":3.3603753871419,"kv":3.8712010109078907,"r2":3.8712010109078907,"distributed":3.3603753871419,"cockroachdb":3.8712010109078907,"postgres":3.8712010109078907,"pg":3.8712010109078907,"connecting":3.8712010109078907,"sql":3.3603753871419,"cohere":3.8712010109078907,"rerank":3.8712010109078907,"monitoring":3.3603753871419,"datadog":3.8712010109078907,"client":1.9252908618525777,"submit":3.8712010109078907,"metrics":3.8712010109078907,"manage":3.8712010109078907,"monitors":3.8712010109078907,"interact":3.8712010109078907,"observability":3.8712010109078907,"features":3.0239031505206873,"apm":3.8712010109078907,"deepgram":3.8712010109078907,"recognition":3.8712010109078907,"intelligence":3.8712010109078907,"tts":3.3603753871419,"translation":3.8712010109078907,"deepl":3.8712010109078907,"document":2.772588722239781,"glossary":3.8712010109078907,"language":3.8712010109078907,"detection":3.8712010109078907,"localization":3.8712010109078907,"deepseek":3.8712010109078907,"chat":3.0239031505206873,"headless":3.8712010109078907,"cms":3.8712010109078907,"directus":3.8712010109078907,"interacting":2.772588722239781,"content":3.8712010109078907,"backend":3.3603753871419,"bot":3.3603753871419,"discord":3.8712010109078907,"bots":3.3603753871419,"slash":3.8712010109078907,"commands":3.8712010109078907,"elasticsearch":3.8712010109078907,"full":3.3603753871419,"indexing":3.3603753871419,"elevenlabs":3.8712010109078907,"voice":3.3603753871419,"firebase":3.3603753871419,"comprehensive":3.0239031505206873,"google":3.0239031505206873,"genai":3.8712010109078907,"gemini":3.8712010109078907,"multimodal":3.8712010109078907,"interactions":3.0239031505206873,"octokit":3.8712010109078907,"github":3.8712010109078907,"providing":3.8712010109078907,"rest":3.0239031505206873,"graphql":3.3603753871419,"app":3.8712010109078907,"support":3.0239031505206873,"via":2.1365999555197845,"packages":3.8712010109078907,"bigquery":3.8712010109078907,"data":2.57191802677763,"warehouse":3.8712010109078907,"crm":3.3603753871419,"hubspot":3.8712010109078907,"managing":3.3603753871419,"contacts":3.8712010109078907,"companies":3.8712010109078907,"deals":3.8712010109078907,"marketing":3.0239031505206873,"automation":3.3603753871419,"transformers":3.8712010109078907,"running":3.3603753871419,"ml":3.3603753871419,"models":3.3603753871419,"huggingface":3.8712010109078907,"inference":3.3603753871419,"messaging":2.2617630984737906,"intercom":3.8712010109078907,"customer":2.772588722239781,"issues":3.3603753871419,"jira":3.8712010109078907,"writing":3.8712010109078907,"agile":3.8712010109078907,"kafkajs":3.8712010109078907,"apache":3.8712010109078907,"kafka":3.8712010109078907,"queue":3.3603753871419,"specification":3.8712010109078907,"landingai":3.0239031505206873,"agentic":3.3603753871419,"extraction":3.0239031505206873,"ade":3.0239031505206873,"covers":3.8712010109078907,"all":3.8712010109078907,"endpoints":3.8712010109078907,"parse":3.0239031505206873,"extract":3.0239031505206873,"split":3.0239031505206873,"jobs":3.8712010109078907,"request":3.8712010109078907,"parameters":3.8712010109078907,"response":3.8712010109078907,"structures":3.8712010109078907,"types":3.8712010109078907,"error":3.0239031505206873,"codes":3.8712010109078907,"model":3.3603753871419,"versions":3.8712010109078907,"curl":3.8712010109078907,"examples":3.8712010109078907,"python":3.8712010109078907,"reference":3.8712010109078907,"includes":3.8712010109078907,"pydantic":3.8712010109078907,"schema":3.8712010109078907,"async":3.3603753871419,"handling":3.3603753871419,"save":3.8712010109078907,"visual":3.8712010109078907,"grounding":3.8712010109078907,"table":3.8712010109078907,"cell":3.8712010109078907,"lookup":3.8712010109078907,"context":3.8712010109078907,"feature":3.8712010109078907,"flags":3.8712010109078907,"launchdarkly":3.8712010109078907,"flag":3.8712010109078907,"experimentation":3.8712010109078907,"toggles":3.8712010109078907,"rollout":3.8712010109078907,"tracker":3.8712010109078907,"linear":3.8712010109078907,"issue":3.8712010109078907,"realtime":3.3603753871419,"livekit":3.8712010109078907,"enabling":3.8712010109078907,"real":3.8712010109078907,"time":3.8712010109078907,"video":3.3603753871419,"communication":3.8712010109078907,"webrtc":3.8712010109078907,"mailchimp":3.8712010109078907,"email":2.772588722239781,"audience":3.8712010109078907,"campaign":3.8712010109078907,"campaigns":3.8712010109078907,"meilisearch":3.8712010109078907,"instant":3.8712010109078907,"onedrive":3.8712010109078907,"microsoft":3.8712010109078907,"graph":3.8712010109078907,"files":3.8712010109078907,"atlas":3.8712010109078907,"mongodb":3.8712010109078907,"driver":3.8712010109078907,"databases":3.3603753871419,"nosql":3.8712010109078907,"workspace":3.3603753871419,"notion":3.8712010109078907,"workspaces":3.8712010109078907,"pages":3.8712010109078907,"okta":3.8712010109078907,"sso":3.8712010109078907,"openai":3.8712010109078907,"completions":3.8712010109078907,"function":3.8712010109078907,"calling":3.8712010109078907,"assistants":3.8712010109078907,"checkout":2.57191802677763,"integrating":3.8712010109078907,"orders":3.3603753871419,"web":3.3603753871419,"semantic":3.3603753871419,"hybrid":3.8712010109078907,"reranking":3.8712010109078907,"integrated":3.8712010109078907,"pinecone":3.8712010109078907,"banking":3.8712010109078907,"plaid":3.8712010109078907,"fintech":3.8712010109078907,"financial":3.8712010109078907,"transactional":3.3603753871419,"postmark":3.8712010109078907,"sending":3.0239031505206873,"delivery":3.3603753871419,"smtp":3.8712010109078907,"orm":3.8712010109078907,"prisma":3.8712010109078907,"type":3.8712010109078907,"safe":3.8712010109078907,"access":3.8712010109078907,"migrations":3.8712010109078907,"qdrant":3.8712010109078907,"similarity":3.8712010109078907,"message":3.8712010109078907,"rabbitmq":3.8712010109078907,"amqplib":3.8712010109078907,"broker":3.8712010109078907,"amqp":3.8712010109078907,"razorpay":3.8712010109078907,"systems":3.8712010109078907,"refunds":3.8712010109078907,"india":3.8712010109078907,"upi":3.8712010109078907,"key":3.8712010109078907,"value":3.8712010109078907,"redis":3.8712010109078907,"caching":3.8712010109078907,"pub":3.8712010109078907,"sub":3.8712010109078907,"cache":3.8712010109078907,"pubsub":3.8712010109078907,"hosting":3.8712010109078907,"replicate":3.8712010109078907,"modern":3.8712010109078907,"platform":2.57191802677763,"react":3.8712010109078907,"integration":3.3603753871419,"scheduling":3.8712010109078907,"webhooks":3.0239031505206873,"domain":3.8712010109078907,"resend":3.8712010109078907,"salesforce":3.8712010109078907,"jsforce":3.8712010109078907,"soql":3.8712010109078907,"enterprise":3.8712010109078907,"sendgrid":3.8712010109078907,"emails":3.8712010109078907,"templates":3.8712010109078907,"sentry":3.8712010109078907,"performance":3.8712010109078907,"tracing":3.8712010109078907,"storefront":3.8712010109078907,"shopify":3.8712010109078907,"ecommerce":3.8712010109078907,"integrations":3.3603753871419,"slack":3.8712010109078907,"square":3.8712010109078907,"pos":3.8712010109078907,"commerce":3.8712010109078907,"billing":3.3603753871419,"including":3.3603753871419,"intents":3.3603753871419,"connect":3.3603753871419,"marketplaces":3.3603753871419,"stripe":3.3603753871419,"stytch":3.8712010109078907,"passwordless":3.8712010109078907,"otp":3.8712010109078907,"open":3.8712010109078907,"source":3.8712010109078907,"alternative":3.8712010109078907,"postgresql":3.8712010109078907,"supabase":3.8712010109078907,"communications":3.8712010109078907,"sms":3.8712010109078907,"whatsapp":3.8712010109078907,"programmable":3.8712010109078907,"apis":3.8712010109078907,"twilio":3.8712010109078907,"vercel":3.8712010109078907,"deploying":3.8712010109078907,"deployment":3.8712010109078907,"serverless":3.8712010109078907,"weaviate":3.8712010109078907,"zendesk":3.8712010109078907,"helpdesk":3.8712010109078907,"tickets":3.8712010109078907,"service":3.8712010109078907,"skill":3.8712010109078907,"when":3.8712010109078907,"mentions":3.8712010109078907,"parsing":3.8712010109078907,"pdf":3.8712010109078907,"ocr":3.8712010109078907,"markdown":3.8712010109078907,"structured":3.8712010109078907,"documents":3.8712010109078907,"classification":3.8712010109078907,"splitting":3.8712010109078907,"wants":3.8712010109078907,"pull":3.8712010109078907,"out":3.8712010109078907,"image":3.8712010109078907,"login":3.8712010109078907,"flows":3.8712010109078907,"common":3.8712010109078907,"patterns":3.8712010109078907,"apps":3.8712010109078907,"playwright":3.8712010109078907,"testing":3.8712010109078907},"documents":[{"id":"airtable/database","tokens":{"name":["database"],"description":["airtable","javascript","sdk","airtable","js","official","airtable","npm","package","airtable","api","operations"],"tags":["airtable","database","low","code","spreadsheet","api"]}},{"id":"amplitude/analytics","tokens":{"name":["analytics"],"description":["amplitude","analytics","javascript","sdk","browser","based","event","tracking","product","analytics"],"tags":["amplitude","analytics","events","tracking","product"]}},{"id":"anthropic/claude-api","tokens":{"name":["claude","api"],"description":["claude","ai","assistant","api","text","generation","analysis","conversation","streaming","tool","vision","batch","processing"],"tags":["anthropic","sdk","llm","ai","claude"]}},{"id":"asana/tasks","tokens":{"name":["tasks"],"description":["asana","api","coding","guide","tasks","project","management","workflow"],"tags":["asana","tasks","project","management","workflow","api"]}},{"id":"assemblyai/transcription","tokens":{"name":["transcription"],"description":["assemblyai","javascript","sdk","coding","guide","speech","text","transcription"],"tags":["assemblyai","transcription","speech","text","audio","ai"]}},{"id":"atlassian/confluence","tokens":{"name":["confluence"],"description":["confluence","cloud","api","coding","guidelines","javascript","typescript","confluence","js","library"],"tags":["atlassian","confluence","wiki","documentation","collaboration"]}},{"id":"auth0/identity","tokens":{"name":["identity"],"description":["auth0","javascript","node","js","sdk","oauth","oidc","identity","management","server","side","applications"],"tags":["auth0","identity","oauth","oidc","authentication"]}},{"id":"aws/s3","tokens":{"name":["s3"],"description":["aws","s3","sdk","javascript","v3","complete","guide","s3","operations","javascript","node","js","projects"],"tags":["aws","s3","storage","cloud","bucket"]}},{"id":"binance/trading","tokens":{"name":["trading"],"description":["binance","api","javascript","typescript","coding","guidelines","trading","official","libraries","sdks"],"tags":["binance","trading","crypto","exchange","api"]}},{"id":"braintree/gateway","tokens":{"name":["gateway"],"description":["braintree","node","js","sdk","payment","gateway","paypal","subscriptions"],"tags":["braintree","gateway","payments","paypal","subscriptions"]}},{"id":"chromadb/embeddings-db","tokens":{"name":["embeddings","db"],"description":["chromadb","javascript","typescript","sdk","vector","embeddings","ai","powered","search"],"tags":["chromadb","embeddings","vector","db","ai","search"]}},{"id":"clerk/auth","tokens":{"name":["auth"],"description":["clerk","javascript","sdk","user","authentication","session","management","identity","workflows"],"tags":["clerk","auth","authentication","user","management","session"]}},{"id":"cloudflare/workers","tokens":{"name":["workers"],"description":["cloudflare","workers","sdk","building","edge","functions","kv","r2","storage","javascript","typescript"],"tags":["cloudflare","workers","edge","kv","r2"]}},{"id":"cockroachdb/distributed-db","tokens":{"name":["distributed","db"],"description":["cockroachdb","node","postgres","pg","javascript","guide","connecting","cockroachdb","node","js","applications"],"tags":["cockroachdb","distributed","db","sql","postgres","database"]}},{"id":"cohere/llm","tokens":{"name":["llm"],"description":["cohere","api","javascript","typescript","sdk","coding","guide","llm","embeddings","rerank"],"tags":["cohere","llm","ai","embeddings","rerank"]}},{"id":"datadog/monitoring","tokens":{"name":["monitoring"],"description":["official","datadog","api","client","javascript","typescript","submit","metrics","manage","monitors","interact","datadog","observability","features"],"tags":["datadog","monitoring","metrics","observability","apm"]}},{"id":"deepgram/speech","tokens":{"name":["speech"],"description":["deepgram","javascript","sdk","coding","guidelines","speech","recognition","text","speech","audio","intelligence"],"tags":["deepgram","speech","transcription","tts","audio"]}},{"id":"deepl/translation","tokens":{"name":["translation"],"description":["deepl","api","client","javascript","typescript","text","document","translation","glossary","management","language","detection"],"tags":["deepl","translation","language","localization","api"]}},{"id":"deepseek/llm","tokens":{"name":["llm"],"description":["deepseek","api","javascript","typescript","sdk","coding","guide","llm","chat","code","generation"],"tags":["deepseek","llm","ai","chat","code"]}},{"id":"directus/headless-cms","tokens":{"name":["headless","cms"],"description":["directus","javascript","typescript","sdk","coding","guidelines","interacting","directus","projects","official","sdk"],"tags":["directus","headless","cms","api","content","backend"]}},{"id":"discord/bot","tokens":{"name":["bot"],"description":["discord","js","sdk","building","discord","bots","slash","commands","gateway","events","javascript","typescript"],"tags":["discord","bot","slash","commands","gateway","sdk"]}},{"id":"elasticsearch/search","tokens":{"name":["search"],"description":["official","elasticsearch","javascript","client","full","text","search","indexing","vector","search","operations"],"tags":["elasticsearch","search","full","text","indexing","vector"]}},{"id":"elevenlabs/text-to-speech","tokens":{"name":["text","speech"],"description":["elevenlabs","js","library","coding","guidelines","text","speech","tts","audio","voice","generation"],"tags":["elevenlabs","text","speech","tts","audio","voice"]}},{"id":"firebase/auth","tokens":{"name":["auth"],"description":["firebase","authentication","javascript","sdk","comprehensive","coding","guide","firebase","auth","javascript","projects"],"tags":["firebase","auth","google","identity","session"]}},{"id":"gemini/genai","tokens":{"name":["genai"],"description":["google","gemini","genai","sdk","multimodal","llm","interactions","javascript","typescript"],"tags":["gemini","google","genai","llm","multimodal"]}},{"id":"github/octokit","tokens":{"name":["octokit"],"description":["official","github","sdk","javascript","providing","rest","api","graphql","api","authentication","app","support","via","octokit","packages"],"tags":["github","octokit","rest","graphql","api"]}},{"id":"google/bigquery","tokens":{"name":["bigquery"],"description":["bigquery","api","javascript","typescript","coding","guidelines","official","node","js","client","library"],"tags":["google","bigquery","data","warehouse","sql","analytics"]}},{"id":"hubspot/crm","tokens":{"name":["crm"],"description":["hubspot","node","js","sdk","managing","crm","contacts","companies","deals","marketing","automation","via","hubspot","api"],"tags":["hubspot","crm","marketing","contacts","automation"]}},{"id":"huggingface/transformers","tokens":{"name":["transformers"],"description":["transformers","js","coding","guidelines","running","ml","models","browser","node","js"],"tags":["huggingface","transformers","ml","inference","models"]}},{"id":"intercom/messaging","tokens":{"name":["messaging"],"description":["intercom","javascript","sdk","customer","messaging","chat","support"],"tags":["intercom","messaging","customer","chat","support"]}},{"id":"jira/issues","tokens":{"name":["issues"],"description":["jira","javascript","typescript","sdk","coding","guidelines","writing","code","jira","api","official","libraries","sdks"],"tags":["jira","issues","atlassian","project","management","agile"]}},{"id":"kafka/streaming","tokens":{"name":["streaming"],"description":["kafkajs","apache","kafka","client","node","js","streaming","messaging"],"tags":["kafka","streaming","messaging","queue","events"]}},{"id":"landingai-ade/api","tokens":{"name":["api"],"description":["rest","api","specification","landingai","agentic","document","extraction","ade","covers","all","endpoints","parse","extract","split","parse","jobs","request","parameters","response","structures","data","types","error","codes","model","versions","curl","examples"],"tags":["landingai","ade","api","document","extraction","parse","extract","split","parse","jobs","curl","rest"]}},{"id":"landingai-ade/sdk","tokens":{"name":["sdk"],"description":["python","sdk","reference","landingai","agentic","document","extraction","ade","includes","pydantic","schema","extraction","async","processing","error","handling","save","visual","grounding","table","cell","lookup","complete","api","context"],"tags":["landingai","ade","python","sdk","pydantic","document","extraction","parse","extract","split","async"]}},{"id":"launchdarkly/feature-flags","tokens":{"name":["feature","flags"],"description":["launchdarkly","node","js","server","sdk","feature","flag","management","experimentation"],"tags":["launchdarkly","feature","flags","toggles","experimentation","rollout"]}},{"id":"linear/tracker","tokens":{"name":["tracker"],"description":["linear","sdk","javascript","typescript","issue","tracking","project","management","via","graphql"],"tags":["linear","tracker","issues","project","management","graphql"]}},{"id":"livekit/realtime","tokens":{"name":["realtime"],"description":["livekit","client","sdk","javascript","typescript","enabling","real","time","video","audio","data","communication","via","webrtc"],"tags":["livekit","realtime","webrtc","video","audio"]}},{"id":"mailchimp/marketing","tokens":{"name":["marketing"],"description":["mailchimp","marketing","api","node","js","sdk","coding","guidelines","email","marketing","audience","management","campaign","management"],"tags":["mailchimp","marketing","email","campaigns","audience"]}},{"id":"meilisearch/search","tokens":{"name":["search"],"description":["meilisearch","javascript","sdk","coding","guidelines","full","text","search","indexing"],"tags":["meilisearch","search","full","text","indexing","instant"]}},{"id":"microsoft/onedrive","tokens":{"name":["onedrive"],"description":["microsoft","onedrive","api","coding","guidelines","javascript","typescript","official","microsoft","graph","sdk"],"tags":["microsoft","onedrive","storage","graph","api","files"]}},{"id":"mongodb/atlas","tokens":{"name":["atlas"],"description":["mongodb","node","js","driver","interacting","mongodb","atlas","databases","official","javascript","typescript","sdk"],"tags":["mongodb","atlas","database","nosql","driver"]}},{"id":"notion/workspace-api","tokens":{"name":["workspace","api"],"description":["notion","javascript","typescript","sdk","interacting","notion","workspaces","pages","databases","via","official","api"],"tags":["notion","api","workspace","pages","databases"]}},{"id":"okta/identity","tokens":{"name":["identity"],"description":["okta","node","js","sdk","coding","guidelines","okta","management","api","official","libraries"],"tags":["okta","identity","sso","oauth","authentication"]}},{"id":"openai/chat","tokens":{"name":["chat"],"description":["openai","api","text","generation","chat","completions","streaming","function","calling","vision","embeddings","assistants"],"tags":["openai","chat","llm","ai"]}},{"id":"paypal/checkout","tokens":{"name":["checkout"],"description":["paypal","javascript","sdk","integrating","checkout","payments","subscriptions","orders","web","applications"],"tags":["paypal","payments","checkout","subscriptions","orders"]}},{"id":"pinecone/sdk","tokens":{"name":["sdk"],"description":["vector","database","ai","applications","semantic","search","hybrid","search","reranking","integrated","embeddings"],"tags":["pinecone","sdk","vector","db","ai","search"]}},{"id":"plaid/banking","tokens":{"name":["banking"],"description":["plaid","api","coding","guidelines","javascript","typescript","official","plaid","libraries","sdks"],"tags":["plaid","banking","fintech","payments","financial","data"]}},{"id":"postmark/transactional-email","tokens":{"name":["transactional","email"],"description":["postmark","api","coding","guidelines","transactional","email","sending","official","node","js","library"],"tags":["postmark","email","transactional","delivery","smtp"]}},{"id":"prisma/orm","tokens":{"name":["orm"],"description":["prisma","orm","client","javascript","typescript","type","safe","database","access","migrations"],"tags":["prisma","orm","database","typescript","migrations"]}},{"id":"qdrant/vector-search","tokens":{"name":["vector","search"],"description":["qdrant","javascript","sdk","qdrant","js","client","rest","vector","database","operations"],"tags":["qdrant","vector","search","embeddings","similarity","ai"]}},{"id":"rabbitmq/message-queue","tokens":{"name":["message","queue"],"description":["rabbitmq","amqplib","coding","guidelines","javascript","node","js","message","broker","interactions"],"tags":["rabbitmq","queue","amqp","messaging","async"]}},{"id":"razorpay/payments","tokens":{"name":["payments"],"description":["razorpay","node","js","sdk","coding","guidelines","building","payment","systems","orders","payments","refunds","subscriptions"],"tags":["razorpay","payments","india","checkout","upi"]}},{"id":"redis/key-value","tokens":{"name":["key","value"],"description":["redis","javascript","client","node","redis","key","value","storage","caching","pub","sub","messaging"],"tags":["redis","database","cache","key","value","pubsub"]}},{"id":"replicate/model-hosting","tokens":{"name":["model","hosting"],"description":["replicate","javascript","sdk","coding","guide","running","ml","models","via","official","replicate","npm","package"],"tags":["replicate","model","hosting","ml","inference","ai"]}},{"id":"resend/email","tokens":{"name":["email"],"description":["modern","email","api","platform","react","email","integration","batch","sending","scheduling","webhooks","domain","management"],"tags":["resend","sdk","email","messaging"]}},{"id":"salesforce/crm","tokens":{"name":["crm"],"description":["salesforce","javascript","sdk","jsforce","coding","guidelines","salesforce","api","interactions"],"tags":["salesforce","crm","soql","enterprise","api"]}},{"id":"sendgrid/email-api","tokens":{"name":["email","api"],"description":["sendgrid","node","js","library","sending","transactional","marketing","emails","via","sendgrid","api"],"tags":["sendgrid","email","transactional","templates","delivery"]}},{"id":"sentry/error-tracking","tokens":{"name":["error","tracking"],"description":["sentry","javascript","sdk","error","tracking","performance","monitoring","distributed","tracing","node","js","browser","applications"],"tags":["sentry","monitoring","error","tracking","performance","tracing"]}},{"id":"shopify/storefront","tokens":{"name":["storefront"],"description":["shopify","storefront","api","library","building","ecommerce","integrations","oauth","official","javascript","sdk"],"tags":["shopify","storefront","ecommerce","api","oauth"]}},{"id":"slack/workspace","tokens":{"name":["workspace"],"description":["slack","node","sdk","building","bots","handling","workspace","events","messaging","integrations"],"tags":["slack","bot","workspace","messaging","events","api"]}},{"id":"square/payments","tokens":{"name":["payments"],"description":["square","sdk","coding","guide","payments","pos","commerce","checkout"],"tags":["square","payments","pos","commerce","checkout"]}},{"id":"stripe/api","tokens":{"name":["api"],"description":["payment","processing","platform","comprehensive","payment","billing","features","including","payment","intents","subscriptions","checkout","customer","management","webhooks","connect","marketplaces"],"tags":["stripe","api","payments","billing"]}},{"id":"stripe/payments","tokens":{"name":["payments"],"description":["payment","processing","platform","comprehensive","payment","billing","features","including","payment","intents","subscriptions","checkout","customer","management","webhooks","connect","marketplaces"],"tags":["stripe","api","payments","billing"]}},{"id":"stytch/auth","tokens":{"name":["auth"],"description":["stytch","node","js","sdk","authentication","guide","passwordless","otp","based","authentication"],"tags":["stytch","auth","authentication","passwordless","otp"]}},{"id":"supabase/client","tokens":{"name":["client"],"description":["open","source","firebase","alternative","postgresql","backend","authentication","storage","realtime","subscriptions","edge","functions"],"tags":["supabase","sdk","database","auth","storage","realtime"]}},{"id":"twilio/messaging","tokens":{"name":["messaging"],"description":["cloud","communications","platform","sms","voice","video","whatsapp","messaging","programmable","apis"],"tags":["twilio","sdk","sms","voice","communications"]}},{"id":"vercel/platform","tokens":{"name":["platform"],"description":["vercel","sdk","deploying","managing","interacting","vercel","platform","via","official","javascript","typescript","api"],"tags":["vercel","deployment","platform","serverless","edge"]}},{"id":"weaviate/vector-db","tokens":{"name":["vector","db"],"description":["weaviate","typescript","javascript","sdk","v3","vector","database","operations","semantic","search"],"tags":["weaviate","vector","db","search","embeddings","ai"]}},{"id":"zendesk/support","tokens":{"name":["support"],"description":["zendesk","api","javascript","node","js","sdk","node","zendesk","helpdesk","tickets","customer","service","integration"],"tags":["zendesk","support","helpdesk","tickets","customer","service"]}},{"id":"landingai-ade/skill","tokens":{"name":["skill"],"description":["when","user","mentions","document","parsing","pdf","extraction","ocr","markdown","extraction","structured","data","extraction","documents","document","classification","splitting","landingai","ade","api","wants","pull","data","out","pdf","image","spreadsheet"],"tags":["landingai","ade","document","extraction","parse","extract","split","ocr","pdf"]}},{"id":"playwright-community/login-flows","tokens":{"name":["login","flows"],"description":["common","login","automation","patterns","web","apps","playwright"],"tags":["browser","automation","playwright","login","testing"]}}]}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: email-api
|
|
3
|
+
description: "SendGrid Node.js library for sending transactional and marketing emails via the SendGrid API."
|
|
4
|
+
metadata:
|
|
5
|
+
languages: "javascript"
|
|
6
|
+
versions: "8.1.6"
|
|
7
|
+
updated-on: "2026-03-01"
|
|
8
|
+
source: maintainer
|
|
9
|
+
tags: "sendgrid,email,transactional,templates,delivery"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# SendGrid Node.js API Coding Guidelines (JavaScript/TypeScript)
|
|
13
|
+
|
|
14
|
+
You are a SendGrid Node.js API coding expert. Help me with writing code using the SendGrid Node.js library for email sending and API interactions. Please follow the following guidelines when generating code.
|
|
15
|
+
|
|
16
|
+
You can find the official documentation and code samples here: https://docs.sendgrid.com/for-developers/sending-email/nodejs
|
|
17
|
+
|
|
18
|
+
## Golden Rule: Use the Correct and Current Packages
|
|
19
|
+
|
|
20
|
+
Always use the official SendGrid Node.js packages, which are organized as a monorepo with specialized packages for different use cases.
|
|
21
|
+
|
|
22
|
+
- **Main Email Package:** `@sendgrid/mail`
|
|
23
|
+
- **Full API Client:** `@sendgrid/client`
|
|
24
|
+
- **Helper Classes:** `@sendgrid/helpers`
|
|
25
|
+
- **Contact Management:** `@sendgrid/contact-importer`
|
|
26
|
+
- **Webhook Processing:** `@sendgrid/eventwebhook`
|
|
27
|
+
- **Inbound Email Parsing:** `@sendgrid/inbound-mail-parser`
|
|
28
|
+
- **Subscription Widget:** `@sendgrid/subscription-widget`
|
|
29
|
+
|
|
30
|
+
**Installation:**
|
|
31
|
+
|
|
32
|
+
- **For Email Sending Only:** `npm install @sendgrid/mail`
|
|
33
|
+
- **For Full API Access:** `npm install @sendgrid/client`
|
|
34
|
+
- **For Helper Classes:** `npm install @sendgrid/helpers`
|
|
35
|
+
|
|
36
|
+
**APIs and Usage:**
|
|
37
|
+
|
|
38
|
+
- **Incorrect:** `const sendgrid = require('sendgrid')` (legacy v2/v3 library)
|
|
39
|
+
- **Correct:** `const sgMail = require('@sendgrid/mail')`
|
|
40
|
+
- **Incorrect:** `sendgrid.send(...)` -> **Correct:** `sgMail.send(...)`
|
|
41
|
+
- **Incorrect:** `const client = require('@sendgrid/client')` without setup -> **Correct:** Set API key first
|
|
42
|
+
|
|
43
|
+
## Prerequisites and Setup
|
|
44
|
+
|
|
45
|
+
Before using SendGrid Node.js library, ensure you have:
|
|
46
|
+
|
|
47
|
+
- Node.js 18 or higher
|
|
48
|
+
- A Twilio SendGrid account (sign up for free to send up to 40,000 emails for the first 30 days)
|
|
49
|
+
- A verified sender identity
|
|
50
|
+
|
|
51
|
+
## API Key Configuration
|
|
52
|
+
|
|
53
|
+
**Never hardcode your API key.** Always use environment variables:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
|
|
57
|
+
echo "sendgrid.env" >> .gitignore
|
|
58
|
+
source ./sendgrid.env
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Basic Email Sending
|
|
62
|
+
|
|
63
|
+
### Simple Email
|
|
64
|
+
|
|
65
|
+
Here's how to send a basic email:
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
const sgMail = require('@sendgrid/mail');
|
|
69
|
+
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
|
|
70
|
+
|
|
71
|
+
const msg = {
|
|
72
|
+
to: 'test@example.com',
|
|
73
|
+
from: 'test@example.com', // Use the email address or domain you verified
|
|
74
|
+
subject: 'Sending with Twilio SendGrid is Fun',
|
|
75
|
+
text: 'and easy to do anywhere, even with Node.js',
|
|
76
|
+
html: '<strong>and easy to do anywhere, even with Node.js</strong>',
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// ES6 Promise approach
|
|
80
|
+
sgMail
|
|
81
|
+
.send(msg)
|
|
82
|
+
.then(() => {
|
|
83
|
+
console.log('Email sent successfully');
|
|
84
|
+
}, error => {
|
|
85
|
+
console.error(error);
|
|
86
|
+
if (error.response) {
|
|
87
|
+
console.error(error.response.body);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// ES8 async/await approach
|
|
92
|
+
(async () => {
|
|
93
|
+
try {
|
|
94
|
+
await sgMail.send(msg);
|
|
95
|
+
console.log('Email sent successfully');
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error(error);
|
|
98
|
+
if (error.response) {
|
|
99
|
+
console.error(error.response.body);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
})();
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Multiple Recipients
|
|
106
|
+
|
|
107
|
+
Send to multiple recipients:
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
sgMail.send({
|
|
111
|
+
to: ['recipient1@example.org', 'recipient2@example.org'],
|
|
112
|
+
from: 'sender@example.org',
|
|
113
|
+
subject: 'Hello world',
|
|
114
|
+
text: 'Hello plain world!',
|
|
115
|
+
html: '<p>Hello HTML world!</p>',
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Send Multiple (Individual Emails)
|
|
120
|
+
|
|
121
|
+
Use `sendMultiple` to send individual emails to each recipient:
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
sgMail.sendMultiple({
|
|
125
|
+
to: ['recipient1@example.org', 'recipient2@example.org'],
|
|
126
|
+
from: 'sender@example.org',
|
|
127
|
+
subject: 'Hello world',
|
|
128
|
+
text: 'Hello plain world!',
|
|
129
|
+
html: '<p>Hello HTML world!</p>',
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Advanced Email Features
|
|
134
|
+
|
|
135
|
+
### Personalizations with Substitutions
|
|
136
|
+
|
|
137
|
+
Send personalized emails with dynamic content:
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
const sgMail = require('@sendgrid/mail');
|
|
141
|
+
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
|
|
142
|
+
|
|
143
|
+
const msg = {
|
|
144
|
+
from: 'sender1@example.org',
|
|
145
|
+
subject: 'Ahoy!',
|
|
146
|
+
text: 'Ahoy {{name}}!',
|
|
147
|
+
html: '<p>Ahoy {{name}}!</p>',
|
|
148
|
+
personalizations: [
|
|
149
|
+
{
|
|
150
|
+
to: 'recipient1@example.org',
|
|
151
|
+
substitutions: {
|
|
152
|
+
name: 'Jon'
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
to: 'recipient2@example.org',
|
|
157
|
+
substitutions: {
|
|
158
|
+
name: 'Jane'
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
sgMail.send(msg);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### CC and BCC Recipients
|
|
168
|
+
|
|
169
|
+
Include CC and BCC recipients:
|
|
170
|
+
|
|
171
|
+
```javascript
|
|
172
|
+
sgMail.send({
|
|
173
|
+
to: 'recipient@example.org',
|
|
174
|
+
cc: 'someone@example.org',
|
|
175
|
+
bcc: ['me@example.org', 'you@example.org'],
|
|
176
|
+
from: 'sender@example.org',
|
|
177
|
+
replyTo: 'othersender@example.org',
|
|
178
|
+
subject: 'Hello world',
|
|
179
|
+
text: 'Hello plain world!',
|
|
180
|
+
html: '<p>Hello HTML world!</p>',
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Client Configuration
|
|
185
|
+
|
|
186
|
+
### MailService Configuration
|
|
187
|
+
|
|
188
|
+
The MailService class provides various configuration options:
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
const sgMail = require('@sendgrid/mail');
|
|
192
|
+
|
|
193
|
+
// Set API key
|
|
194
|
+
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
|
|
195
|
+
|
|
196
|
+
// Set timeout (in milliseconds)
|
|
197
|
+
sgMail.setTimeout(10000);
|
|
198
|
+
|
|
199
|
+
// Set substitution wrappers (default is {{ and }})
|
|
200
|
+
sgMail.setSubstitutionWrappers('{{', '}}');
|
|
201
|
+
|
|
202
|
+
// Use custom client instance
|
|
203
|
+
const {Client} = require('@sendgrid/client');
|
|
204
|
+
const customClient = new Client();
|
|
205
|
+
customClient.setApiKey(process.env.SENDGRID_API_KEY);
|
|
206
|
+
sgMail.setClient(customClient);
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Data Residency
|
|
210
|
+
|
|
211
|
+
Set data residency for EU compliance:
|
|
212
|
+
|
|
213
|
+
```javascript
|
|
214
|
+
const client = require('@sendgrid/client');
|
|
215
|
+
const sgMail = require('@sendgrid/mail');
|
|
216
|
+
|
|
217
|
+
// Send to EU region
|
|
218
|
+
client.setDataResidency('eu');
|
|
219
|
+
sgMail.setClient(client);
|
|
220
|
+
|
|
221
|
+
const msg = {
|
|
222
|
+
to: 'recipient@example.org',
|
|
223
|
+
from: 'sender@example.org',
|
|
224
|
+
subject: 'Hello world',
|
|
225
|
+
text: 'Hello plain world!',
|
|
226
|
+
html: '<p>Hello HTML world!</p>',
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
sgMail.send(msg);
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Direct API Client Usage
|
|
233
|
+
|
|
234
|
+
For accessing SendGrid's full v3 Web API:
|
|
235
|
+
|
|
236
|
+
```javascript
|
|
237
|
+
const client = require('@sendgrid/client');
|
|
238
|
+
client.setApiKey(process.env.SENDGRID_API_KEY);
|
|
239
|
+
|
|
240
|
+
const request = {
|
|
241
|
+
method: 'GET',
|
|
242
|
+
url: '/v3/api_keys'
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
client.request(request)
|
|
246
|
+
.then(([response, body]) => {
|
|
247
|
+
console.log(response.statusCode);
|
|
248
|
+
console.log(body);
|
|
249
|
+
})
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Custom Headers and Requests
|
|
253
|
+
|
|
254
|
+
Add custom headers and modify request defaults:
|
|
255
|
+
|
|
256
|
+
```javascript
|
|
257
|
+
// Add custom default header
|
|
258
|
+
client.setDefaultHeader('User-Agent', 'Some user agent string');
|
|
259
|
+
// or
|
|
260
|
+
client.setDefaultHeader({'User-Agent': 'Some user agent string'});
|
|
261
|
+
|
|
262
|
+
// Change request defaults
|
|
263
|
+
client.setDefaultRequest('baseUrl', 'https://api.sendgrid.com/');
|
|
264
|
+
// or
|
|
265
|
+
client.setDefaultRequest({baseUrl: 'https://api.sendgrid.com/'});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Multiple Client Instances
|
|
269
|
+
|
|
270
|
+
Create multiple client instances for different API keys:
|
|
271
|
+
|
|
272
|
+
```javascript
|
|
273
|
+
const {Client} = require('@sendgrid/client');
|
|
274
|
+
const sgClient1 = new Client();
|
|
275
|
+
const sgClient2 = new Client();
|
|
276
|
+
sgClient1.setApiKey('KEY1');
|
|
277
|
+
sgClient2.setApiKey('KEY2');
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Error Handling
|
|
281
|
+
|
|
282
|
+
Handle SendGrid API errors properly:
|
|
283
|
+
|
|
284
|
+
```javascript
|
|
285
|
+
try {
|
|
286
|
+
await sgMail.send(msg);
|
|
287
|
+
console.log('Email sent successfully');
|
|
288
|
+
} catch (error) {
|
|
289
|
+
console.error('SendGrid Error:', error);
|
|
290
|
+
|
|
291
|
+
if (error.response) {
|
|
292
|
+
console.error('Response Status:', error.response.status);
|
|
293
|
+
console.error('Response Body:', error.response.body);
|
|
294
|
+
|
|
295
|
+
// Handle specific error codes
|
|
296
|
+
if (error.response.status === 401) {
|
|
297
|
+
console.error('Invalid API key');
|
|
298
|
+
} else if (error.response.status === 403) {
|
|
299
|
+
console.error('Sender not verified or insufficient permissions');
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Package Architecture
|
|
306
|
+
|
|
307
|
+
The SendGrid Node.js library follows a modular architecture:
|
|
308
|
+
|
|
309
|
+
- **@sendgrid/mail** depends on **@sendgrid/client** and **@sendgrid/helpers**
|
|
310
|
+
- **@sendgrid/client** handles HTTP communication with SendGrid's API
|
|
311
|
+
- **@sendgrid/helpers** provides utility classes for email construction
|
|
312
|
+
|
|
313
|
+
## TypeScript Support
|
|
314
|
+
|
|
315
|
+
All packages include TypeScript definitions:
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
import { MailService, MailDataRequired, ClientResponse, ResponseError } from '@sendgrid/mail';
|
|
319
|
+
|
|
320
|
+
const sgMail: MailService = require('@sendgrid/mail');
|
|
321
|
+
sgMail.setApiKey(process.env.SENDGRID_API_KEY!);
|
|
322
|
+
|
|
323
|
+
const msg: MailDataRequired = {
|
|
324
|
+
to: 'test@example.com',
|
|
325
|
+
from: 'test@example.com',
|
|
326
|
+
subject: 'Sending with TypeScript',
|
|
327
|
+
text: 'Hello TypeScript world!',
|
|
328
|
+
html: '<strong>Hello TypeScript world!</strong>',
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
sgMail.send(msg)
|
|
332
|
+
.then(([response]: [ClientResponse, {}]) => {
|
|
333
|
+
console.log('Email sent, status:', response.statusCode);
|
|
334
|
+
})
|
|
335
|
+
.catch((error: ResponseError) => {
|
|
336
|
+
console.error('Error:', error);
|
|
337
|
+
});
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## Development and Testing
|
|
341
|
+
|
|
342
|
+
For development setup:
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
git clone https://github.com/sendgrid/sendgrid-nodejs.git
|
|
346
|
+
cd sendgrid-nodejs
|
|
347
|
+
npm install
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Run tests with Docker:
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
make test-docker
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## Useful Links
|
|
357
|
+
|
|
358
|
+
- **Documentation:** https://docs.sendgrid.com/for-developers/sending-email/nodejs
|
|
359
|
+
- **API Reference:** https://docs.sendgrid.com/api-reference/
|
|
360
|
+
- **GitHub Repository:** https://github.com/sendgrid/sendgrid-nodejs
|
|
361
|
+
- **Support:** https://support.sendgrid.com
|
|
362
|
+
- **Pricing:** https://sendgrid.com/pricing
|
|
363
|
+
|
|
364
|
+
## Notes
|
|
365
|
+
|
|
366
|
+
This SendGrid Node.js library is a monorepo containing seven specialized packages. The modular design allows you to install only the packages you need while maintaining consistency across the entire SDK. Always verify sender identities before sending emails to avoid 403 Forbidden responses.
|
|
367
|
+
|
|
368
|
+
### Wiki Pages
|
|
369
|
+
|
|
370
|
+
- [Monorepo Architecture (sendgrid/sendgrid-nodejs)](/wiki/sendgrid/sendgrid-nodejs#1.1)
|
|
371
|
+
- [Getting Started (sendgrid/sendgrid-nodejs)](/wiki/sendgrid/sendgrid-nodejs#1.2)
|