Skip to content
START FOR FREE
START FOR FREE
  • SUPPORT
  • COMMUNITY
Menu
  • SUPPORT
  • COMMUNITY
MENUMENU
  • Products
    • The World’s Fastest and Most Scalable Graph Platform

      LEARN MORE

      Watch a TigerGraph Demo

      TIGERGRAPH CLOUD

      • Overview
      • TigerGraph Cloud Suite
      • FAQ
      • Pricing

      USER TOOLS

      • GraphStudio
      • Insights
      • Application Workbenches
      • Connectors and Drivers
      • Starter Kits
      • openCypher Support

      TIGERGRAPH DB

      • Overview
      • GSQL Query Language
      • Compare Editions

      GRAPH DATA SCIENCE

      • Graph Data Science Library
      • Machine Learning Workbench
  • Solutions
    • The World’s Fastest and Most Scalable Graph Platform

      LEARN MORE

      Watch a TigerGraph Demo

      Solutions

      • Solutions Overview

      INCREASE REVENUE

      • Customer Journey/360
      • Product Marketing
      • Entity Resolution
      • Recommendation Engine

      MANAGE RISK

      • Fraud Detection
      • Anti-Money Laundering
      • Threat Detection
      • Risk Monitoring

      IMPROVE OPERATIONS

      • Supply Chain Analysis
      • Energy Management
      • Network Optimization

      By Industry

      • Advertising, Media & Entertainment
      • Financial Services
      • Healthcare & Life Sciences

      FOUNDATIONAL

      • AI & Machine Learning
      • Time Series Analysis
      • Geospatial Analysis
  • Customers
    • The World’s Fastest and Most Scalable Graph Platform

      LEARN MORE

      CUSTOMER SUCCESS STORIES

      • Ford
      • Intuit
      • JPMorgan Chase
      • READ MORE SUCCESS STORIES
      • Jaguar Land Rover
      • United Health Group
      • Xbox
  • Partners
    • The World’s Fastest and Most Scalable Graph Platform

      LEARN MORE

      PARTNER PROGRAM

      • Partner Benefits
      • TigerGraph Partners
      • Sign Up
      TigerGraph partners with organizations that offer complementary technology solutions and services.​
  • Resources
    • The World’s Fastest and Most Scalable Graph Platform

      LEARN MORE

      BLOG

      • TigerGraph Blog

      RESOURCES

      • Resource Library
      • Benchmarks
      • Demos
      • O'Reilly Graph + ML Book

      EVENTS & WEBINARS

      • Graph+AI Summit
      • Graph for All - Million Dollar Challenge
      • Events &Trade Shows
      • Webinars

      DEVELOPERS

      • Documentation
      • Ecosystem
      • Developers Hub
      • Community Forum

      SUPPORT

      • Contact Support
      • Production Guidelines

      EDUCATION

      • Training & Certifications
  • Company
    • Join the World’s Fastest and Most Scalable Graph Platform

      WE ARE HIRING

      COMPANY

      • Company Overview
      • Leadership
      • Legal Terms
      • Patents
      • Security and Compliance

      CAREERS

      • Join Us
      • Open Positions

      AWARDS

      • Awards and Recognition
      • Leader in Forrester Wave
      • Gartner Research

      PRESS RELEASE

      • Read All Press Releases
      TigerGraph Reports Exceptional Customer Growth and Product Leadership as More Market-Leading Companies Tap the Power of Graph
      March 1, 2023
      Read More »

      NEWS

      • Read All News
      The-New-Stack-Logo-square

      Multiple Vendors Make Data and Analytics Ubiquitous

      TigerGraph enhances fundamentals in latest platform update

  • START FREE
    • The World’s Fastest and Most Scalable Graph Platform

      GET STARTED

      • Request a Demo
      • CONTACT US
      • Try TigerGraph
      • START FREE
      • TRY AN ONLINE DEMO

Full Stack TigerGraph Part 1

  • Emily McAuliffe
  • May 27, 2020
  • Developers
  • Blog >
  • Full Stack TigerGraph Part 1

This article is Part 1 of a series of articles on integrating or using TigerGraph in a Full Stack application. Follow the Author on LinkedIn and Medium.

Graph Databases represent data in an intuitive manner and are exploding in popularity in recent times. Moreover, TigerGraph, a super fast, native, parallel graph database, has also seen incredible engagement and was named a “Cool Vendor” by Gartner. Through out these articles, we will walk through ways of harnessing TigerGraph’s analytical abilities and queries in a Full Stack application. In part 1, we will concern ourselves with simply setting up the back end.

