via Inngest SDKs
To send data from any application, we've created a set of SDKs that allow you to send data to Inngest quickly and easily:
- Go: https://github.com/inngest/inngestgo
- JavaScript / TypeScript (Node): https://github.com/inngest/inngest-js
- Browser SDK: https://github.com/inngest/javascript-sdk
- Python: https://github.com/inngest/inngest-python
- Ruby: https://github.com/inngest/inngest-ruby
These SDKs all follow the same format: initialize the SDK with an API key from your workspace, then use the client to send events. Each SDK has documentation and examples in the readme.
Getting a new source API key
To create a new API key for your new source, goto the Sources page in the Inngest dashboard and create a new source using the "Add Source" button at the top right. On the next page, select your SDK or the "API" source, then click "Create a source key."
Your now have a new entry on your list of sources.
JavaScript (Node) SDK example
The JavaScript SDK works in Node.js environments with TypeScript, ES Modules, or Common.js modules. Trigger an event from anywhere, like at the end of an API request and it will immediately be sent to Inngest.
shell
$ npm install inngest# or$ yarn add inngest
js
// ES Modules / TypeScriptimport { Inngest } from "inngest";// or CommonJSconst { Inngest } = require("inngest");const inngest = new Inngest(process.env.INNGEST_SOURCE_API_KEY);await inngest.send({name: "user.signup",data: {plan: account.planType,},user: {external_id: user.id,email: user.email,},});
Go SDK example
With your new source key, here's an example for how you can use the Go SDK to send data to Inngest:
go
import ("context""os""github.com/inngest/inngestgo")func sendEvent(ctx context.Context) {// Create a new clientclient := inngestgo.NewClient(os.Getenv("<YOUR NEW INNGEST API KEY>"))// Send an eventclient.Send(ctx, inngestgo.Event{Name: "user.created",Data: map[string]interface{}{"plan": account.PlanType,"ip": req.RemoteAddr,},User: map[string]interface{}{// Use the external_id field within User so that we can identify// this event as authored by the given user.inngestgo.ExternalID: user.ID,inngestgo.Email: ou.Email,},Version: "2021-07-01.01",Timestamp: inngestgo.Now(),})}
Learn more about the event format here.