πŸ› οΈAPI

Empower your integrations with the flexibility of GraphQL on Graph Commons.

The Graph Commons API provides developers with a powerful GraphQL interface to integrate, query, and manage data. With this API, you can automate processes, dive deep into your networks, and harness the full potential of Graph Commons directly from your applications.

GraphQL API Explorer

You can build queries, browse schemas, and test the API using the Apollo GraphQL Explorer:

πŸ‘‰πŸΌ Open in Apollo Explorerarrow-up-right

Try our Graph Commons API directly in the Apollo GraphQL Explorer

Authentication

No separate API key required, simply use your Graph Commons username and password to authenticate.

circle-info

API authentication is done with your email and password. Social logins are not supported.

Here’s a Node.js function to authenticate and retrieve a JWT token:

Create a graph

Use the login function from the authentication step to create a new graph.

circle-info

You can send your own temporary IDs for node types, edge types, nodes, and edges. The server will return an idsMapping so you can map your temp IDs to real server IDs later.

Read a graph

Use the login function from the authentication step together with a graphIdβ€”either returned from the createGraph step or any existing graph on Graph Commonsβ€”to fetch graph data.

Update a graph

You can update an existing graphβ€”adding or removing nodes, edges, properties, or adjusting node positionsβ€”using the updateGraph mutation.

Call savePatchGraph(id, patch) to create new items and/or update graph properties (such as nodesPosition). The create section should use temporary IDs, which the server will map to permanent ones in the returned idsMapping.

Reset a graph

If you want to clear all nodes and edges while preserving the existing node/edge types and their colors, call resetGraph first. Then, use savePatchGraph with create blocks to re-populate the graph.

Tips & Gotchas

  • Temp IDs in creates: In createGraph and the create section of savePatchGraph, you can use any string IDs (e.g., n_sam, et_works_at). The server returns an idsMapping to translate these to real IDs. Store them if you’ll reference the same items later.

  • Referencing existing items: When modifying existing nodes/edges, use the real IDs (from idsMapping or from a getGraphById read).

  • Positions: Set positions with either the temp node IDs (during createGraph) or the real node IDs (when updating).

  • Types vs. Instances: nodeTypes/edgeTypes define the schema. nodes/edges are your data. After a reset, types remain; nodes/edges are cleared.

  • Errors: Always check report.success and surface report.errors in logs for faster debugging.

Next steps

Last updated

Was this helpful?