Endpoints

Martin Linkov edited this page Jun 27, 2018 · 37 revisions

There are 7 API endpoints available:

All paths are relative to: http://gcp.unigraph.rocks/api

All endpoints return a JSON formatted response.

Many of the examples described in the wiki are included in this Postman Collection

The endpoints are designed to perform a particular task very quickly. The result from one can be passed to another for additional analysis and extraction, see the examples below:


Displaying related entities from the broader context

Sending this text "Paris is the oldest daughter of Richard Hilton" to the /context endpoint like so:

<<<<<<< Updated upstream

<<<<<<< HEAD

curl -X POST -H 'max:n' -H 'X-Unigraph-API-Key: [YOUR-API-KEY]' -d 'Paris is the oldest daughter of Richard Hilton' http://gcp.unigraph.rocks/api/context/text
=======
>>>>>>> Stashed changes
```bash
curl -X POST \
 http://try.unigraph.rocks/api/context/text \
 -H 'max:n' \
 -H 'X-Unigraph-API-Key: [YOUR-API-KEY]' \
 -d 'Paris is the oldest daughter of Richard Hilton' 
<<<<<<< Updated upstream
=======
>>>>>>> origin/master
>>>>>>> Stashed changes

Produces this result:

[  
   {  
      "uid":"2001fa0e79e1",
      "weight":1,
      "stated":"Richard Hilton",
      "edges":[  
         "12fa0773bf",
         "12fa2518dc",
         "12f9a255",
         "12fa124061",
         "2001f9b22b",
         "2001fa034cea",
         "12fa034a4b",
         "12fafe9d70",
         "2001fa0c580b",
         "2001fa041e16",
         "12fa26281e",
         "12fa075ea4",
         "1205",
         "12f91357",
         "12fa05e6a4",
         "12fb010bda1e",
         "121e",
         "2004fa0b0ba2",
         "12f98040"
      ]
   },
   {  
      "uid":"2001f9b22b",
      "weight":1,
      "stated":"Paris Hilton",
      "edges":[  
         "12fa0773bf",
         "12fa2518dc",
         "12f9a255",
         "12fa124061",
         "2001fa034cea",
         "12fa034a4b",
         "12fafe9d70",
         "2001fa041e16",
         "12fa26281e",
         "12fa075ea4",
         "1205",
         "12f91357",
         "12fa05e6a4",
         "12fb010bda1e",
         "2001fa0e79e1",
         "121e",
         "2001fa14bf88",
         "2001fa1c4a07",
         "12f98040",
         "12fa0201c4"
      ]
   },
   {  
      "uid":"2001fa034cea",
      "weight":0.26925683306979875,
      "edges":[  
         "12fa0773bf",
         "12fa2518dc",
         "12f9a255",
         "12fa124061",
         "2001f9b22b",
         "12fa034a4b",
         "12fafe9d70",
         "2001fa041e16",
         "12fa26281e",
         "12fa075ea4",
         "1205",
         "12f91357",
         "12fa05e6a4",
         "12fb010bda1e",
         "2001fa0e79e1",
         "121e",
         "2001fa1c4a07",
         "12f98040"
      ]
   },
   {  
      "uid":"2001fa041e16",
      "weight":0.24486107973797144,
      "edges":[  
         "12fa0773bf",
         "12fa2518dc",
         "12f9a255",
         "12fa124061",
         "2001f9b22b",
         "2001fa034cea",
         "12fafe9d70",
         "1205",
         "12f91357",
         "12fa05e6a4",
         "12fb010bda1e",
         "2001fa0e79e1",
         "121e",
         "2004fa0b0ba2",
         "2001fa1c4a07",
         "12f98040"
      ]
   },
   {  
      "uid":"121e",
      "weight":0.21368872825841417,
      "edges":[  
         "12fa034a4b",
         "12fa26281e",
         "12fa075ea4",
         "12f98040",
         "12fa0201c4"
      ]
   }...
]

Richard Hilton and Paris Hilton are correctly identified and listed with their uids: 2001fa0e79e1 Richard and 2001f9b22b Paris.

Now, we can use the /query and ask for their images, like so:

query Richard {
  node(uid: "2001fa0e79e1") {
    image {
      url
    }
  }
}

query Paris {
  node(uid: "2001f9b22b") {
    image {
      url
    }
  }
}

Apart from Richard and Paris, there are other nodes, returned. Lets learn more about them. Lets get the label and image of 2001fa034cea:

{
  node(uid: "2001fa034cea") {
    label.en
    image {
      url
    }
  }
}

It turns out, that 2001fa034cea is Nicky Hilton.

Now, lets see how Nicky Hilton connects with Richard and Paris. For this we'll use the /relations endpoint:

<<<<<<< Updated upstream
curl -X GET \
 'http://try.unigraph.rocks/api/relations/2001fa034cea/2001fa0e79e1?resolve' \
 -H 'X-Unigraph-API-Key: [YOUR-API-KEY]'
=======
<<<<<<< HEAD
curl -X POST -H 'X-Unigraph-API-Key: [YOUR-API-KEY]' "http://gcp.unigraph.rocks/api/relations/2001fa034cea/2001fa0e79e1?resolve"
=======
curl -X GET \
 'http://try.unigraph.rocks/api/relations/2001fa034cea/2001fa0e79e1?resolve' \
 -H 'X-Unigraph-API-Key: [YOUR-API-KEY]'
>>>>>>> origin/master
>>>>>>> Stashed changes

The response tells us that Richard Hilton is the father of Nicky Hilton:

{  
   "father":[  
      "20f36445b7ec54618946884ccce4623c"
   ],
   "parent":[  
      "20f7c6d603231f25c53f8ef5cbf81445"
   ],
   "relative":[  
      "20f8b2dd997d83a5d61737a91ff99512"
   ]
}

Useful, given our initial query: "Paris is the oldest daughter of Richard Hilton". While it was obvious for a human that Richard Hilton has at leas one more child, a computer could not have done that deduction. Now it can!

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.