Skip to content

building-envelope-data/api

Repository files navigation

buildingenvelopedata.org API specification

This specification of an Application Programming Interface (API) is designed to facilitate the exchange of data about building envelopes. Several databases use the same API specification to offer data about components. A metabase manages for example the identifiers of components and institutions which must be the same for all databases.

This API specification consists of GraphQL schemas to specify a GraphQL endpoint and JSON Schemas to specify the format of the responses. GraphQL schemas are in the directory ./apis. There is a visualization of the GraphQL schema of the metabase and of the database. Example GraphQL queries in the directory ./queries. You can try the queries of the tutorial at the GraphQL endpoint of the metabase.

JSON schemas are in the directory ./schemas and example JSON files in the directory ./examples. The directory ./tests/valid provides test JSON files that are supposed to be valid and the directory ./tests/invalid JSON files that are supposed to be invalid. A visualization of the JSON Schema of an optical data point is available together with visualizations of examples of optical data points. A visualization of the JSON Schema of a calorimetric data set is available together with visualizations of examples of calorimetric data sets.

The following introduction explains the structure for new users and the section "On your Linux machine" explains how you can work with the API specification.

Watch the video introduction

Table Of Contents

I don't want to read this whole thing, I just have a question!

Introduction

How to use this repository

Code of Conduct

Implementation of the API specification

How to contribute

I don't want to read this whole thing, I just have a question!

If you have a question, please read this README.md and search this repository with its wiki, discussions, Questions and Answers and existing issues for the answer.

If you don't find the answer there and if your question is related to the code, please raise a new issue and add the tag question.

Introduction

The example JSON files ./examples present examples of data formatted according to the JSON schemas and could be part of the response of a GraphQL endpoint. For example, nearnormalHemisphericalSolarReflectanceAccordingToStandard.json is an example of data about a component with an identifier and an optical data set.

Like all data about components, the example is valid against the schema component.json which references optical.json, calorimetric.json and more. In this way, metadata about one component can be exchanged as well as optical data, calorimetric data and more about this component.

An optical data set can include metadata like the standard according to which the optical data was determined. The pure optical data is formatted according to opticalData.json, because optical.json references opticalData.json.

Similarly, calorimetric.json defines the metadata about a calorimetric data set and refers to calorimetricData.json for the pure calorimetric data which is illustrated by the example bistMeasurement.json.

How to use this repository

For beginners

With you web browser, you can search our wiki, the issues and pull requests and contribute to them.

In order to browse the code conveniently, you should first clone the repository and then use a text editor, for example Visual Studio Code.

On your Linux machine

In order to use our development tooling, for example, to format code and to run tests, follow the instructions below.

  1. Open your favorite shell, for example, good old Bourne Again SHell, aka, bash, the somewhat newer Z shell, aka, zsh, or shiny new fish.
  2. Install Git by running
    sudo apt install git-all
    on Debian-based distributions like Ubuntu, or
    sudo dnf install git
    on Fedora and closely-related RPM-Package-Manager-based distributions like CentOS. For further information see Installing Git.
  3. Clone the source code by running
    git clone git@github.com:building-envelope-data/api.git
    and navigate into the new directory building-envelope-data by running
    cd building-envelope-data
  4. Prepare your environment by running
    cp /.env.sample /.env
    and adjusting the copied environment to your needs.

With Docker

  1. Install Docker Desktop, and GNU Make.
  2. List all GNU Make targets by running
    make help
    The targets name, tag, build, remove, run, shell, remove-containers, remove-volumes, and serve can be used to interface with Docker. The other ones can be used within bash inside a Docker container:
    • compile validates the JSON schemas against the JSON Schema meta-schemas and the GraphQL schemas against the GrahpQL specification,
    • test validates the tests against the schemas,
    • example validates the examples against the schemas,
    • format formats source files,
    • introspect introspects the GraphQL schemas,
    • dos2unix converts Windows-style to UNIX-style line endings,
    • install-tools installs development tools from the lock file, and
    • update-tools updates development tools to the latest compatible minor versions.
  3. Drop into bash with the working directory /app, which is mounted to the host's working directory, inside a fresh Docker container based on Debian Linux everything installed by running
    make shell
    If necessary, the Docker image is (re)built automatically, which takes a while the first time.
  4. Do something with the project like validating the schemas by running
    make compile
  5. Drop out of the container by running
    exit
    or pressing Ctrl-D.

Without Docker

  1. Install GNU Bash, GNU Make, and npm.
  2. Install the development tools in package.json by running
    make install-tools
    
    which in particular installs the command-line interface for Another JSON Schema Validator (AJV), namely ajv-cli as Node package to be executed through npx, for example,
    npx ajv --help
    
  3. Drop into bash.
  4. Do something with the project as elaborated above.

Note that another POSIX-compatible shell than GNU Bash should also do. See also the POSIX specification and the POSIX FAQ.

Also note that GNU Make takes the shell from the variable SHELL or, if not set, the program /bin/sh. See Choosing the Shell

Code of Conduct

Our Code of Conduct is the guideline of our collaboration.

Implementation of the API specification

A database which implements this API specification is presented by https://github.com/building-envelope-data/database . A metadatabase wich implements this API specification is presented by https://www.buildingenvelopedata.org/ (front end) https://www.buildingenvelopedata.org/graphql/ (back end) and https://github.com/building-envelope-data/metabase (source code). The metadatabase manages for example the identifiers for components and institutions which must be the same for all databases. The databases manage the data sets of the components.

How to contribute

If you are interested to contribute by questions, reporting bugs or suggesting enhancements, please see CONTRIBUTING.md for further details.