Accessing Cassandra with REST APIs

If you are moving into the cloud-native world, you need a microservices-based architecture that allows you to scale pieces of your architecture independently. APIs like REST make this possible.

Get Started
Introduction

Introduction

An important aspect of microservices design is to make them stateless. This allows services to scale readily. However, apps need state! Microservices store their state in persistent storage services - services built on scalable databases like Cassandra.

Next concept: Why REST for Cassandra?

Why REST for Cassandra?

REST is currently the dominant API style. Cassandra lets you scale your storage needs. The marriage of a RESTful interface to Cassandra means you get all the benefits of scale with an interface you already know how to use. And, because you already know how to use REST APIs (and if you don’t, here’s a link you can quickly integrate these benefits into your applications.

Next concept: How to Get REST with Cassandra
Why REST for Cassandra?
How to Get REST With Cassandra

How to Get REST With Cassandra

You have a couple of choices on how to get REST with Cassandra. Of course you can build your own RESTful service on top of your Cassandra cluster - here’s an example. Or, if you don’t have a Cassandra cluster and want one, you can create an Astra database for free online, which also gives you a REST API.

Here’s an example of REST access using JavaScript:

Bash
// REST
// @param Array primary_key
// @param Array return_fields
async rest_read( primary_key, return_fields = [] ){
  if( return_fields.length ) console.log('REST API does not currently support specifying return fields')
  let result = await get()( `${restURL}/v1/keyspaces/${keyspace}/tables/${this.tablename}/rows/${primary_key.join(';')}` )
  if( result && result.rows && result.rows.length ){
    return result.rows
  } else {
    return []
  }
}

Skill Building

Try The Astra REST API Service for yourself - it allows you to scale your databases horizontally quickly, and easily. Give it a try!

Continue Your Journey

How to Create a REST API for Your Database

How to Create a REST API for Your Database

Cedrick Lunven shows how to create APIs for your distributed database including REST, gRPC and GraphQL.

Watch Now
Cassandra Microservices on GitHub

Cassandra Microservices on GitHub

This repository contains sample inventory microservices to demonstrate how to use Spring, Kubernetes and Cassandra together a single stack.

Download Now
Visit The RESTful Site

Visit The RESTful Site

Understand REST and its guiding principles.

Explore

More Resources

Items releated to REST

REST API concepts and examples
Rest

REST API concepts and examples

Learn REST API concepts by making example calls to Facebook's Graph API, Google Maps' API, Instagram's Media Search API, and Twitter's Status Update API.

Watch Now
What is REST
Rest

What is REST

Learn about how to design web services using the REST paradigm.

Start Learning
Understanding Using RESTful APIs
Rest

Understanding Using RESTful APIs

learn everything you need to know about REST APIs to be able to read API documentations and use them effectively.

Read More

Chrome Web Store: Talend API Tester