Skip to content

CSV Formatting

Normally, a graph query will be returned as a nested JSON-serialized object graph. This representation truthfully maps the data to the structure of the query. Sometimes however, it’s more useful to retrieve the data as a 2D CSV table.

How to Request CSV Result

There are two ways to tell the graph query API that you want the result as csv:

  • Add a ?format=csv query parameter to the /resources/graph endpoint request
  • Add a Accept: text/csv header in the /resources/graph endpoint request

Limitations

When returning CSV, it’s important to understand the limitations:

  • Only a single query can be included in the request
  • For any navigations, only the first “many” navgiation on the same level will be expanded. If there are more, only the first node will be returned.
  • Total count is only available of the root node

Pagination

The total count, as well as the first/last cursors are returned as HTTP headers:

  • Total-Count - The total number of available nodes (only available if queried with "getTotalCount": true)
  • First-Cursor - The cursor of the first node
  • Last-Cursor - The cursor of the last node

Query Overrides

To simplify pagination, the after and before properties of the root query can be overridden using query parameters. This allows you to paginate without having to update the root query.

For example:

POST https://<hantera-hostname>/resources/graph?csv&after=<cursor>
Authorization: Bearer <YOUR TOKEN>
Content-Type: application/json
[{
"edge": "deliveries",
"alias": "d",
"getTotalCount": true,
"node": {
"fields": ["deliveryNumber"],
"navigate": [
{
"edge": "order",
"alias": "o",
"node": {
"fields": ["orderNumber"],
}
}
]
}
}]