Setup

We will be using the Free Cloud Instance as our instance of TigerGraph. You can learn how to set up a free TigerGraph cloud instance from this article written by Jon Herke.

Now that the instance is up, we must generate the secrets and tokens, as we will need them to make requests to TigerGraph. There are a couple of steps we must follow. First, click on the Admin Button in the top right corner. You will now navigate to the Admin area, which looks like:

Now, click on User Management. Here, you shall see an area where you can generate a secret. Please generate the secret and copy it. The secret must never be exchanged or compromised and you must copy it right away when it is generated or you may have to generate another one.

We need to use the secret to generate a token. This token will be used for authorization when we make requests. We can do that by making a request to TigerGraph to generate a token.

curl -X GET 'HOST_NAME:9000/requesttoken?secret=SECRET&lifetime=1000000'

For the fields HOST_NAME and SECRET, you must fill them out based on your TigerGraph Cloud Instance URL as well as the secret you copied. Here is an example for a given url and secret below:

url = https://blank-test.i.tgcloud.io:14240/#/home
secret = blank1231

curl -X GET https://blank-test.i.tgcloud.io:9000/requesttoken?secret=blank1231&lifetime=1000000

If the command runs successfully, TigerGraph will return a response with your generated token. Now that most of our setup is complete, let’s take look at one way of calling our TigerGraph query end points.

Method

Although there exist many different methods of calling the query endpoints, I believe that having a server in between which takes in the requests from the Front End and then calls to TigerGraph would be a good option, since the tokens are at one secure place, the server, and there is a chance to cache certain requests or computations which remain fairly constant. We will dive a bit deeper on the idea of caching in the next part of the Full Stack TigerGraph series.

Although there are many ways one can create this middle server, we shall use NodeJS and Express for this article. So, in the end, here is how our Request flow looks like.

ExpressJs is a web framework for NodeJS to handle requests, routing and much more. Please take a look at the documentation of it if you are unfamiliar.

Execution

I will assume that you have npm installed and working. First, let’s begin by creating a new NodeJS project.

npm init

Npm will now prompt you fill out your package.json information, please do so. Now, we will install express.

npm install express --save

If the install went smoothly, express will show as a dependency in your package.json.

Let’s create a file that corresponds to main key in your package.json, which would be index.js for me.

In index.js, let’s start by creating an express app and making it listen on port 5000 locally.

const express = require("express");
const app = express();
console.log("Listening...");
app.listen(5000);

At anytime you can run the app by using the following command:

node FILE
node index.js (For my project)

Now that the app is listening, let’s start by creating a GET endpoint where we will make a request to TigerGraph.

app.get("/profile/:id", async(req, res)=>{
});

To give a bit of context, suppose in our graph we have a query called getProfile which takes a parameter person and returns data about the profile based on that id. We want to be able to make a request to the getProfile endpoint and pass in the id parameter we receive from the request the client makes to our express server.

The graph schema, parameters and what not do not matter. This is just for an example.

To put it simply, from our route “/profile/:id” we must grab the id from the route parameters and use the id for the parameter person to the getProfile endpoint. Let’s start coding away!

First, let’s make a config file for our TigerGraph credentials. Simply make a file called config.js, and then place the credentials in the file. This is how I did it:

const TigerGraphCred = {
   token: "TOKEN",
   secret: "blank1231",
   queryUrl: "https://https://blank-test.i.tgcloud.io:9000/query/"
}

module.exports = TigerGraphCred;

Here is what my folder structure looks like:

Let’s head back into index.js and write out the function.

const express = require("express");
const app = express();
const TigerGraphCred = require("./config.js");
const fetch = require("node-fetch");

app.get("/profile/:id", async(req, res)=>{
const person = req.params.id;
const reqUrl = TigerGraphCred.queryUrl + `RP_getProfile?person=${person}`;
const response = await fetch(reqUrl, {
headers:{
"Content-Type": "application/json",
"Authorization": `Bearer ${TigerGraphCred.token}`,
"Accept":"application/json"
}
});

if(response.status === 200){
const json = await response.json();
//query for the error and send appropriate status code and response
if(json.error){
res.status(400).send({"error": json.message});
}
else{
res.status(200).send(json);
}
}
else{
const message = await response.text();
res.status(500).send({'error': message});
}
});

