Introduction
Graph API Data is a high-performance graph database platform accessible via REST and GraphQL. This guide will get you up and running in minutes.
Installation
Install the official Graph API Data SDK for your language of choice:
bash
# Node.js / TypeScript
npm install @Graph API Data/sdk
# Python
pip install Graph API Data
# Go
go get github.com/Graph API Data/Graph API Data-go
Authentication
All API requests must include your API key in the Authorization header. You can find your API keys in the dashboard.
Keep your API key secret. Never commit it to version control. Use environment variables in production.
javascript
import { Graph API Data } from '@Graph API Data/sdk';
const gd = new Graph API Data({
apiKey: process.env.Graph API Data_API_KEY, // gd_live_xxxxx
region: 'us-east-1', // optional
});
Your First Query
Once authenticated, you can start querying your graphs. Here's a simple node lookup and a traversal:
javascript
// Get a single node by ID
const user = await gd.nodes.get({
graph: 'social_network',
id: 'user_42',
});
// { id: 'user_42', name: 'Alice', age: 28, ... }
// Traverse outgoing FOLLOWS edges to depth 2
const network = await gd.traverse({
graph: 'social_network',
start: 'user_42',
edge: 'FOLLOWS',
direction: 'outgoing',
depth: 2,
});
// â { nodes: [...], edges: [...], took: '1.2ms' }
Traversal Parameters
| Parameter | Type | Description |
|---|---|---|
| graph required | string | The name of the target graph database. |
| start required | string | The starting node ID for the traversal. |
| edge | string | string[] | Edge type(s) to follow. If omitted, all edge types are traversed. |
| direction | 'outgoing' | 'incoming' | 'both' | Direction to traverse edges. Defaults to 'outgoing'. |
| depth | number | Maximum traversal depth (hops). Defaults to 1, max 10. |
| limit | number | Max nodes to return. Defaults to 1000, max 100000. |
| filter | object | Property filters to apply on traversed nodes or edges. |
For traversals deeper than depth 5, we recommend adding a
filter to reduce result size and improve performance.
Error Handling
The SDK throws typed errors for all failure cases. Always wrap your queries in try/catch:
javascript
try {
const result = await gd.traverse({ ... });
} catch (err) {
if (err.code === 'GRAPH_NOT_FOUND') { ... }
if (err.code === 'RATE_LIMIT_EXCEEDED') { ... }
if (err.code === 'UNAUTHORIZED') { ... }
}