Using the REST API
These sections will cover the usage of the Gaffer REST API to perform queries and operations on a graph. This guide should cover a lot of the use cases a user may face; however please refer to the reference guide for a full list of what is possible.
What is the REST API?
When a graph is deployed, a REST (or RESTful) API will be available at a predefined address. This provides an application programming interface (API) that a user or computer can interact with to send and receive data between them and the application.
In Gaffer, the REST API consists of various predefined HTTP requests known as
endpoints that can be used to interact with a running graph instance. These
endpoints are accessed either by sending a crafted HTTP request to them e.g.
with a tool like curl
or more
commonly by the provided Swagger UI.
Querying a Graph
If you wish to simply run a query which gets some information about the graph instance, such
as what schema is being used or what Operations are available, then there
should already be GET
endpoints to do that. Executing any of these GET
requests will simply 'get' you some information, however they may be of limited
use for a user.
The main endpoint users interact with is /graph/operations/execute
. This
is a POST
endpoint which allows you to 'post' a query to that endpoint which
then responds back with data.
In Gaffer, JSON is the main interchange language which means you can post JSON and get response back in it.
Tip
See the what is JSON guide for a short introduction to the language.
Generally a query consists of two parts an Operation
or OperationChain
and
optionally some sort of filtering provided by a View
. These parts are
discussed in more detail further in the guide so please see the page covering
Operations and this page on
filtering using views.