Skip to content

Accessing the API

v3 API Authorization

All v3 Local Logic APIs use access tokens (JSON Web Tokens) to authorize requests and no longer require API keys.

Token Retrieval

Tokens can be retrieved from the api.locallogic.co/oauth/token API with a client_id and a client_secret as query parameters, which we will send to you privately. Make sure to keep these credentials in a safe place!

Example: api.locallogic.co/oauth/token?client_id={CLIENT_ID}&client_secret={CLIENT_SECRET} will return a response similar to the following:

{
"access_token": "YOUR.ACCESS.TOKEN",
"token_type": "Bearer"
}

Token Usage

This token must be used in the Authorization Header for all v3 API requests. Remember to include the word Bearer at the beginning of the authorization string.

Issued tokens expire within 24 hours of retrieval to improve security (if a token is somehow leaked, it won’t be usable forever), so we recommend retrieving the token just prior to all v3 API calls. For example, in NodeJS it could be implemented as follows:

var fetch = require("node-fetch");
// call authorization API
fetch('https://api.locallogic.co/oauth/token?' + new URLSearchParams({
client_id: '<CLIENT_ID>',
client_secret: '<CLIENT_SECRET>'
}), {
method: 'GET',
})
.then(authResponse => authResponse.json())
.then(authBody => {
var accessToken = authBody.access_token;
// call v3 API with access token
return fetch('api.locallogic.co/v3/<resource>?' + new URLSearchParams({
lat: 41.847206,
lng: -87.668825
}), {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: 'Bearer ' + accessToken
}
})
})
.then(response => response.json())
.then(body => {
// successful API call
console.log(body)
})
.catch(error => {
// handle error
console.log(error);
});

Tracking

Add the following script to your HTML page or template. Make sure to replace the {YOUR_TOKEN} placeholder with the token we provided to you. If you don’t have a token, contact us.

<script async defer
src="https://cdn.locallogic.co/sdk/?token={YOUR_TOKEN}&usage=api">
</script>
  • ⚠️ Make sure you have correctly replaced your SDK token in the example above, including removing the curly brackets.
  • ⚠️ Make sure there is no callback parameter in the script URL
  • ⚠️ Make sure to have the usage=api parameter in the script URL
Edit this page on GitHub
2 contributorschrisarnold91jpvalery
Last edited by chrisarnold91 on May 6, 2021