app.listen(5000);

To elaborate, we are using the fetch api to make a HTTP GET request to our TigerGraph query endpoint. Then, after that, we are essentially checking the status of our request and if any errors are present. Finally, if TigerGraph responded with a status code of 200 and if no run-time errors came, then we can return the JSON response from the TigerGraph request.

Conclusion

A huge thank you for reading this article. This is the first of a series of articles that will navigate through building a Full Stack application with TigerGraph. Please let me know if you liked or disliked some part of the article and how I can improve.

Read Part 2 here: https://www.tigergraph.com/2020/06/07/designing-feed-relationships-with-graph-databases-full-stack-tigergraph-part-2/

You Might Also Like

Developer Spotlight: Kapil Saini

Developer Spotlight: Kapil Saini

October 21, 2022
Graph Neural Network-based Graph Outlier Detection: A Brief Introduction

Graph Neural Network-based Graph Outlier Detection:...

September 15, 2022
Developer Spotlight: Renata Bastos Gottgtroy

Developer Spotlight: Renata Bastos Gottgtroy

September 12, 2022

Introducing TigerGraph 3.0

July 1, 2020

Everything to Know to Pass your TigerGraph Certification Test

June 24, 2020

Neo4j 4.0 Fabric – A Look Behind the Curtain

February 7, 2020

