Skip to main content

Backend SDK

Squid provides a Backend SDK that enables you to enhance the functionality and security of your application. With the SDK, developers can define and execute customized backend code written in Typescript.

What can the Squid Backend SDK do?

The Backend SDK has a wide range of functionality that can be designed to suit any application's needs. By leveraging the following features, you can create a customizable, flexible backend for your project:

  • Chat with AI agents
  • Connect directly to external resources using Squid connectors
  • Secure resource access and user authentication
  • Real-time data updates using Squid's built in database
  • Customizable backend functions, such as webhooks, schedulers, and triggers
  • And more!

How to use the Squid Backend SDK

In order to use the Squid Backend SDK, start by initializing a Squid backend project. This command can be found in the Backend Project section of the Squid Console's application overview tab.

Once you have initialized a backend project, you can start customizing your backend. Most backend customization is done by creating classes that extend the SquidService class. This class provides useful context information, such as authentication details for the user who initiated an action, as well as access to this.squid, a reference to the Squid Client.

Tip

After initializing your backend project, Squid will automatically generate some backend code for you. You can see an ExampleService class that extends the SquidService within the starter code. This file is located in the /src/service directory in your backend project. You can use this as a starting point for your backend development.

By using this.squid, the backend code can perform any task that the client can perform, such as executing queries and mutating data. In addition, it has access to secrets and resources that are forbidden to the client, giving it a wider range of capabilities. The Squid Backend has extensive power and flexibility, making it a powerful tool for developers who need to build complex backend functionality for their applications.

Securing your backend

It's important to note that code running in the backend project has unrestricted access to your backend resources. For instance, any use of this.squid in your backend project will not require authorization and will bypass security rules. Think of this.squid as an admin for your backend project.

To learn more about how to secure your backend, read the security documentation.

Your backend functionality should be built within a class or multiple classes that extend the SquidService class. The index.ts file connects the backend code to the Squid server, so make sure to export any classes you add in this file.

Finish setting up your backend by following the next step in the console to Create a .env file. Use the Squid CLI to run your project and develop locally.

Conclusion

The Squid Backend SDK provides a powerful and flexible way to create your application's backend with custom logic, security, and seamless integration with external resources. Developers can build everything from simple automation to complex workflows that scale with your needs. Please contact us with any questions or feedback. Get started today and unlock the full potential of your backend with Squid!

Explore