Description
Heart API is a runner module of Heart, which exposes an HTTP API that starts an analysis when it is requested.
Note that you must install an analysis module too, to have a minimum viable installation of Heart.
Read more about the description and design of Heart.
Usage
-
Install the package and an analysis module, for example Heart GreenIT
npm install @fabernovel/heart-api @fabernovel/heart-greenit
If you are using Yarn, npm < 7 or PNPM < 8, you also have to install Heart CLI (which is automatically installed in more recent versions of these packages managers):
npm install @fabernovel/heart-cli
-
Start the server
npx heart api
You now have an HTTP server listening to
127.0.0.1:3000
, with a/greenit
endpoint where you couldPOST
your analysis configuration (JSON-formatted) to start an analysis.You can change the default port with the
--port
option, and specify HTTP CORS headers with the--cors
one. -
Start an analysis
POST /greenit Content-type: application/json { "config": { "url": "https://www.fabernovel.com" } }
The analysis configuration set with the request's body follows the JSON format, and depends of the analysis module; read their README.