aiida.restapi package

In this module, AiiDA provides REST API to access different AiiDA nodes stored in database. The REST API is implemented using Flask RESTFul framework. The REST urls provided for node types Computer, Node (Calculation , Data, Code).

Examples:

Computers:
http://localhost:5000/computers?(COLUMN_FILTERS)&(LIMIT)&(OFFSET)?(ORDERBY) http://localhost:5000/computers/1
NODES / CALCULATIONS / DATAS / CODES:

(replace nodes with calculations/datas/codes) http://localhost:5000/nodes?(COLUMN_FILTERS)&(LIMIT)&(OFFSET)&(SORT)

OR http://localhost:5000/nodes/pages?(COLUMN_FILTERS)&(PER_PAGE)&(SORT) http://localhost:5000/nodes/pages/1?(COLUMN_FILTERS)&(PER_PAGE)&(SORT)

http://localhost:5000/nodes/1 http://localhost:5000/nodes/1/io http://localhost:5000/nodes/1/io/inputs http://localhost:5000/nodes/1/io/inputs?(COLUMN_FILTERS) http://localhost:5000/nodes/1/io/outputs http://localhost:5000/nodes/1/io/outputs?(COLUMN_FILTERS) http://localhost:5000/nodes/1/contents/attributes http://localhost:5000/nodes/1/contents/attributes?alist=abc http://localhost:5000/nodes/1/contents/attributes?nalist=c,d http://localhost:5000/nodes/1/contents/extras http://localhost:5000/nodes/1/contents/extras?elist=a,b,c http://localhost:5000/nodes/1/contents/extras?nelist=c,d

Submodules

Implementation of RESTful API for materialscloud.org based on flask + flask_restful module For the time being the API returns the parsed valid endpoints upon GET request Author: Snehal P. Waychal and Fernando Gargiulo @ Theos, EPFL

class aiida.restapi.api.AiidaApi(app=None, **kwargs)[source]

Bases: flask_restful.Api

AiiDA customized version of the flask_restful Api class

__init__(app=None, **kwargs)[source]

The need to have a special constructor is to include directly the addition of resources with the parameters required to initialize the resource classes.

Parameters:kwargs – parameters to be passed to the resources for configuration and PREFIX
__module__ = 'aiida.restapi.api'
handle_error(e)[source]

this method handles the 404 “URL not found” exception and return custom message :param e: raised exception :return: list of available endpoints

class aiida.restapi.api.App(*args, **kwargs)[source]

Bases: flask.app.Flask

Basic Flask App customized for this REST Api purposes

__init__(*args, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.api'

Resources for REST API

class aiida.restapi.resources.BandsData(**kwargs)[source]

Bases: aiida.restapi.resources.Data

Resource for Bands data

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
methods = {'GET'}
class aiida.restapi.resources.BaseResource(**kwargs)[source]

Bases: flask_restful.Resource

Each derived class will instantiate a different type of translator. This is the only difference in the classes.

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
get(id=None, page=None)[source]

Get method for the resource :param id: node identifier :param page: page no, used for pagination :return: http response

methods = {'GET'}
class aiida.restapi.resources.Calculation(**kwargs)[source]

Bases: aiida.restapi.resources.Node

Resource for Calculation

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
methods = {'GET'}
class aiida.restapi.resources.CifData(**kwargs)[source]

Bases: aiida.restapi.resources.Data

Resource for cif data

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
methods = {'GET'}
class aiida.restapi.resources.Code(**kwargs)[source]

Bases: aiida.restapi.resources.Data

Resource for Code

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
methods = {'GET'}
class aiida.restapi.resources.Computer(**kwargs)[source]

Bases: aiida.restapi.resources.BaseResource

Resource for Computer

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
methods = {'GET'}
class aiida.restapi.resources.Data(**kwargs)[source]

Bases: aiida.restapi.resources.Node

Resource for Data node

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
methods = {'GET'}
class aiida.restapi.resources.Group(**kwargs)[source]

Bases: aiida.restapi.resources.BaseResource

Resource for Group

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
methods = {'GET'}
class aiida.restapi.resources.KpointsData(**kwargs)[source]

Bases: aiida.restapi.resources.Data

Resource for kpoints data

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
methods = {'GET'}
class aiida.restapi.resources.Node(**kwargs)[source]

Bases: flask_restful.Resource

Differs from BaseResource in trans.set_query() mostly because it takes query_type as an input and the presence of additional result types like “tree”

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
get(id=None, page=None)[source]

Get method for the Node resource.

Parameters:
  • id – node identifier
  • page – page no, used for pagination
Returns:

http response

methods = {'GET'}
class aiida.restapi.resources.ServerInfo(**kwargs)[source]

Bases: flask_restful.Resource

Endpointd to return general server info

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
get()[source]

It returns the general info about the REST API :return: returns current AiiDA version defined in aiida/__init__.py

methods = {'GET'}
class aiida.restapi.resources.StructureData(**kwargs)[source]

Bases: aiida.restapi.resources.Data

Resource for structure data

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
methods = {'GET'}
class aiida.restapi.resources.UpfData(**kwargs)[source]

Bases: aiida.restapi.resources.Data

Resource for upf data

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
methods = {'GET'}
class aiida.restapi.resources.User(**kwargs)[source]

Bases: aiida.restapi.resources.BaseResource

Resource for User

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'aiida.restapi.resources'
methods = {'GET'}

It defines the method with all required parameters to run restapi locally.

aiida.restapi.run_api.run_api(flask_app, flask_api, **kwargs)[source]

Takes a flask.Flask instance and runs it.

flask_app: Class inheriting from Flask app class flask_api = flask_restful API class to be used to wrap the app

kwargs: List of valid parameters: prog_name: name of the command before arguments are parsed. Useful when api is embedded in a command, such as verdi restapi hostname: self-explainatory port: self-explainatory config: directory containing the config.py file used to configure the RESTapi catch_internal_server: If true, catch and print all inter server errors debug: self-explainatory wsgi_profile:to use WSGI profiler middleware for finding bottlenecks in web application hookup: to hookup app All other passed parameters are ignored.