Snapshot Exchange Datafeed API

Overview

FactSet’s Exchange DataFeed Snapshot API provides cost-effective access to real-time and delayed global exchange data. Proprietary technology normalizes over 200 global exchanges and 150+ data fields. Asset types integrated include equities, futures, options, warrants, fixed income, mutual funds, ETFs, indices, commodities, and FX rates. 

API Definition

swagger_file_format

API Documentation

SDK Library

Code Snippet

Example Codes for HTTP GET

All of the example codes request the ASK_1, BID_1, and LAST_1 fields for the symbols, FDS-USA, IBM-USA, and TWX-USA. Two programming environments are illustrated (C#/.NET and Java). Each programming language has two sections. The first section makes the HTTP GET request, the second parses the XML response.

​
//Issuing an HTTP GET Request

using System.IO;
using System.IO.Compression;
using System.Net;
using System.Xml;
class MyXMLParser
{
[System.STAThread]
static void Main(string [] args)
{
 // setup the request
 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(
"https://api.factset.com/services/DFSnapshot?" +
"serv=FDS_C&req_id=99&format=xml" +
"&ids=FDS-USA,IBM-USA,TWX-USA&fields=ASK_1,BID_1,LAST_1"
 req.KeepAlive = false;
 req.Headers.Add("Accept-Encoding", "deflate, gzip");
 req.Headers.Add("Authorization", "Basic AaBbCcDdEeFfGgHhIi1234==");
 // make request and get the response
 HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
 Stream stream = rsp.GetResponseStream();
 // uncompress the response
 if (rsp.ContentEncoding.Equals("deflate"))
 stream = new DeflateStream(stream, CompressionMode.Decompress);
 else if (rsp.ContentEncoding.Equals("gzip"))
 stream = new GZipStream(stream, CompressionMode.Decompress);

// Parsing the XML Response
//This code uses a C# XMLTextReader to move through the response nodes and print out the values4

XmlTextReader reader = new XmlTextReader(stream);
 reader.WhitespaceHandling = WhitespaceHandling.None;
 while (reader.Read())
 {
 if (reader.NodeType.Equals(XmlNodeType.Element))
 {
 if (reader.Name.Equals("Error"))
 {
 System.Console.WriteLine(reader.Name);
 printAttributes(reader);
 System.Console.WriteLine();
 }
 else if (reader.Name.Equals("Record"))
 {
 System.Console.WriteLine(reader.Name);
 printAttributes(reader);
 // Move to first Field element
 while (reader.Read() && !reader.Name.Equals("Field"))
 { }
 // Print out all field ids, names and values
 do
 {
 printAttributes(reader);
 } while (reader.Read() && reader.Name.Equals("Field"));
 System.Console.WriteLine();
 }
 }
 }
}
static void printAttributes(XmlTextReader reader)
{
 while (reader.MoveToNextAttribute())
 System.Console.Write(reader.Name + ": " + reader.Value + ", ");
 System.Console.WriteLine();
}
} // class MyXMLParser



​

 

​
//Issuing an HTTP GET request

import java.io.*;
import java.util.zip.*;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import javax.xml.parsers.*;
import org.xml.sax.*;
public class MyXMLParser implements ContentHandler {
public static void main(String[] args)
{
 try {
 // setup the request
 URL url = new URL(
"https://api.factset.com/services/DFSnapshot?" +
"serv=FDS_C&req_id=99&format=xml" +
"&ids=FDS-USA,IBM-USA,TWX-USA&fields=ASK_1,BID_1,LAST_1"
 HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
 conn.setDoOutput(true);
 conn.setRequestProperty("Accept-Encoding", "deflate, gzip");
 conn.setRequestProperty("Authorization",
 "Basic AaBbCcDdEeFfGgHhIi1234==");
 // getInputStream will implicitly connect and get the response
 InputStream inputStream = conn.getInputStream();
 // uncompress the response
 if (conn.getContentEncoding().equals("deflate"))
 inputStream = new InflaterInputStream(inputStream,
 new Inflater(true));
 else if (conn.getContentEncoding().equals("gzip"))
 inputStream = new GZIPInputStream(inputStream)

// Parsing the XML Response
//The SAX parser, which comes with the Standard Edition of Java, uses event-handler callbacks for each element in the XML
document5
. Therefore, in order to print the record attributes for each field, the “req_sym”, “key”, and “stale” values must be saved
in temporary variables.

 .
 .
 XMLReader reader =
 SAXParserFactory.newInstance().newSAXParser().getXMLReader();
 reader.setContentHandler(new MyXMLParser());
 reader.parse(new InputSource(inputStream));
 } catch (IOException e) {
 // Deal with IOException
 } catch (SAXException e) {
 // Deal with SAXException
 } catch (ParserConfigurationException e) {
 // Deal with ParserConfigurationException
 }
}
public void startElement(String uri, String localName, String qName,
 Attributes atts)
{
 if (qName.equals("Error"))
 System.out.println("Error code: " + atts.getValue("code")
 + ", description: " + atts.getValue("description"));
 else if (qName.equals("Record")) {
 currentReqSym = atts.getValue("req_sym");
 currentKey = atts.getValue("key");
 currentStale = atts.getValue("stale");
 }
 else if (qName.equals("Field"))
 System.out.println("req_sym: " + currentReqSym
 + ", key: " + currentKey + ", stale: " + currentStale
 + ", id: " + atts.getValue("id")
 + ", name: " + atts.getValue("name")
 + " = " + atts.getValue("value"));
}
private String currentReqSym, currentKey, currentStale;
public void characters(char [] ch, int start, int length) {}
public void endDocument() {}
public void endElement(String uri, String localName, String qName) {}
public void endPrefixMapping(String prefix) {}
public void ignorableWhitespace(char[] ch, int start, int length) {}
public void processingInstruction(String target, String data) {}
public void setDocumentLocator(Locator locator) {}
public void skippedEntity(String name) {}
public void startDocument() {}
public void startPrefixMapping(String prefix, String uri) {}
} // class MyXMLParser

​

 

Example Codes for HTTP GET

All of the example codes request the ASK_1, BID_1, and LAST_1 fields for the symbols, FDS-USA, IBM-USA, and TWX-USA. Two programming environments are illustrated (C#/.NET and Java). Each programming language has two sections. The first section makes the HTTP GET request, the second parses the XML response.

​
//Issuing an HTTP GET Request

using System.IO;
using System.IO.Compression;
using System.Net;
using System.Xml;
class MyXMLParser
{
[System.STAThread]
static void Main(string [] args)
{
 // setup the request
 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(
"https://api.factset.com/services/DFSnapshot?" +
"serv=FDS_C&req_id=99&format=xml" +
"&ids=FDS-USA,IBM-USA,TWX-USA&fields=ASK_1,BID_1,LAST_1"
 req.KeepAlive = false;
 req.Headers.Add("Accept-Encoding", "deflate, gzip");
 req.Headers.Add("Authorization", "Basic AaBbCcDdEeFfGgHhIi1234==");
 // make request and get the response
 HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
 Stream stream = rsp.GetResponseStream();
 // uncompress the response
 if (rsp.ContentEncoding.Equals("deflate"))
 stream = new DeflateStream(stream, CompressionMode.Decompress);
 else if (rsp.ContentEncoding.Equals("gzip"))
 stream = new GZipStream(stream, CompressionMode.Decompress);

// Parsing the XML Response
//This code uses a C# XMLTextReader to move through the response nodes and print out the values4

XmlTextReader reader = new XmlTextReader(stream);
 reader.WhitespaceHandling = WhitespaceHandling.None;
 while (reader.Read())
 {
 if (reader.NodeType.Equals(XmlNodeType.Element))
 {
 if (reader.Name.Equals("Error"))
 {
 System.Console.WriteLine(reader.Name);
 printAttributes(reader);
 System.Console.WriteLine();
 }
 else if (reader.Name.Equals("Record"))
 {
 System.Console.WriteLine(reader.Name);
 printAttributes(reader);
 // Move to first Field element
 while (reader.Read() && !reader.Name.Equals("Field"))
 { }
 // Print out all field ids, names and values
 do
 {
 printAttributes(reader);
 } while (reader.Read() && reader.Name.Equals("Field"));
 System.Console.WriteLine();
 }
 }
 }
}
static void printAttributes(XmlTextReader reader)
{
 while (reader.MoveToNextAttribute())
 System.Console.Write(reader.Name + ": " + reader.Value + ", ");
 System.Console.WriteLine();
}
} // class MyXMLParser



​

 

​
//Issuing an HTTP GET request

import java.io.*;
import java.util.zip.*;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import javax.xml.parsers.*;
import org.xml.sax.*;
public class MyXMLParser implements ContentHandler {
public static void main(String[] args)
{
 try {
 // setup the request
 URL url = new URL(
"https://api.factset.com/services/DFSnapshot?" +
"serv=FDS_C&req_id=99&format=xml" +
"&ids=FDS-USA,IBM-USA,TWX-USA&fields=ASK_1,BID_1,LAST_1"
 HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
 conn.setDoOutput(true);
 conn.setRequestProperty("Accept-Encoding", "deflate, gzip");
 conn.setRequestProperty("Authorization",
 "Basic AaBbCcDdEeFfGgHhIi1234==");
 // getInputStream will implicitly connect and get the response
 InputStream inputStream = conn.getInputStream();
 // uncompress the response
 if (conn.getContentEncoding().equals("deflate"))
 inputStream = new InflaterInputStream(inputStream,
 new Inflater(true));
 else if (conn.getContentEncoding().equals("gzip"))
 inputStream = new GZIPInputStream(inputStream)

// Parsing the XML Response
//The SAX parser, which comes with the Standard Edition of Java, uses event-handler callbacks for each element in the XML
document5
. Therefore, in order to print the record attributes for each field, the “req_sym”, “key”, and “stale” values must be saved
in temporary variables.

 .
 .
 XMLReader reader =
 SAXParserFactory.newInstance().newSAXParser().getXMLReader();
 reader.setContentHandler(new MyXMLParser());
 reader.parse(new InputSource(inputStream));
 } catch (IOException e) {
 // Deal with IOException
 } catch (SAXException e) {
 // Deal with SAXException
 } catch (ParserConfigurationException e) {
 // Deal with ParserConfigurationException
 }
}
public void startElement(String uri, String localName, String qName,
 Attributes atts)
{
 if (qName.equals("Error"))
 System.out.println("Error code: " + atts.getValue("code")
 + ", description: " + atts.getValue("description"));
 else if (qName.equals("Record")) {
 currentReqSym = atts.getValue("req_sym");
 currentKey = atts.getValue("key");
 currentStale = atts.getValue("stale");
 }
 else if (qName.equals("Field"))
 System.out.println("req_sym: " + currentReqSym
 + ", key: " + currentKey + ", stale: " + currentStale
 + ", id: " + atts.getValue("id")
 + ", name: " + atts.getValue("name")
 + " = " + atts.getValue("value"));
}
private String currentReqSym, currentKey, currentStale;
public void characters(char [] ch, int start, int length) {}
public void endDocument() {}
public void endElement(String uri, String localName, String qName) {}
public void endPrefixMapping(String prefix) {}
public void ignorableWhitespace(char[] ch, int start, int length) {}
public void processingInstruction(String target, String data) {}
public void setDocumentLocator(Locator locator) {}
public void skippedEntity(String name) {}
public void startDocument() {}
public void startPrefixMapping(String prefix, String uri) {}
} // class MyXMLParser

​

 

Example Codes for HTTP GET

All of the example codes request the ASK_1, BID_1, and LAST_1 fields for the symbols, FDS-USA, IBM-USA, and TWX-USA. Two programming environments are illustrated (C#/.NET and Java). Each programming language has two sections. The first section makes the HTTP GET request, the second parses the XML response.

​
//Issuing an HTTP GET Request

using System.IO;
using System.IO.Compression;
using System.Net;
using System.Xml;
class MyXMLParser
{
[System.STAThread]
static void Main(string [] args)
{
 // setup the request
 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(
"https://api.factset.com/services/DFSnapshot?" +
"serv=FDS_C&req_id=99&format=xml" +
"&ids=FDS-USA,IBM-USA,TWX-USA&fields=ASK_1,BID_1,LAST_1"
 req.KeepAlive = false;
 req.Headers.Add("Accept-Encoding", "deflate, gzip");
 req.Headers.Add("Authorization", "Basic AaBbCcDdEeFfGgHhIi1234==");
 // make request and get the response
 HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
 Stream stream = rsp.GetResponseStream();
 // uncompress the response
 if (rsp.ContentEncoding.Equals("deflate"))
 stream = new DeflateStream(stream, CompressionMode.Decompress);
 else if (rsp.ContentEncoding.Equals("gzip"))
 stream = new GZipStream(stream, CompressionMode.Decompress);

// Parsing the XML Response
//This code uses a C# XMLTextReader to move through the response nodes and print out the values4

XmlTextReader reader = new XmlTextReader(stream);
 reader.WhitespaceHandling = WhitespaceHandling.None;
 while (reader.Read())
 {
 if (reader.NodeType.Equals(XmlNodeType.Element))
 {
 if (reader.Name.Equals("Error"))
 {
 System.Console.WriteLine(reader.Name);
 printAttributes(reader);
 System.Console.WriteLine();
 }
 else if (reader.Name.Equals("Record"))
 {
 System.Console.WriteLine(reader.Name);
 printAttributes(reader);
 // Move to first Field element
 while (reader.Read() && !reader.Name.Equals("Field"))
 { }
 // Print out all field ids, names and values
 do
 {
 printAttributes(reader);
 } while (reader.Read() && reader.Name.Equals("Field"));
 System.Console.WriteLine();
 }
 }
 }
}
static void printAttributes(XmlTextReader reader)
{
 while (reader.MoveToNextAttribute())
 System.Console.Write(reader.Name + ": " + reader.Value + ", ");
 System.Console.WriteLine();
}
} // class MyXMLParser



​

 

​
//Issuing an HTTP GET request

import java.io.*;
import java.util.zip.*;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import javax.xml.parsers.*;
import org.xml.sax.*;
public class MyXMLParser implements ContentHandler {
public static void main(String[] args)
{
 try {
 // setup the request
 URL url = new URL(
"https://api.factset.com/services/DFSnapshot?" +
"serv=FDS_C&req_id=99&format=xml" +
"&ids=FDS-USA,IBM-USA,TWX-USA&fields=ASK_1,BID_1,LAST_1"
 HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
 conn.setDoOutput(true);
 conn.setRequestProperty("Accept-Encoding", "deflate, gzip");
 conn.setRequestProperty("Authorization",
 "Basic AaBbCcDdEeFfGgHhIi1234==");
 // getInputStream will implicitly connect and get the response
 InputStream inputStream = conn.getInputStream();
 // uncompress the response
 if (conn.getContentEncoding().equals("deflate"))
 inputStream = new InflaterInputStream(inputStream,
 new Inflater(true));
 else if (conn.getContentEncoding().equals("gzip"))
 inputStream = new GZIPInputStream(inputStream)

// Parsing the XML Response
//The SAX parser, which comes with the Standard Edition of Java, uses event-handler callbacks for each element in the XML
document5
. Therefore, in order to print the record attributes for each field, the “req_sym”, “key”, and “stale” values must be saved
in temporary variables.

 .
 .
 XMLReader reader =
 SAXParserFactory.newInstance().newSAXParser().getXMLReader();
 reader.setContentHandler(new MyXMLParser());
 reader.parse(new InputSource(inputStream));
 } catch (IOException e) {
 // Deal with IOException
 } catch (SAXException e) {
 // Deal with SAXException
 } catch (ParserConfigurationException e) {
 // Deal with ParserConfigurationException
 }
}
public void startElement(String uri, String localName, String qName,
 Attributes atts)
{
 if (qName.equals("Error"))
 System.out.println("Error code: " + atts.getValue("code")
 + ", description: " + atts.getValue("description"));
 else if (qName.equals("Record")) {
 currentReqSym = atts.getValue("req_sym");
 currentKey = atts.getValue("key");
 currentStale = atts.getValue("stale");
 }
 else if (qName.equals("Field"))
 System.out.println("req_sym: " + currentReqSym
 + ", key: " + currentKey + ", stale: " + currentStale
 + ", id: " + atts.getValue("id")
 + ", name: " + atts.getValue("name")
 + " = " + atts.getValue("value"));
}
private String currentReqSym, currentKey, currentStale;
public void characters(char [] ch, int start, int length) {}
public void endDocument() {}
public void endElement(String uri, String localName, String qName) {}
public void endPrefixMapping(String prefix) {}
public void ignorableWhitespace(char[] ch, int start, int length) {}
public void processingInstruction(String target, String data) {}
public void setDocumentLocator(Locator locator) {}
public void skippedEntity(String name) {}
public void startDocument() {}
public void startPrefixMapping(String prefix, String uri) {}
} // class MyXMLParser

​

 

Change Logs