Authentication

To maintain API access, please provide your API Access key in the header with each HTTP request:

x-craft-api-key: YOUR_API_KEY

In order to request an API key, please reach out to sales@craft.co

Example with JavaScript:

require('isomorphic-fetch');
API_KEY = 'qfNfdijpFhbhPhA7j2ZxvtEGkfv8DftTtmTEbnWN';
API_ENDPOINT = 'https://api.craft.co/v1/query';
GRAPHQL_QUERY = 'query getCompany($domain: String!) { company(domain: $domain) { locations { city, country } } }';
requestHeaders= { 'Content-Type': 'application/json', 'x-craft-api-key': API_KEY };
requestData = { 'query': GRAPHQL_QUERY, 'variables': { 'domain': 'facebook.com' } };
fetch(API_ENDPOINT, {
method: 'POST',
headers: requestHeaders,
body: JSON.stringify(requestData),
})
.then(function(response) { return response.json() })
.then(console.log)
.catch(console.error);

You must replace qfNfdijpFhbhPhA7j2ZxvtEGkfv8DftTtmTEbnWN in the further examples with your company's unique API key.