Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

Helping platform leaders, architects, engineers, and operators build scalable real time data platforms.

1/8/2019

Reading time:2 min

rohitsakala/CassandraRestfulAPI

by John Doe

=====================DescriptionCassandraRestfulAPI project exposes the cassandra data tables and nodes with the help of Restful API's. The project follows the standard Restful API rules. This project is developed as Major project of the Cloud Computing course by Team 15. The project is developed using Python Driver provided by Datastax using Flask framework.InstallationFlask$ sudo pip install FlaskCassandraFollow these steps to install CassandraPython Cassandra DriverFollow these steps to install python cassandra driver Python Driver CassandraOther Dependenciessudo pip install flask-mongoengine sudo pip install -U flask_paginateRun the codeFirst is to start cassandra. Second is to run flask i.e python main.py. Go to https:127:0.0.1:5000/ and use the following API's.API's--- Nodes ---List all the nodes[GET] http://127.0.0.1:5000/nodes/Get info of a node[GET] http://127.0.0.1:5000/nodes/nodeidCreates a new node[POST] http://127.0.0.1:5000/nodes/Body* { 'username' : username , 'password' : password, 'ip' : ip }Delete a node[DELETE] http://127.0.0.1:5000/nodes/nodeidBody* { 'username' : username , 'password' : password }--- Keyspaces ---List all the Keyspaces[GET] http://127.0.0.1:5000/keyspaces/Get Info about a keyspace[GET] http://127.0.0.1:5000/keyspaces/keyspaceidCreates a new keyspace[POST] http://127.0.0.1:5000/keyspaces/Body* { 'name' : name , 'replicationFactor' : number }Updates the keyspace[PUT] http://127.0.0.1:5000/keyspaces/keyspaceidBody* { 'replicationFactor' : number }Deletes the keyspace[DELETE] http://127.0.0.1:5000/keyspaces/keyspaceid--- Column Family ---List all the column families of a keyspace[GET] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/Get info of a column family[GET] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyidCreates a new column family[POST] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/Body* { 'name' : name }Delete a column family[DELETE] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyid--- Row Entries ---List all the rows[GET] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyid/entrys/Get Info about a row[GET] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyid/entrys/entrynameCreates a new row[POST] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyid/entrys/Body* { 'field1' : field name , 'field1_type' : field data type .... }Deletes the row[DELETE] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyid/entrys/entryname######Note:- 10.1.36.68 is the seed ######Note:- In delete node code, path is the directory where cassandra is installed##More InfoMail :- rohitsakala@gmail.com

Illustration Image

=====================

Description

CassandraRestfulAPI project exposes the cassandra data tables and nodes with the help of Restful API's. The project follows the standard Restful API rules. This project is developed as Major project of the Cloud Computing course by Team 15. The project is developed using Python Driver provided by Datastax using Flask framework.

Installation

Flask

$ sudo pip install Flask

Cassandra

Follow these steps to install Cassandra

Python Cassandra Driver

Follow these steps to install python cassandra driver Python Driver Cassandra

Other Dependencies

sudo pip install flask-mongoengine sudo pip install -U flask_paginate

Run the code

First is to start cassandra. Second is to run flask i.e python main.py. Go to https:127:0.0.1:5000/ and use the following API's.

API's

--- Nodes ---

List all the nodes

[GET] http://127.0.0.1:5000/nodes/

Get info of a node

[GET] http://127.0.0.1:5000/nodes/nodeid

Creates a new node

[POST] http://127.0.0.1:5000/nodes/

Body
* { 'username' : username , 'password' : password, 'ip' : ip }

Delete a node

[DELETE] http://127.0.0.1:5000/nodes/nodeid

Body
* { 'username' : username , 'password' : password }

--- Keyspaces ---

List all the Keyspaces

[GET] http://127.0.0.1:5000/keyspaces/

Get Info about a keyspace

[GET] http://127.0.0.1:5000/keyspaces/keyspaceid

Creates a new keyspace

[POST] http://127.0.0.1:5000/keyspaces/

Body
* { 'name' : name , 'replicationFactor' : number }

Updates the keyspace

[PUT] http://127.0.0.1:5000/keyspaces/keyspaceid

Body
* { 'replicationFactor' : number }

Deletes the keyspace

[DELETE] http://127.0.0.1:5000/keyspaces/keyspaceid

--- Column Family ---

List all the column families of a keyspace

[GET] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/

Get info of a column family

[GET] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyid

Creates a new column family

[POST] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/

Body
* { 'name' : name }

Delete a column family

[DELETE] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyid

--- Row Entries ---

List all the rows

[GET] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyid/entrys/

Get Info about a row

[GET] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyid/entrys/entryname

Creates a new row

[POST] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyid/entrys/

Body
* { 'field1' : field name , 'field1_type' : field data type .... }

Deletes the row

[DELETE] http://127.0.0.1:5000/keyspace/keyspaceid/columnfamilys/columnfamilyid/entrys/entryname

######Note:- 10.1.36.68 is the seed ######Note:- In delete node code, path is the directory where cassandra is installed

##More Info

Mail :- rohitsakala@gmail.com

Related Articles

spring
angular
rest

GitHub - jhipster/jhipster-sample-app-cassandra: This is a sample application created with JHipster, with the Cassandra option

jhipster

3/7/2024

Checkout Planet Cassandra

Claim Your Free Planet Cassandra Contributor T-shirt!

Make your contribution and score a FREE Planet Cassandra Contributor T-Shirt! 
We value our incredible Cassandra community, and we want to express our gratitude by sending an exclusive Planet Cassandra Contributor T-Shirt you can wear with pride.

Join Our Newsletter!

Sign up below to receive email updates and see what's going on with our company

Explore Related Topics

AllKafkaSparkScyllaSStableKubernetesApiGithubGraphQl

Explore Further

rest