TigerGraph Blog

  • Categories
    • blogs
      • About TigerGraph
      • Benchmark
      • Business
      • Community
      • Compliance
      • Customer
      • Customer 360
      • Cybersecurity
      • Developers
      • Digital Twin
      • eCommerce
      • Emerging Use Cases
      • Entity Resolution
      • Finance
      • Fraud / Anti-Money Laundering
      • GQL
      • Graph Database Market
      • Graph Databases
      • GSQL
      • Healthcare
      • Machine Learning / AI
      • Podcast
      • Supply Chain
      • TigerGraph
      • TigerGraph Cloud
    • Graph AI On Demand
      • Analysts and Research
      • Customer 360 and Entity Resolution
      • Customer Spotlight
      • Development
      • Finance, Banking, Insurance
      • Keynote
      • Session
    • Video
  • Recent Posts

    • Trillion edges benchmark: new world record beyond 100TB by TigerGraph featuring AMD based Amazon EC2 instances
    • Overview of Graph and Machine Learning with TigerGraph | Mar 8 @ 11am PST
    • Gartner Data & Analytics Summit 2023, London
    • Gartner Data and Analytics Summit, Orlando
    • Transaction Surveillance with Maximum Flow Algorithm
    TigerGraph

    Product

    SOLUTIONS

    customers

    RESOURCES

    start for free

    TIGERGRAPH DB
    • Overview
    • Features
    • GSQL Query Language
    GRAPH DATA SCIENCE
    • Graph Data Science Library
    • Machine Learning Workbench
    TIGERGRAPH CLOUD
    • Overview
    • Cloud Starter Kits
    • Login
    • FAQ
    • Pricing
    • Cloud Marketplaces
    USEr TOOLS
    • GraphStudio
    • TigerGraph Insights
    • Application Workbenches
    • Connectors and Drivers
    • Starter Kits
    • openCypher Support
    SOLUTIONS
    • Why Graph?
    industry
    • Advertising, Media & Entertainment
    • Financial Services
    • Healthcare & Life Sciences
    use cases
    • Benefits
    • Product & Service Marketing
    • Entity Resolution
    • Customer 360/MDM
    • Recommendation Engine
    • Anti-Money Laundering
    • Cybersecurity Threat Detection
    • Fraud Detection
    • Risk Assessment & Monitoring
    • Energy Management
    • Network & IT Management
    • Supply Chain Analysis
    • AI & Machine Learning
    • Geospatial Analysis
    • Time Series Analysis
    success stories
    • Customer Success Stories

    Partners

    Partner program
    • Partner Benefits
    • TigerGraph Partners
    • Sign Up
    LIBRARY
    • Resources
    • Benchmark
    • Webinars
    Events
    • Trade Shows
    • Graph + AI Summit
    • Million Dollar Challenge
    EDUCATION
    • Training & Certifications
    Blog
    • TigerGraph Blog
    DEVELOPERS
    • Developers Hub
    • Community Forum
    • Documentation
    • Ecosystem

    COMPANY

    Company
    • Overview
    • Careers
    • News
    • Press Release
    • Awards
    • Legal
    • Patents
    • Security and Compliance
    • Contact
    Get Started
    • Start Free
    • Compare Editions
    • Online Demo - Test Drive
    • Request a Demo

    Product

    • Overview
    • TigerGraph 3.0
    • TIGERGRAPH DB
    • TIGERGRAPH CLOUD
    • GRAPHSTUDIO
    • TRY NOW

    customers

    • success stories

    RESOURCES

    • LIBRARY
    • Events
    • EDUCATION
    • BLOG
    • DEVELOPERS

    SOLUTIONS

    • SOLUTIONS
    • use cases
    • industry

    Partners

    • partner program

    company

    • Overview
    • news
    • Press Release
    • Awards

    start for free

    • Request Demo
    • take a test drive
    • SUPPORT
    • COMMUNITY
    • CONTACT
    • Copyright © 2023 TigerGraph
    • Privacy Policy
    • Linkedin
    • Facebook
    • Twitter

    Copyright © 2020 TigerGraph | Privacy Policy

    Copyright © 2020 TigerGraph Privacy Policy

    • SUPPORT
    • COMMUNITY
    • COMPANY
    • CONTACT
    • Linkedin
    • Facebook
    • Twitter

    Copyright © 2020 TigerGraph

    Privacy Policy

    • Products
    • Solutions
    • Customers
    • Partners
    • Resources
    • Company
    • START FREE
    START FOR FREE
    START FOR FREE
    TigerGraph
    PRODUCT
    PRODUCT
    • Overview
    • GraphStudio UI
    • Graph Data Science Library
    TIGERGRAPH DB
    • Overview
    • Features
    • GSQL Query Language
    TIGERGRAPH CLOUD
    • Overview
    • Cloud Starter Kits
    TRY TIGERGRAPH
    • Get Started for Free
    • Compare Editions
    SOLUTIONS
    SOLUTIONS
    • Why Graph?
    use cases
    • Benefits
    • Product & Service Marketing
    • Entity Resolution
    • Customer Journey/360
    • Recommendation Engine
    • Anti-Money Laundering (AML)
    • Cybersecurity Threat Detection
    • Fraud Detection
    • Risk Assessment & Monitoring
    • Energy Management
    • Network Resources Optimization
    • Supply Chain Analysis
    • AI & Machine Learning
    • Geospatial Analysis
    • Time Series Analysis
    industry
    • Advertising, Media & Entertainment
    • Financial Services
    • Healthcare & Life Sciences
    CUSTOMERS
    read all success stories

     

    PARTNERS
    Partner program
    • Partner Benefits
    • TigerGraph Partners
    • Sign Up
    RESOURCES
    LIBRARY
    • Resource Library
    • Benchmark
    • Webinars
    Events
    • Trade Shows
    • Graph + AI Summit
    • Graph for All - Million Dollar Challenge
    EDUCATION
    • TigerGraph Academy
    • Certification
    Blog
    • TigerGraph Blog
    DEVELOPERS
    • Developers Hub
    • Community Forum
    • Documentation
    • Ecosystem
    COMPANY
    COMPANY
    • Overview
    • Leadership
    • Careers  
    NEWS
    PRESS RELEASE
    AWARDS
    START FREE
    Start Free
    • Request a Demo
    • SUPPORT
    • COMMUNITY
    • CONTACT
    Dr. Jay Yu

    Dr. Jay Yu | VP of Product and Innovation

    Dr. Jay Yu is the VP of Product and Innovation at TigerGraph, responsible for driving product strategy and roadmap, as well as fostering innovation in graph database engine and graph solutions. He is a proven hands-on full-stack innovator, strategic thinker, leader, and evangelist for new technology and product, with 25+ years of industry experience ranging from highly scalable distributed database engine company (Teradata), B2B e-commerce services startup, to consumer-facing financial applications company (Intuit). He received his PhD from the University of Wisconsin - Madison, where he specialized in large scale parallel database systems

    Todd Blaschka | COO

    Todd Blaschka is a veteran in the enterprise software industry. He is passionate about creating entirely new segments in data, analytics and AI, with the distinction of establishing graph analytics as a Gartner Top 10 Data & Analytics trend two years in a row. By fervently focusing on critical industry and customer challenges, the companies under Todd's leadership have delivered significant quantifiable results to the largest brands in the world through channel and solution sales approach. Prior to TigerGraph, Todd led go to market and customer experience functions at Clustrix (acquired by MariaDB), Dataguise and IBM.