GraphQL

Search API provides GraphQL query API, currently for companies only. It has no filtering or sorting capabilities, but it is a convenient way of exploring company hierarchies.

GraphQL companies query takes a list of company IDs as an argument and set of projections to apply on companies with those IDs. Projections may include all regular company attributes, but in GraphQL company has fields describing relations within company hierarchy, that can also be queried. Relations are defined as connections in Relay format.

Currently, query nesting is limited to one level (e.g. one can query children and ancestors for given company, but not children's children or ancestors' roots), with following exceptions:

  • Query parent for ancestor:
{ companies(ids: [1]) {   ancestors {     edges {       node {         id         parent {           edges {             node {               id             }           }         }       }     }   } }}
  • Query children count for some relation
{ companies(ids: [2]) {   children {     edges {       node {         children {           count         }       }     }   }  siblings {  edges {       node {         children {           count         }       }     }   } }}

Result from graph expressions section may be achieved using following GraphQL query:

Fetch companies through GraphQL

POST /v3/graphql
Authorization: Bearer $ACCESS_TOKENContent-Type: application/graphql
{	companies(ids: [56789]) {		id		company_name		children {			edges {				node {					id					company_name				}			}		}		siblings {			edges {				node {					id					company_name				}			}		}	}}
Content-Type: application/json; charset=UTF-8
{  "data": {    "companies": [      {        "id": 56789,        "company_name": "BigCompany US",        "children": {          "edges": [            {              "node": {                "id": 1111,                "company_name": "BigCompany US East"              }            },            {              "node": {                "id": 2222,                "company_name": "BigCompany US South"              }            },            {              "node": {                "id": 3333,                "company_name": "BigCompany US West"              }            }          ]        },        "siblings": {          "edges": [            {              "node": {                "id": 23456,                "company_name": "BigCompany US Asia"              }            },            {              "node": {                "id": 45678,                "company_name": "BigCompany US Australia"              }            },            {              "node": {                "id": 12345,                "company_name": "BigCompany US Europe"              }            },            {              "node": {                "id": 34567,                "company_name": "BigCompany US South America"              }            }          ]        }      }    ]  },  "errors": []}

JSON-wrapped query

GraphQL API also accepts GraphQL queries wrapped as JSON. This is controlled by Content-Type header and to use JSON version, it needs to be set to Content-Type: application/json rather than Content-Type: application/graphql (the latter will be parsed as raw GraphQL query).

After setting appropriate header, the payload should be regular GraphQL over JSON.

Fetch companies through GraphQL over JSON

POST /v3/graphql
Authorization: Bearer $ACCESS_TOKENContent-Type: application/json
{    "query": "query($id:Long!){companies(ids:[$id]){id,company_name}}",    "variables": {        "id": 12345    }}
Content-Type: application/json
{    "data": {        "companies": [            {                "id": 12345,                "company_name": "A Company"            }        ]    },    "errors": []}