Skip to content

Quick Start Guide

dotasek edited this page Feb 14, 2018 · 8 revisions

This document is here for legacy information. For the more recent info, please refer to Trying Automation in the Cytoscape Automation Wiki.


Basic Examples

The design principle of cyREST is simple: programmer-friendly, easy-to-use RESTful API for Cytoscape users. These days, almost all popular web services including Google, Twitter, and Facebook have REST API. They are following basic RESTful API design principles and once you learn one of them, it is relatively easy to learn others because they simply map their operations on data objects to basic HTTP operations, which are Create (POST), Read (GET), Update (PUT), and Delete (DELETE).

cyREST follows this design principle. All operations on Cytoscape data objects and functions are mapped to CRUD.

Examples

Before you try...

Of course, you can use web browsers like Chrome to test cyREST, but commands other than GET cannot be issued from browsers. I strongly recommend to use curl and jq to play with the basic cyREST API. Once you learn basics, you can use your favorite programming languages to write your real workflows.

Get data from Cytoscape (GET)

  • Get all networks as a list of SUIDs

GET http://localhost:1234/v1/networks


* Get Visual Style names

GET http://localhost:1234/v1/styles


* Get Visual Style named _Directed_ as JSON

GET http://localhost:1234/v1/styles/Directed


* GET list of layout algorithms

GET http://localhost:1234/v1/apply/layouts


* Apply _force-directed_ layout to network with SUID 53

GET http://localhost:1234/v1/apply/layouts/force-directed/53


### Create new objects in Cytoscape

* Send network and tables as JSON
  * Network to be sent:
  ```JSON
{
    "data": {
          "name": "my network 1"
    },
    "elements": {
          "nodes":[...],
          "edges":[...]
    }
}
POST http://localhost:1234/v1/networks

Update existing data

  • Add new nodes to existing network with SUID 52

PUT http://localhost:1234/v1/networks/52


#### Delete existing objects
* Delete all networks in current session

DELETE http://localhost:1234/v1/networks


* Delete a network with SUID 52

DELETE http://localhost:1234/v1/networks/52


* Delete a node with SUID 1200

DELETE http://localhost:1234/v1/networks/52/nodes/1200


### References
* **[Complete cyREST API v1 Documentation](http://idekerlab.github.io/cyREST)**