Introduction

Sauron is the GraphQL API your application’s server will call to request the data you seek using the data key.

Check out the GraphQL Schema Reference to see details on all Queries, Mutations, Types and their descriptions.

Sauron Helper Packages

We provide packages that makes it super easy to interact with the Sauron API. They completely abstract away the complexity of authentication and interacting with the GraphQL APIs.

Installation

npm i -g @gandalf-network/eyeofsauron

eyeofsauron generate

This will generate an eyeofsauron folder in your project root directory.

Usage

Import the package

// Typescript
import Eye, { Source } from './eyeofsauron';
// ESModules
import Eye, { Source } from './eyeofsauron/index.js';
// CommonJS
const Eye = require('./eyeofsauron').default
const { Source } = require('./eyeofsauron');

Get Activity

const eye = new Eye({privateKey: process.env.PRIVATE_KEY})

const { data } = await eye.getActivity({dataKey: dataKey,  source: Source.Amazon, limit: 100, page: 2})

Get Traits

const { data: traits } = await eye.getTraits({
    dataKey: dataKey,
    source: Source.UBER,
    labels: [TraitLabel.RATING, TraitLabel.TRIP_COUNT],
})

Read more on Github.


Roll Your Own

Every request to the Sauron API needs to be authenticated using your privateKey. This is required to validate that the data request is truly coming from your application.

The packages above handle all of this authentication stuff automagically! You might want to consider using them instead.
1

Prepare the signature

Start by creating a digital signature of your request’s body. You’ll need to hash the body of your request using SHA-256 and then sign the hash with ECDSA using your privateKey.

2

Encode the signature

After signing, encode the digital signature using Base64.

3

Add signature header

Add the Base64-encoded signature to the request’s headers with the key X-Gandalf-Signature.

Securing your privateKey is extremely important. All requests to Sauron should be made server-side.

See example code snippets:

Every Query or Mutation in the Sauron GraphQL API is accessible in the helper packages as a function/method. You can read about all Queries, Mutations & Types in the Schema Reference.