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), Workflows.
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 …
Subpackages¶
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'¶
-
-
class
aiida.restapi.api.
App
(*args, **kwargs)[source]¶ Bases:
flask.app.Flask
Basic Flask App customized for this REST Api purposes
-
__module__
= 'aiida.restapi.api'¶
-
Resources for REST API
-
class
aiida.restapi.resources.
BandsData
(**kwargs)[source]¶ Bases:
aiida.restapi.resources.Data
-
__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.
-
__module__
= 'aiida.restapi.resources'¶
-
methods
= ['GET']¶
-
-
class
aiida.restapi.resources.
Calculation
(**kwargs)[source]¶ Bases:
aiida.restapi.resources.Node
-
__module__
= 'aiida.restapi.resources'¶
-
methods
= ['GET']¶
-
-
class
aiida.restapi.resources.
CifData
(**kwargs)[source]¶ Bases:
aiida.restapi.resources.Data
-
__module__
= 'aiida.restapi.resources'¶
-
methods
= ['GET']¶
-
-
class
aiida.restapi.resources.
Code
(**kwargs)[source]¶ Bases:
aiida.restapi.resources.Node
-
__module__
= 'aiida.restapi.resources'¶
-
methods
= ['GET']¶
-
-
class
aiida.restapi.resources.
Computer
(**kwargs)[source]¶ Bases:
aiida.restapi.resources.BaseResource
-
__module__
= 'aiida.restapi.resources'¶
-
methods
= ['GET']¶
-
-
class
aiida.restapi.resources.
Data
(**kwargs)[source]¶ Bases:
aiida.restapi.resources.Node
-
__module__
= 'aiida.restapi.resources'¶
-
methods
= ['GET']¶
-
-
class
aiida.restapi.resources.
Group
(**kwargs)[source]¶ Bases:
aiida.restapi.resources.BaseResource
-
__module__
= 'aiida.restapi.resources'¶
-
methods
= ['GET']¶
-
-
class
aiida.restapi.resources.
KpointsData
(**kwargs)[source]¶ Bases:
aiida.restapi.resources.Data
-
__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”
-
__module__
= 'aiida.restapi.resources'¶
-
methods
= ['GET']¶
-
-
class
aiida.restapi.resources.
ServerInfo
(**kwargs)[source]¶ Bases:
flask_restful.Resource
-
__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
-
__module__
= 'aiida.restapi.resources'¶
-
methods
= ['GET']¶
-
-
class
aiida.restapi.resources.
UpfData
(**kwargs)[source]¶ Bases:
aiida.restapi.resources.Data
-
__module__
= 'aiida.restapi.resources'¶
-
methods
= ['GET']¶
-
-
class
aiida.restapi.resources.
User
(**kwargs)[source]¶ Bases:
aiida.restapi.resources.BaseResource
-
__module__
= 'aiida.restapi.resources'¶
-
methods
= ['GET']¶
-
-
aiida.restapi.run_api.
run_api
(App, Api, *args, **kwargs)[source]¶ Takes a flask.Flask instance and runs it. Parses command-line flags to configure the app.
App: Class inheriting from Flask app class Api = flask_restful API class to be used to wrap the app
args: required by argparse
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 default_host: self-explainatory default_port: self-explainatory default_config_dir = directory containing the config.py file used to configure the RESTapi parse_aiida_profile= if True, parses an option to specify the AiiDA profile All other passed parameters are ignored.