AiiDA REST API for data queries and workflow management.
Uses pydantic for models/validation and fastapi for the ASGI application.
Serve e.g. using uvicorn.
/users(GET/POST) and/users/<id>(GET) endpointsUserpydanticmodel for validation- Automatic documentation at
http://127.0.0.1:8000/docs - Full specification at
http://127.0.0.1:8000/openapi.json
pip install aiida-restapiTo start the REST API, run:
aiida_restapi start [OPTIONS]--root-pathRoot path for the API (default: /)--hostHost to listen on (default: 127.0.0.1)--portPort to listen on (default: 8000)--read-onlyStart the API in read-only mode (default: False)--watchWatch for changes and reload (default: False)
By default, the API allows requests from localhost. You can configure the CORS policy by modifying CORS_ALLOW_ORIGIN_REGEX and/or CORS_ORIGIN_URLS in aiida_restapi/config.py. For more details, see FastAPI CORS documentation.
See the examples directory.
Resource collections use JSON:API-style query parameters:
GET /nodes?filter[node_type]=data.core.int.Int.&sort=-ctime&page[offset]=0&page[limit]=10
filter[field]=valueandfilter[field][==]=valuetest equalityfilter[field][in]=["value1","value2"]tests membershipfilter[field][<|<=|>|>=]=valuecompares numeric valuesfilter[field][like|ilike]=patternmatches strings using SQL%and_wildcardsfilter[field][contains]=["value1","value2"]tests array containmentfilter[field][of_length|shorter|longer|has_key]=valuefilters arrays and dictionariesfilter[field][!operator]=valuenegates any supported leaf operatorsort=field,-othersorts ascending and descending, respectivelypage[offset]andpage[limit]control offset paginationinclude=relationship,otherincludes related resources- Nested dictionary values use dot-separated fields, for example
filter[attributes.config.timeout][>=]=30 inandcontainsoperators, and their negated forms, require a non-empty JSON array- Values are decoded as JSON scalars when possible
- Repeated constraints are combined with AND
- Repeated
inconstraints are flattened - General boolean grouping (e.g.,
OR) is intentionally reserved forPOST /querybuilder
git clone https://github.com/aiidateam/aiida-restapi .
cd aiida-restapiTo reload the API on changes, run:
aiida_restapi start --watchWe use pre-commit to take care for the formatting, type checking and linting.
pip install -e .[pre-commit] # install extra dependencies
pre-commit run # running pre-commit on changes
pre-commit run --all-files # running pre-commit on every file
pre-commit run pylint --all-files # run only the linter on every fileOne can also set up pre-commit to be run on every commit
pre-commit install
# pre-commit uninstall # to disable it againWith tox the tests can be run
pip install tox
tox -e py311 # run all tests for Python 3.11
tox -av # see all supported environmentstox will create a custom environment to run the tests in. If you want to run the tests inside your current environment
pip install -e .[testing] # install extra dependencies
pytest -vSee the developer guide for more information.
MIT