You do have another option. For initial testing and development, you can use our own test playground. The API server is deployed at https://xapi.fantom.network/ for regular GraphQL queries andhttps://xapi.fantom.network/graphql for Web Socket subscriptions. Feel free to connect and try your queries. Fine tune your application before committing to deploy your own instance.
Building your API server is a fairly straight forward process. First clone the repository to your local machine. Do not clone the project into $GOPATH, due to the Go modules. Instead, use any other location.
Once you have the copy on your machine, build the executable:
$ cd fantom-api-graphql
$ go build -o ./build/apiserver ./cmd/apiserver
The API server executable will be created in the <build> folder of the project. You can change the location by changing the output path in the Go building command above.
To run your copy of the API server, simply run:
The API server already contains some most common configuration options as default values and you don't have to change them most of the time. The default values are:
The network binding address is localhost.
Default listening port is 16761.
Default Lachesis IPC interface is ~/.lachesis/data/lachesis.ipc.
MongoDB connection address is mongodb://localhost:27017.
Default logging level is INFO.
If you want to change one of the default values, you need to create a configuration file. The API server can read configuration options from several configuration formats, namely JSON, TOML, YAML, HCL, envfile and Java properties config files. Please choose the one you are most familiar with. The name of the configuration file is expected to be "apiserver" with extension which corresponds with the file format of your choosing.
Example YAML file looks like this:
You can keep the config file on with the API server executable, or you can save it on the home folder under the .fantomapi sub-folder. On MacOS the expected path is Library/FantomApi.