This guide demonstrates basic usage of FinP2P's GraphQL API.
The examples documented here can be run using:
- A curl command line.
- The GraphQL Playground.
Command Line
You can run GraphQL queries in a curl request on the command line on your local machine. A GraphQL request can be made as a POST request to /oss/query with the query as the payload.
curl 'https://demo-bank-us.api.ownera.io/oss/query' --header "Content-Type: application/json" --request POST --data "{\"query\": \"{assets {nodes { id, name }} }\"}"
GraphQL Playground
The GraphQL Playground allows you to run queries directly against the server endpoint with syntax highlighting and autocomplete. It also allows you to explore the schema and types.
Queries can be run directly against the Node's GraphQL playground under /oss
Query roots
The Query API exposes various query roots for the underlying objects that represent the FinP2P model, different query roots should be used in order to retrieve the required information, for example in order to retrieve an overview of an Asset's tokens distribution or summary over all users, querying from the Assets
root will be preferred. on the other hand, querying for a specific user holdings and summary of Asset's tokens, using the Users
query root is advised. for more information please advise the Query Examples section.
Filters and Aggregation
The Query API provides directives which allow the client to perform filtering and aggregation operations in the specified query, for query roots which accept optional Filter
or Aggregate
types the client can construct one or multiple filter objects that will be applied on the underlying data (multiple filters will be executed as an AND operations). multiple Aggregates can be provided as well, each aggregated results will be reflected in the query result AggregateResult
object which will indicate the field, aggregation operator used (e.g. SUM, COUNT) and the result of the operation, please see Query Examples section for further information.