Graph

The Graph API is the interface that most users will interact with to query Open Ed Graph collections. We recommend using the graph to query for data on an as-needed basis instead of fetching the entire dataset in one go for several reasons: firstly, to download the entire dataset in one go takes a long time and will leave your front end applications waiting; querying the graph also requires you to write multiple graph traversal code in multiple applications and finally, using the Graph query ensures you get back the same result everytime.

The Syntax

Every request to the Graph endpoint is a POST request, where data passed in the body of the request contains the fields you want. For example, suppose you have an entity with id=3. You want to fetch all nodes that are outgoing from this node due to only prerequisite relationships (not any other type of relationship). Furthermore, you want to get all assessments that are associated with all the outcomes that are on this path, with a limit of 2 assessments per outcome.

The syntax for this particular request then is:


  {
    entityId: '3',
    pathType: "OUTGOING_ALL",
    relationshipType: "HAS_PREREQUISITE_OF",
    assessments: {
      forEntity: 'ALL',
      numEach: 'ALL'
    }
  }

which gives you a response of:


  {
    {
      "entities": [Entity],
      "relationships": [Relationship],
      "assessments": [ Assessment ],
      "pathType": String,
      "relationshipType": String,
    }
  }

Body fields

The following fields in the body field are recognized:

  • entityId:
  • pathType:
  • relationshipType:
  • assessments:

Post graph

POST /graph/:bucketId

NodeJS

CURL

Python


  const rp = require('request-promise');

  rp({
    method: 'POST',
    url: `/api/graph/${bucketId}`,
    headers: {
      authorization: `Bearer ${token}`
    },
    body: ...fields
  })