Blog

All Blog Posts  |  Next Post  |  Previous Post

Introducing the New JavaScript SDK for Seamless StellarDS API Integration

Today

We’re thrilled to unveil the all-new JavaScript SDK for StellarDS! This powerful tool simplifies the process of interacting with the StellarDS API, making it the perfect choice for both lightweight applications and enterprise-grade projects. With a developer-friendly design and intuitive features, the SDK helps you unlock the full potential of StellarDS with ease.

TMS Software Delphi  Components

StellarDS is our fast and easy solution to let your application use a backend as a service. Using the power of our REST API, you can easily fetch and manipulate data in the cloud. StellarDS even enables you to set up a whole database with only a few API calls. We handle everything a backend might need, from data storage and manipulation to security and privacy. There is no need anymore for hosting servers or implementing new security measures. StellarDS will handle this for you, leaving more room for implementing the things you want.

Try the demo

To help you get started, we’ve created an interactive demo that you can use to follow along with this post. The demo is built using vanilla JavaScript, and all files are served directly from our server. The code snippets shared below come from this demo, giving you a real-world example of how to implement the StellarDS JavaScript SDK. Download the Demo here.

TMS Software Delphi  Components

Key Features

The new StellarDS JavaScript SDK introduces a range of features that simplify integration:

  • Simplified API Calls: Handle common operations like data retrieval, updates, and workflow management with minimal boilerplate code.
  • Comprehensive Documentation: Each function is well-documented, making it easy for developers to understand and implement.

OAuth2.0

Before you can start making API calls, you’ll need to authenticate your application to gain access to the StellarDS API. We’ve provided a JavaScript file (included in the demo) that manages the login process, guiding you through the necessary steps to obtain an access token.

Here’s how to authenticate using OAuth 2.0 with the SDK:

const oauth = new OAuth2({
    clientId: CLIENT_ID,
    redirectUri: REDIRECT_URI,
    authorizationEndpoint: AUTHORIZATION_ENDPOINT,
    tokenEndpoint: TOKEN_ENDPOINT,
    clientSecret: CLIENT_SECRET,
});
oauth.redirectToAuth();
const tokenResponse = await oauth.exchangeCodeForToken(code);

Once you have the token, you can proceed to set up the StellarDS JavaScript SDK:

var StellarDataStore = window.stellards_js_sdk;
let defaultClient= StellarDataStore.ApiClient.instance;
        
let Bearer = defaultClient.authentications['Bearer'];
Bearer.apiKey = "Bearer " + tokenResponse.access_token;
let apiInstance = new StellarDataStore.DataApi(defaultClient);

Making API Calls

With the SDK authenticated, you can now start making API requests to interact with StellarDS data.

GET request

To fetch a list of records from our database, use the following code:

  apiInstance.v1DataTableGet(project, table, null, (error, data, response) => {
        if (error) {
            console.error(error);
        } else {
            console.log(data);
        }
  });

Post request

Adding a new record is just as simple. Here’s how you can send a POST request:

let opts = {
   'createRecordRequest': new StellarDataStore.CreateRecordRequest() 
};
opts.createRecordRequest.records = [];
opts.createRecordRequest.records.push( {'task':task , 'completed': false});
apiInstance.v1DataTablePost(project, table, opts, (error, data, response) => {
   if (error) {
       console.error(error);
   } else {
      	todoInput.value = '';
      	renderTodos();
   }
});
Note that the opts object contains a createRecordRequest, which matches the expected input in the request body. After adding an object to the records array, you pass it to the v1DataTablePost function.

The process for PUT and DELETE requests is very similar. Feel free to explore the demo or consult the documentation for more details.
TMS Software Delphi  Components

Get Started Today

The StellarDS JavaScript SDK is available now, complete with sample code and detailed documentation to help you hit the ground running. Explore our to-do list demo, dive into the SDK’s capabilities, and start building powerful applications with StellarDS today.

Download the SDK or Check out the Documentation to get started now!

Follow us now!

Show us support and follow us on our social media to always be up to date about stellards.io

TMS Software Delphi  Components

TMS Software Delphi  Components

TMS Software Delphi  Components

TMS Software Delphi  Components

TMS Software Delphi  Components

TMS Software Delphi  Components



Bradley Velghe




This blog post has not received any comments yet.



Add a new comment

You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
All fields are required.



All Blog Posts  |  Next Post  |  Previous Post