Factom Open API consists of API binary, user management binary & config file.
Postgres database is required for Factom Open API. You can connect to any internal/external Postgres DB by filling the config file. Please prepare DB connection credentials for the next step.
Create any folder (e.g. ~/.foa) for config and download config template into it
mkdir ~/.foa
curl -o ~/.foa/config.yaml https://raw.githubusercontent.com/DeFacto-Team/Factom-Open-API/master/config.yaml.EXAMPLEThere are few sections into config file:
admin(Admin params)api(API params)store(DB params)factom(Factom params)
You may use custom config params: uncomment the line and put your value to override the default value.
Login & password for Admin UI. Leave empty to disable Admin UI.
By default Open API uses HTTP port 8081.
Log levels: 3 — Warn, 4 — Info, 5 – Debug, 6 – Debug+DB
Specify connection to your internal/external Postgres DB.
Entry Credits (EC) purchase fixed amounts of data in the Factom network.
You need EC address filled with Entry Credits to write data on the Factom.
- EC address may be imported or generated via Open API Admin UI
- Fund your EC address in the EC store
By default Open API is connected to Factom Open Node, that means you don't need to setup your own node on the Factom blockchain to work with blockchain. But if you want to use your own node, you may specify it into the config.
nano ~/.foa/config.yamlDownload with cURL:
curl -o foa https://github.com/DeFacto-Team/Factom-Open-API/releases/download/1.1.0/foaRun Factom Open API with default config location:
./foaBy default the binary uses the config located at <USER_FOLDER>/.foa/config.yaml. If you use custom location for config file, please don't forget to provide it with -c flag while running binaries.
./foa -c=/somewhere/placed/config.yamlThis instruction is for Linux. Setup running the Factom Open API as a daemon is needed to automatically start Factom Open API when your server starts after reboot.
Move foa binary to /usr/bin/.
It’s better to run Factom Open API as non-root user, so you need new user:
adduser foanano /etc/systemd/system/foa.serviceFill this file with the following daemon config:
[Unit]
Description=Run the Factom Open API service
Documentation=https://github.com/DeFacto-Team/Factom-Open-API
After=network-online.target
[Service]
User=foa
Group=foa
EnvironmentFile=-/etc/default/foa
ExecStart=/usr/bin/foa $FOA_OPTS
KillMode=control-group
Restart=on-failure
[Install]
WantedBy=multi-user.targetnano /etc/default/foaFill this file with FOA_OPTS param:
FOA_OPTS = ''systemctl daemon-reload
systemctl start foa
systemctl enable foa