Report Issue Edit Page



All clients can communicate with the server via the HTTP endpoint (set with option --port when starting Dgraph). Queries and mutations can be submitted and JSON is returned.

Go clients can use the clients package and communicate with the server over gRPC. Internally this uses Protocol Buffers and the proto file used by Dgraph is located at graphresponse.proto.




The go client communicates with the server on the grpc port (set with option --grpc_port when starting Dgraph).


Go get the client:

go get -u -v


The client GoDoc has specifications of all functions and examples.

Larger examples can be found here. And this blog post explores the examples further.

The app dgraphloader uses the client interface to batch concurrent mutations.

Note As with mutations through a mutation block, schema type needs to be set for the edges, or schema is derived based on first mutation received by the server.


Incomplete A lot of development has gone into the Go client and the Python client is not up to date with it. We are looking for help from contributors to bring it up to date.


Via pip
pip install -U pydgraph
By Source
  • Clone the git repository for python client from github.
git clone
cd pydgraph

# Optional: If you have the dgraph server running on localhost:8080 and localhost:9080 you can run tests.
python test

# Install the python package.
python install


In [1]: from pydgraph.client import DgraphClient
In [2]: dg_client = DgraphClient('localhost', 8080)
In [3]: response = dg_client.query("""
                <alice> <name> \"Alice\" .
                <greg> <name> \"Greg\" .
                <alice> <follows> <greg> .

            me(_xid_: alice)
                    name _xid_
In [4]: print response
n {
  uid: 10125359828081617157
  attribute: "_root_"
  children {
    uid: 6454194656439714227
    xid: "greg"
    attribute: "follows"
    properties {
      prop: "name"
      val: "Greg"
l {
  parsing: "8.64014ms"
  processing: "302.099\302\265s"
  pb: "10.422\302\265s"


Incomplete A lot of development has gone into the Go client and the Java client is not up to date with it. We are looking for help from contributors to bring it up to date.


Currently, given that this is the first version, the distribution is done via a fatJar built locally. The procedure to build it is:

# Get code from Github
git clone [email protected]:dgraph-io/dgraph4j.git
cd dgraph4j

# Build fatJar, from the repository
./gradlew fatJar

# Copy fatJar to your CLASSPATH were it will be included
cp dgraph4j/build/libs/dgraph4j-all-0.0.1.jar $CLASSPATH


You just need to include the fatJar into the classpath, the following is a simple example of how to use it:

  • Write (assuming Dgraph contains the data required for the query):
import io.dgraph.client.DgraphClient;
import io.dgraph.client.GrpcDgraphClient;
import io.dgraph.client.DgraphResult;

public class DgraphMain {
    public static void main(final String[] args) {
        final DgraphClient dgraphClient = GrpcDgraphClient.newInstance("localhost", 9080);
        final DgraphResult result = dgraphClient.query("{me(_xid_: alice) { name _xid_ follows { name _xid_ follows {name _xid_ } } }}");
  • Compile:

    javac -cp dgraph4j/build/libs/dgraph4j-all-0.0.1.jar
  • Run:

    java -cp dgraph4j/build/libs/dgraph4j-all-0.0.1.jar:. DgraphMain
    Jun 29, 2016 12:28:03 AM io.grpc.internal.ManagedChannelImpl <init>
    INFO: [[email protected]] Created with target localhost:9080


This client requires commands which are often already installed on a Dgraph server or a client machine.

Verify that your installation has the required commands.

curl   -V 2>/dev/null || wget    -V
python -V 2>/dev/null || python3 -V
less   -V 2>/dev/null || more    -V

Your first choices are curl, python and less, however you can substitute the alternatives: wget for curl, python3 for python, and more for less.

If you are missing both of a pair of alternates, you will need to install one of them. If both are available, you may use either.

Notice that we wrap the query text in $'…'. This preserves newlines in the quoted text. This is not strictly necessary for queries, but is required by the RDF format used with mutates.

The json.tool module is part of the standard release package for python and python3.


This example, from Get Started, Movies by Steven Spielberg, uses commands commonly available on a Dgraph server to query the local Dgraph server.

curl localhost:8080/query -sS -XPOST -d $'{
  director(allofterms("name", "steven spielberg")) {
    [email protected] (orderdesc: initial_release_date) {
      [email protected]
}' | python -m json.tool | less

And here using all alternatives.

wget localhost:8080/query -q -O- --post-data=$'{
  director(allofterms("name", "steven spielberg")) {
    [email protected] (orderdesc: initial_release_date) {
      [email protected]
' | python3 -m json.tool | more