Connect to Quix
The Quix SDK comes with a streaming client that enables you to connect to Quix easily, to read data from Quix, and to write data to Quix. The streaming client manages the connections between your application and Quix and makes sure that the data is delivered reliably to and from your application.
Starting with 0.4.0, we’re offering QuixStreamingClient, which handles the cumbersome part of setting up your streaming credentials using the Quix Api. When you’re running the app in the online IDE or as a deployment, all you have to do is the following:
If you wish to run the same code locally, you’ll have to provide an OAuth2.0 bearer token. We have created a purpose made token for this, called SDK token. Once you have the token you will have to provide it as an argument to QuixStreamingClient or set
Quix__Sdk__Token environment variable.
Using the streaming client is another way to talk with a broker. It is a Kafka specific client implementation that requires some explicit configuration but allows you to connect to any Kafka cluster even outside Quix platform. It involves the following steps:
Obtain a client certificate and credentials (security context) for your application.
Create a streaming client.
A security context consists of a client certificate, username, and password. Quix generates these automatically for you when you create a project using the templates provided on the Quix Portal. If necessary, you can download these credentials separately from Topics option on Quix Portal.
security = SecurityOptions(CERTIFICATES_FOLDER, QUIX_USER, QUIX_PASSWORD) client = StreamingClient('kafka-k1.quix.ai:9093,kafka-k2.quix.ai:9093,kafka-k3.quix.ai:9093', security)
var security = new SecurityOptions(CERTIFICATES_FOLDER, QUIX_USER, QUIX_PASSWORD); var client = new Quix.Sdk.Streaming.StreamingClient("kafka-k1.quix.ai:9093,kafka-k2.quix.ai:9093,kafka-k3.quix.ai:9093", security);
Quix web APIs are secured with OAuth2.0 bearer scheme. Therefore, all HTTP requests to Quix must contain a valid bearer token. You can generate a personal access token (PAT) for use as a bearer token from the portal by following the following steps.
Navigate to your profile by clicking on your avatar and selecting "Profile" from the drop-down menu.
Select "Personal Access Tokens" tab on the profile page.
Click on "Generate Token" button to open a dialog to set a name and an expiry date for the PAT and click on "Create" to generate the PAT.
Store credentials securely
For your convenience, when you create a new project on the Quix platform, the credentials are generated and set in the code for you. However, it is good practice to move them out of the code to a more secure location like environment variables or a keystore, depending on your development platform.
When you deploy your application to Quix, you can store them on Quix as environment variables.