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 [email protected]
Example with JavaScript:
1
require('isomorphic-fetch');
2
3
API_KEY = 'qfNfdijpFhbhPhA7j2ZxvtEGkfv8DftTtmTEbnWN';
4
API_ENDPOINT = 'https://api.craft.co/v1/query';
5
GRAPHQL_QUERY = 'query getCompany($domain: String!) { company(domain: $domain) { locations { city, country } } }';
6
7
requestHeaders= { 'Content-Type': 'application/json', 'x-craft-api-key': API_KEY };
8
requestData = { 'query': GRAPHQL_QUERY, 'variables': { 'domain': 'facebook.com' } };
9
10
fetch(API_ENDPOINT, {
11
method: 'POST',
12
headers: requestHeaders,
13
body: JSON.stringify(requestData),
14
})
15
.then(function(response) { return response.json() })
16
.then(console.log)
17
.catch(console.error);
Copied!
You must replace qfNfdijpFhbhPhA7j2ZxvtEGkfv8DftTtmTEbnWN in the further examples with your company's unique API key.
Last modified 1yr ago
Copy link