Zingtree API

Learn about Zingtree's REST API

 

Overview

Zingtree makes it easy to find trees, or import data from your sessions into any other system via a standard API.

Zingtree uses a RESTful API, with easy support for any language. You can also use our PHP wrapper.

If needed, your API Key is found at the bottom of the Account, Organizations and Billing page.

The following operations are available:

All results are returned in JSON format. The examples below use trees and sessions from the Zingtree Gallery.


Status Codes

The API will also return HTTP Status codes as follows:

200 (Success): The query was successful.
404 (Not Found): The session ID or API Key was not found.
500 (Server Error): The operation requested is not supported.

get_session_data

Description:

Returns a JSON structure with details about a session.

Structure:

https://zingtree.com/api/session/{{session ID}}/get_session_data

Live Example:

https://zingtree.com/api/session/Gallery55-14546345866804/get_session_data                    

Example PHP call:

zt_get_session_data ("Gallery55-14546345866804") ;

Example Return:

{  
   "source":"",
   "os":"Win7",
   "browser":"Chrome Generic",
   "start_time_pst":"2016-01-04 17:09:00",
   "start_time_utc":"2016-01-05 1:09:00",
   "tree_id":"225470905",
   "tree_name":"Form Fields and Data Entry Demo",
   "total_score":"0",
   "ip":"192.168.1.1",
   "notes":"",
   "time_spent":"0:15",
   "duration_seconds":15,
   "path":[  
      {  
         "question":"?",
         "page_title":"Welcome",
         "subtree":"Form Fields and Data Entry Demo",
         "from_node_id":"1",
         "to_node_id":"2",
         "time":"0:15",
         "seconds":15,
         "button_text":"Continue"
      },
      {  
         "question":"Next: See how Zingtree can import this data into another application",
         "page_title":"Summary",
         "subtree":"Form Fields and Data Entry Demo",
         "from_node_id":"2",
         "to_node_id":0,
         "time":"0:00",
         "seconds":0,
         "button_text":""
      }
   ]
}                    

get_session_notes

Description:

Returns a JSON structure with agent-entered notes from a session.

Structure:

https://zingtree.com/api/session/{{session ID}}/get_session_notes

Live Example:

https://zingtree.com/api/session/Gallery55-14546345866804/get_session_notes                    

Example PHP call:

zt_get_session_notes ("Gallery55-14546345866804") ;

Example Return:

{  
   "notes":"These are sample notes entered for this session.",
}                    

get_form_data

Description:

Returns a JSON structure with form variables and values entered during a session.

Structure:

https://zingtree.com/api/session/{{session ID}}/get_form_data

Live Example:

https://zingtree.com/api/session/Gallery55-14546345866804/get_form_data                   

Example PHP call:

zt_get_form_data ("Gallery55-14546345866804") ;

Example Return:

{  
   "name":"Bill Zing",
   "comment":"I think Zingtree is great!"
}                    

find_sessions

Description:

Returns a JSON structure with session information for a particular agent and date range.

Start date and end date are in the form of YYYY-MM-DD. If blank, returns sessions for last 30 days.

If agent is *, return sessions for all agents.

Structure:

https://zingtree.com/api/sessions/{{apikey}}/{{agent}}/{{start date}}/{{end date}}

Live Example:

https://zingtree.com/api/sessions/6a103737e44e4aa6e1e4b6b0bcb46f83/*/2016-03-20/2016-03-20                   

Example PHP call:

zt_find_sessions('6a103737e44e4aa6e1e4b6b0bcb46f83', '*', '2016-03-20', '2016-03-20') ;

Example Return:

{"count":3, "agent":"", "start_date":"2016-03-20", "end_date":"2016-03-20",
    "sessions":[
        {"session_id":"9f5a6cb4b1dd47c990e230abbdc5baf2","agent":"Bill","start_time":"2016-03-20 00:07:55","resolution_state":"Y","total_score":"0","tree_id":"815089605"}},
        {"session_id":"23cd2c6474724190ac551223971a6f54","agent":"Tom","start_time":"2016-03-20 00:12:16","resolution_state":"N","total_score":"0","tree_id":"815089605"}},
        {"session_id":"Gallery24-14584700538357","agent":"","start_time":"2016-03-20 03:34:13","resolution_state":"?","total_score":"0","tree_id":"815089605"}}
]}        

