Toggle Menu

Accessing Cassandra with the Stargate REST API

REST APIs are a popular way to expose interfaces in microservice and cloud-native architectures. Stargate makes it easy to serve a RESTful API directly from any Cassandra database, allowing you to access data via simple HTTP operations.

What is a RESTful API

What is a RESTful API?

REST stands for Representational State Transfer. The RESTful API style was invented by Roy Fielding and his colleagues in 2000 as a way of using standard HTTP commands like POST, PUT, GET, DELETE, and others to support exchange of data using formats such as JSON. This style of interface promotes a clean separation between implementation of clients and servers. Over time the RESTful style has emerged as the most common way of specifying interfaces for stateless microservices that can scale independently and store their data in databases like Cassandra.

Next concept: Why use the REST API with Cassandra?

Why use the REST API with Cassandra?

REST is the most popular API style, while Cassandra is known for high scalability. The marriage of a RESTful interface to Cassandra through the Stargate data gateway means you get all the benefits of scale with a well understood interface pattern.

When the Stargate REST API is added to an existing Cassandra deployment, it automatically creates HTTP endpoints that allow you to perform create, read, update, and delete (CRUD) operations on tables in your database. You can also create new database tables directly via the API.

Next concept: How to get the Stargate REST API
Why use the REST API with Cassandra?
How to get the Stargate REST API

How to get the Stargate REST API

Stargate is an open-source data gateway now available in DataStax Astra. If you already have an Astra database, the Stargate REST API is already enabled. If you don’t have a Cassandra cluster and want one, you can set up a database for free at astra.datastax.com. If you have access to your own self-hosted Cassandra cluster, see the Stargate documentation for the quickstart guide for installing and using the REST API.

Next: Try it out

Try It Out

With the Stargate REST API you can serve RESTful APIs directly from Cassandra. Here’s two ways you can try it yourself.

Explore the Stargate REST API in DataStax Astra with this Next.js starter app.

Try on Astra
Try on Astra

Astra REST API Service

Getting started with the Stargate REST API on Astra

CONTRIBUTORS

REST stands for Representational State Transfer. The RESTful API style is a popular way of using standard HTTP commands like POST, PUT, GET, DELETE, and others to support exchange of data, using formats such as JSON. This style of interface promotes a clean separation between implementation of clients and servers.

The Stargate open source project provides an API layer that allows you to expose a REST API on top of any Cassandra database. When the Stargate REST API is added to an existing Cassandra deployment, it automatically creates HTTP endpoints that allow you to perform create, read, update, and delete (CRUD) operations on tables in your database. You can also create new database tables directly via the API.

Astra now offers offers a REST API via Stargate, which we explore in this scenario.

We'll use the Astra REST API to:

  • Create a table and a record
  • Read the record from the table
  • Update the record
  • Delete the record

As a prerequisite, be sure to setup an Astra account and create a Cassandra as a Service database at astra.datastax.com.

This is fun and easy! We'll show you how.

Time to Complete

10 minutes

Difficulty

Beginner

Share

More Resources

Items releated to Stargate REST API

Stargate

Stargate.io

Everything you need to get up to speed on all things Stargate.

Learn More
Start Learning

Stargate Discord Server

Join our discord room to chat with the contributors and meet the community.

Start Learning
Stargate

Community

Learn about how you can get involved in the Stargate project.

Read more