Overview
VIDEO
Get your API Keys
Connect App Clip & Instant App
Simply launch the Connect in your application using a URL. Here’s how to construct the Connect URL.
Connect Helper Package
We provide packages to make it easy to generate a valid Connect URL. The Connect helper handles parameter validations automagically!
iOS (Swift) JavaScript/TypeScript Android (Kotlin) Install Using Swift Package Manager in Xcode
Open your project in Xcode.
Go to File
> Add Packages...
.
Enter the repository URL: https://github.com/gandalf-network/connect-ios-sdk.git
.
Choose the version rule (e.g., “Up to Next Major”) and click Add Package
.
Select the GandalfConnect package for your target.
Or Update Package.swift // swift-tools-version: 5.9
import PackageDescription
let package = Package (
name : "YourProjectName" ,
dependencies : [
. package ( url : "https://github.com/gandalf-network/connect-ios-sdk.git" , . upToNextMajor ( from : "1.0.0" ))
],
targets : [
. target (
name : "YourTargetName" ,
dependencies : [ "GandalfConnect" ]
)
]
)
Then, run swift package update
to fetch the dependency.
Usage Import the package Initialization Create an instance of ConnectInput
with the necessary details:
let services: InputData = [
"uber" : . service ( Service ( traits : [ "rating" ], activities : [ "trip" ]))
]
let input = ConnectInput (
publicKey : "yourPublicKey" ,
redirectURL : "https://example.com" ,
services : services
)
Initialize the Connect
class:
let connect = Connect ( input : input)
Generating URL To generate a URL, call the generateURL
method:
do {
let generatedURL = try await connect. generateURL ()
print ( "Generated URL: \( generatedURL ) " )
} catch {
print ( "Error generating URL: \( error ) " )
}
Read more on Github .
Install Using Swift Package Manager in Xcode
Open your project in Xcode.
Go to File
> Add Packages...
.
Enter the repository URL: https://github.com/gandalf-network/connect-ios-sdk.git
.
Choose the version rule (e.g., “Up to Next Major”) and click Add Package
.
Select the GandalfConnect package for your target.
Or Update Package.swift // swift-tools-version: 5.9
import PackageDescription
let package = Package (
name : "YourProjectName" ,
dependencies : [
. package ( url : "https://github.com/gandalf-network/connect-ios-sdk.git" , . upToNextMajor ( from : "1.0.0" ))
],
targets : [
. target (
name : "YourTargetName" ,
dependencies : [ "GandalfConnect" ]
)
]
)
Then, run swift package update
to fetch the dependency.
Usage Import the package Initialization Create an instance of ConnectInput
with the necessary details:
let services: InputData = [
"uber" : . service ( Service ( traits : [ "rating" ], activities : [ "trip" ]))
]
let input = ConnectInput (
publicKey : "yourPublicKey" ,
redirectURL : "https://example.com" ,
services : services
)
Initialize the Connect
class:
let connect = Connect ( input : input)
Generating URL To generate a URL, call the generateURL
method:
do {
let generatedURL = try await connect. generateURL ()
print ( "Generated URL: \( generatedURL ) " )
} catch {
print ( "Error generating URL: \( error ) " )
}
Read more on Github .
Install npm i @gandalf-network/connect
Usage Import the package // Typescript && ESModules
import Connect from '@gandalf-network/connect'
import { Platform } from "@gandalf-network/connect/components" ;
// CommonJS
const Connect = require ( "@gandalf-network/connect" );
const { Platform } = require ( "@gandalf-network/connect/components" );
Connect // Initialize Connect
const connect = new Connect ({
publicKey: "YOUR_PUBLIC_KEY" ,
redirectURL: "YOUR_REDIRECT_URL" ,
// The platform defaults to IOS but could be ANDROID or UNIVERSAL
platform: Platform . ANDROID ,
services:
{
uber: {
traits: [ "rating" ],
activities: [ "trip" ],
},
gandalf: {
traits: [ "email" ]
}
}
})
try {
// Generate the Connect URL
const connectUrl = await connect . generateURL ()
// Use the URL as needed
console . log ( 'Generated Connect URL:' , connectUrl )
// If you want to display a QR Code instead:
const qrCodeDataUrl = await connect . generateQRCode ()
} catch ( error ) {
// handle error
}
Display the QR code using the qrCodeDataUrl
< img src = { { qrCodeDataUrl } } alt = "Connect QR Code" />
Read more on Github .
Install with Gradle To integrate GandalfConnect into your project, add it to your build.gradle.kts
or build.gradle
file:
build.gradle.kts repositories {
maven ( "https://jitpack.io" )
}
dependencies {
implementation ( "com.github.gandalf-network:connect-kotlin-sdk:1.0.0" )
}
build.gradle repositories {
mavenCentral()
maven {
url 'https://jitpack.io'
}
}
dependencies {
implementation 'com.github.gandalf-network:connect-kotlin-sdk:1.0.0'
}
Install with Maven To integrate GandalfConnect into your project, add it to your pom.xml
file:
build.gradle.kts <repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.gandalf-network</groupId>
<artifactId>connect-kotlin-sdk</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
Usage Importing the Library In your Kotlin file where you want to use GandalfConnect, import the library:
// The Connect class
import com.gandalf.connect.Connect
// Useful Types
import com.gandalf.connect.types.ConnectInput
import com.gandalf.connect.types.InputData
import com.gandalf.connect.types.Service
Connect Create an instance of ConnectInput
with the necessary details:
val publicKey = ""
val redirectURL = "https://example.com"
val services: InputData = mutableMapOf (
"uber" to Service (traits = listOf ( "rating" ), activities = listOf ( "trip" ))
)
val connectInput = ConnectInput (publicKey, redirectURL, services)
Initialize the Connect
class:
val connect = Connect (connectInput)
To generate a URL, call the generateURL
method:
runBlocking {
try {
val generatedURL = connect. generateURL ()
println ( "Generated URL: $generatedURL " )
} catch (e: Exception ) {
println ( "Error: ${ e.message } " )
}
}
Read more on Github .
Finally, pull the data
Get Data Key
After your user is done linking their accounts, Connect will navigate to your redirectUrl
with a query
parameter called dataKey
.
You can use the packages to get the dataKey
easily.
iOS (Swift)
JavaScript/TypeScript
Android (Kotlin)
Proceed by sending the dataKey to your server, where you can securely request the data you seek.
Alternatively, your redirectURL could be a server-side endpoint. You can get the dataKey
directly
from your application’s server.
Securely request the data (server-side)
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 .
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 .
Installation pip install git+https://github.com/gandalf-network/gandalf-sdk-python.git
eyeofsauron generate
This will generate an eyeofsauron
folder in your project root directory.
Usage Initialization from eyeofsauron.client import Eye
from eyeofsauron.enums import Source
from eyeofsauron.enums import TraitLabel
eye = Eye( "YOUR_PRIVATE_KEY" )
Get Activity import asyncio
...
activities = await eye.get_activity(
data_key = 'YOUR_DATA_KEY' ,
source = Source. NETFLIX ,
limit = 10 ,
page = 1 ,
)
Get Traits traits = await eye.get_traits(
data_key = "YOUR_DATA_KEY" ,
source = Source. UBER ,
labels = [TraitLabel. RATING , TraitLabel. TRIP_COUNT , TraitLabel. ACCOUNT_CREATED_ON ],
)
Read more on Github .
Installation go get github.com/gandalf-network/gandalf-sdk-go/eyeofsauron
go run github.com/gandalf-network/gandalf-sdk-go/eyeofsauron -f generated
This will create a generated
folder in your project root directory.
Usage Initialization package main
import (
" log "
" github.com/gandalf-network/gandalf-sdk-go/eyeofsauron/generated "
)
func main () {
eye , err := generated . NewEyeOfSauron ( "<YOUR_GANDALF_PRIVATE_KEY" )
if err != nil {
log . Fatalf ( "failed to run gandalf client: %s " , err )
}
}
Get Activity response , err := eye . GetActivity (
context . Background (),
"DATA_KEY" ,
generated . SourceNetflix ,
10 ,
1 ,
)
if err != nil {
log . Fatalf ( "failed to get activity: %s " , err )
}
Get Traits response , err := eye . GetTraits ( context . Background (), "DATA_KEY" , generated . SourceNetflix , [] generated . TraitLabel { generated . TraitLabelPlan })
if err != nil {
log . Fatalf ( "failed to get traits: %s " , err )
}
fmt . Println ( "Get Traits" , response . GetGetTraits ())
Read more on Github .
Read more about getActivity's parameters.
This is the key that gives you permission to access the user’s data. Read how to get one
here .
This is how you specify which service you want to retrieve activity from. This can be NETFLIX
,
AMAZON
, PLAYSTATION
.
The number of activity records to be retrieved (per page). The maximum per request is 300 records.
Read more about getTraits's parameters.
This is the key that gives you permission to access the user’s data. Read how to get one
here .
This is how you specify which service you want to retrieve traits from. This can be UBER
,
AMAZON
, etc.
The labels of the traits you want to retrieve traits from. This can be RATING
, TRIP_COUNT
, PRIME_SUBSCRIBER
etc
That’s all!