get_trees

Description:

Returns a JSON structure with information about all of an organization's trees.

Structure:

https://zingtree.com/api/tree/{{apikey}}/get_trees

Live Example:

https://zingtree.com/api/tree/6a103737e44e4aa6e1e4b6b0bcb46f83/get_trees                   

Example PHP call:

zt_get_trees ("6a103737e44e4aa6e1e4b6b0bcb46f83") ;

Example Return:

{"count":3,
"trees": [
    {"name":"Pet Rock Demo","description":"Zingtree demo using the Pet Rock","tree_id":"164166011", "tags":"gallery troubleshooting"},
    {"name":"Intercom.io Demo","description":"Shows how to gather data and insert it into an Intercom.io chat window.","tree_id":"172041421", "tags":"gallery chat"},
    {"name":"Narcissist Test","description":"Narcissism test, adapted from The Narcissist Test by Dr Craig Malkin\r\n\r\n","tree_id":"229818441", "tags":"gallery scoring"}
]}                    

get_tree_tag_all

Description:

Returns a JSON structure with trees that have ALL tags in a comma delimited list.

Structure:

https://zingtree.com/api/tree/{{apikey}}/get_tree_tag_all/{{taglist}}

Live Example:

https://zingtree.com/api/tree/6a103737e44e4aa6e1e4b6b0bcb46f83/get_tree_tag_all/demo,gallery                   

Example PHP call:

zt_get_tree_tag_all('6a103737e44e4aa6e1e4b6b0bcb46f83', 'demo,gallery') ;

Example Return:

{"count":1,
"results":[
    {"id":"14","name":"Astrology Site - Troubleshooting Demo","tags":"demo,gallery,testtag2","description":"Interactive guide to assist subscribers who have questions about their account"}
]}                    

get_tree_tag_any

Description:

Returns a JSON structure with trees that have ANY tags in a comma delimited list.

Structure:

https://zingtree.com/api/tree/{{apikey}}/get_tree_tag_any/{{taglist}}

Live Example:

https://zingtree.com/api/tree/6a103737e44e4aa6e1e4b6b0bcb46f83/get_tree_tag_any/demo,gallery                   

Example PHP call:

zt_get_tree_tag_any('6a103737e44e4aa6e1e4b6b0bcb46f83', 'demo,gallery') ;

Example Return:

{"count":4,
"results":[
    {"id":"14","name":"Astrology Site - Troubleshooting Demo","tags":"demo,gallery,testtag2","description":"Interactive guide to assist subscribers who have questions about their account"},
    {"id":"120169628","name":"Zapier Demo","tags":"gallery","description":"Demonstrates how to  send data from Zingtree to 500+ apps supported by Zapier."},
    {"id":"164166011","name":"Pet Rock Demo","tags":"gallery","description":"Zingtree demo using the Pet Rock"},
    {"id":"207620939","name":"What To Wear Demo","tags":"demo","description":"This is a tree for the \"What to Wear\" example used in the tutorials."}
]}                    

search_trees

Description:

Returns a JSON structure with information about all of an organization's trees and nodes matching search text.

Structure:

https://zingtree.com/api/tree/{{apikey}}/search_trees/{{search text}}

Live Example:

https://zingtree.com/api/tree/6a103737e44e4aa6e1e4b6b0bcb46f83/search_trees/Demo                   

Example PHP call:

zt_search_trees ("6a103737e44e4aa6e1e4b6b0bcb46f83", "Demo") ;

Example Return:

{"count":6,
"results": [
    {"tree_id":"225470905","name":"Form Fields and Data Entry Demo","node":"2","page_title":"Summary"},
    {"tree_id":"539252574","name":"Freshdesk Integration example","node":"1","page_title":"Welcome"},
    {"tree_id":"172041421","name":"Intercom.io Demo","node":"1","page_title":"Start"},
    {"tree_id":"164166011","name":"Pet Rock Demo","node":"1","page_title":"The Care and Training of Your PET ROCK"},
    {"tree_id":"867287049","name":"Zingtree Tour","node":"1","page_title":"Zingtree Tour"},
    {"tree_id":"723996162","name":"Zopim Demo","node":"1","page_title":"Start"}
]}