Create & save a custom people view

Introduction

While the ability to using a view on the fly can be useful, we do understand there are use cases that call for a specific view as a requirement. This guide will show you how to create and use a custom view.

Creating your custom view

For this example we will be creating a customer people view. The same methodology can be applied to any data type however. Please reference your data types schema for the fields your can use to create a custom view.

We will use the https://api.datafiniti.co/v4/views API endpoint to create this view. We will use the following top level people fields to create a view that only provides these fields upon an API search/enrichment/suppression request.

  • businessName
  • city
  • emails
  • first name
  • last name
  • jobtitle
  • province
  • postal code
  • phone number

You will have to build the body of the API request as a JSON and must require:

  • name
    • name of the view you are creating
  • data type
    • data type of the view you are creating
  • fields
    • fields matching to your data type's schema
      This what the JSON for the API request should look like:
{
  "name": "people_leads",
  "data_type": "people",
  "fields": [
        {"name": "businessName"},
        {"name": "city"},
        {"name": "emails"},
        {"name": "firstName"},
        {"name": "lastName"},
        {"name": "jobTitle"},
        {"name": "province"},
        {"name": "postalCode"},
        {"name": "phones"}
    ]
}

🚧

Nested fields

Please note that if you use a top level field with nested sub fields that you will have to declare if you wish to flatten the results. Otherwise flatten is set to false by default.

Once you send the request is sent, if successful you will receive a Json 201 response like the following

{
    "name": "people_leads",
    "data_type": "people",
    "fields": [
        {
            "flatten": false,
            "sub_fields": [],
            "name": "businessName"
        },
        {
            "flatten": false,
            "sub_fields": [],
            "name": "city"
        },
        {
            "flatten": false,
            "sub_fields": [],
            "name": "emails"
        },
        {
            "flatten": false,
            "sub_fields": [],
            "name": "firstName"
        },
        {
            "flatten": false,
            "sub_fields": [],
            "name": "lastName"
        },
        {
            "flatten": false,
            "sub_fields": [],
            "name": "jobTitle"
        },
        {
            "flatten": false,
            "sub_fields": [],
            "name": "province"
        },
        {
            "flatten": false,
            "sub_fields": [],
            "name": "postalCode"
        },
        {
            "flatten": false,
            "sub_fields": [],
            "name": "phones"
        }
    ],
    "user": 126609,
    "date_created": "2023-09-14T15:29:14.316Z",
    "date_updated": "2023-09-14T15:29:14.316Z",
    "_id": 1410,
    "isDynamic": false,
    "id": "1410"
}

Using your custom view

Now that you have a customer view, lets use it! This can be done by declaring the view in the body of any search/pagination API call. We will use a people search API call for this example.

{  
	"query":"country:US AND province:CA",  
	"num_records":10,  
	"view":"people_leads"  
}

Here is an example of a records using the newly created leads_view

 {
            "businessName": "Century Marksmen",
            "city": "San Joesee",
            "firstName": "Bruce",
            "lastName": "leeroy",
            "jobTitle": "realtor",
            "province": "CA",
            "id": "YnJTL4oBnlMipTIrlWxx"
        },

📘

Custom view is tied to your account

Please note that once created that your custom view is only tied to your account. If you have question about your view please reference the view ID and name with this API endpoint. https://api.datafiniti.co/v4/views?page=1&limit=10

You can also visit the API reference page here to test your new view or you can download the postman suite here.