Query Layer

The Query Layer Developer Hub

Welcome to the QueryLayer Developer Guides and API Docs.

QueryLayer is Data Query Infrastructure for developer teams to automate compliance with and management of Sensitive Data. We design and build software that makes it easier for you and your teams to build products for your users that do the right thing at all times with data; keeping you and your users safer and ensuring trust in data-driven businesses.

We have language for Shell, Java, Ruby, Python, and JavaScript. You can view code examples in the dark area to the bottom, and you can switch the programming language of the examples with the tabs.

Get Started    

Text Analysis Walkthrough

This page will help run your first text analysis with Query Layer.

1. Create a Developer Account

Sign up for a developer account and get access to the Query Layer console. From here you can setup your business, and start running queries.

2. Get Test Keys

After activating your account you are able to access your JWT token, you can use these to run queries in our sandbox environment where no real data will be used.

To use the examples below, replace YOUR_JWT_TOKEN with your own.

3. Run Unstructured text anonymization

The following cURL command creates a TextAnalysisSession which contains a single unstructured text string. Remember to Replace YOUR_JWT_TOKEN with your JWT token.

curl --request POST \
  --url https://app.querylayer.com:5000/demo-organization/api/data_types/analyze \
  --header 'authorization: Bearer <YOUR_JWT_TOKEN>' \
  --header 'content-type: application/json' \
  --data '{"q":"Hello, my name is David Johnson and I live in Maine.My credit card number is 4095-2609-9393-4932 and my Crypto wallet id is 16Yeky6GMjeNkAiNcBY7ZhrLoMSgg1BoyZ. On September 18 I visited microsoft.com and sent an email to [email protected],  from the IP 192.168.0.1. My passport: 191280345 and my phone number: (212) 555-1234."}'
var data = JSON.stringify({
  "q": "Hello, my name is David Johnson and I live in Maine.My credit card number is 4095-2609-9393-4932 and my Crypto wallet id is 16Yeky6GMjeNkAiNcBY7ZhrLoMSgg1BoyZ. On September 18 I visited microsoft.com and sent an email to [email protected],  from the IP 192.168.0.1. My passport: 191280345 and my phone number: (212) 555-1234."
});

var xhr = new XMLHttpRequest();

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://appdev.querylayer.com:5000/demo-organization/api/data_types/analyze");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer <YOUR_JWT_TOKEN>");

xhr.send(data);
require 'uri'
require 'net/http'

url = URI("http://appdev.querylayer.com:5000/demo-organization/api/data_types/analyze")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer <YOUR_JWT_TOKEN>'
request.body = "{\"q\":\"Hello, my name is David Johnson and I live in Maine.My credit card number is 4095-2609-9393-4932 and my Crypto wallet id is 16Yeky6GMjeNkAiNcBY7ZhrLoMSgg1BoyZ. On September 18 I visited microsoft.com and sent an email to [email protected],  from the IP 192.168.0.1. My passport: 191280345 and my phone number: (212) 555-1234.\"}"

response = http.request(request)
puts response.read_body
import requests

url = "http://appdev.querylayer.com:5000/demo-organization/api/data_types/analyze"

payload = "{\"q\":\"Hello, my name is David Johnson and I live in Maine.My credit card number is 4095-2609-9393-4932 and my Crypto wallet id is 16Yeky6GMjeNkAiNcBY7ZhrLoMSgg1BoyZ. On September 18 I visited microsoft.com and sent an email to [email protected],  from the IP 192.168.0.1. My passport: 191280345 and my phone number: (212) 555-1234.\"}"
headers = {
    'content-type': "application/json",
    'authorization': "Bearer <YOUR_JWT_TOKEN>"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

After running the above cURL command in your terminal, you'll see the response will return a Json object.

{
   "results":[
      {
         "field":{
            "name":"DOMAIN_NAME"
         },
         "score":1,
         "location":{
            "start":46,
            "end":54,
            "length":8
         }
      },
      {
         "field":{
            "name":"CREDIT_CARD"
         },
         "score":1,
         "location":{
            "start":77,
            "end":96,
            "length":19
         }
      },
      {
         "field":{
            "name":"CRYPTO"
         },
         "score":1,
         "location":{
            "start":124,
            "end":158,
            "length":34
         }
      },
      {
         "field":{
            "name":"DOMAIN_NAME"
         },
         "score":1,
         "location":{
            "start":186,
            "end":199,
            "length":13
         }
      },
      {
         "field":{
            "name":"EMAIL_ADDRESS"
         },
         "score":1,
         "location":{
            "start":221,
            "end":239,
            "length":18
         }
      },
      {
         "field":{
            "name":"DOMAIN_NAME"
         },
         "score":1,
         "location":{
            "start":226,
            "end":239,
            "length":13
         }
      },
      {
         "field":{
            "name":"PHONE_NUMBER"
         },
         "score":1,
         "location":{
            "start":311,
            "end":325,
            "length":14
         }
      },
      {
         "field":{
            "name":"IP_ADDRESS"
         },
         "score":0.95,
         "location":{
            "start":254,
            "end":265,
            "length":11
         }
      },
      {
         "field":{
            "name":"PERSON"
         },
         "score":0.85,
         "location":{
            "start":18,
            "end":31,
            "length":13
         }
      },
      {
         "field":{
            "name":"LOCATION"
         },
         "score":0.85,
         "location":{
            "start":46,
            "end":51,
            "length":5
         }
      },
      {
         "field":{
            "name":"DATE_TIME"
         },
         "score":0.85,
         "location":{
            "start":163,
            "end":175,
            "length":12
         }
      }
   ],
   "text":"Hello, my name is <PERSON> and I live in <DOMAIN_NAME> credit card number is <CREDIT_CARD> and my Crypto wallet id is <CRYPTO>. On <DATE_TIME> I visited <DOMAIN_NAME> and sent an email to [email protected]<DOMAIN_NAME>,  from the IP <IP_ADDRESS>. My passport: 191280345 and my phone number: <PHONE_NUMBER>."
}

Query Layer automatically detects the Personal-Identifiable Information (PII), annonymizes it based on one or more anonymization mechanisms, and returns a string with no personal identifiable data.

For example in the above, the input was:

Hello, my name is David Johnson and I live in Maine. My credit card number is 4095-2609-9393-4932 and my Crypto wallet id is 16Yeky6GMjeNkAiNcBY7ZhrLoMSgg1BoyZ. 
 
On September 18 I visited microsoft.com and sent an email to [email protected],  from the IP 192.168.0.1. 

My passport: 191280345 and my phone number: (212) 555-1234.

And the output text string was:

Hello, my name is <PERSON> and I live in <LOCATION>. 
My credit card number is <CREDIT_CARD> and my Crypto wallet id is <CRYPTO>. 
 
On <DATE_TIME> I visited <DOMAIN_NAME> and sent an email to <EMAIL_ADDRESS>,  from the IP <IP_ADDRESS>. 

My passport: <US_PASSPORT> and my phone number: <PHONE_NUMBER>.

For each data type, Query Layer returns a confidence score:


Field TypeScoreTextStart:End
CREDIT_CARD179:98
CRYPTO1126:160
DOMAIN_NAME1191:204
EMAIL_ADDRESS1226:244
DOMAIN_NAME1231:244
PHONE_NUMBER1318:332
IP_ADDRESS0.95259:270
PERSON0.8518:31
LOCATION0.8546:51
DATE_TIME0.85168:180
US_PASSPORT0.4287:296
US_SSN0.3287:296

Updated 18 days ago


Text Analysis Walkthrough


This page will help run your first text analysis with Query Layer.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.