×
×

Hello world.

3 steps and you're good to go — no API key required.

1. Embed treaty.js

Copy and paste the following code snippet into your HTML document, preferably before the closing </body> tag.

<script src="https://treaty.io/beta/treaty.js"></script>

2. Generate your token

Once treaty.js is embedded, use the following function to generate your token.

treaty.getToken(function(token){
	console.log(token);
});

3. Consume your token

Query our API by providing your token in the request. Each token is valid for 24 hours and can be used only once.

https://treaty.io/beta/api/?token=YOUR_TOKEN
treaty.consumeToken(YOUR_TOKEN, function(fingerprint){
	console.log(fingerprint);
});

Example response

If the submitted token is valid, a JSON fingerprint will be returned by the API.

Loading fingerprint...

Response object

Example error

If the submitted token is invalid, expired or missing, a invalid_token_error will be returned by the API.

{
  "error": {
	"type": "invalid_token_error",
	"message": "Invalid token"
  }
}

Complete example

Copy and paste the following example into an empty html document, upload it to your server and open it with your favorite browser. Make sure you access the example via a valid domain name otherwise you will get a invalid_referrer_error.

<!DOCTYPE html>
<script src="https://treaty.io/beta/treaty.js"></script>
<script>
	treaty.getToken(function(token){
		treaty.consumeToken(token, function(fingerprint){
			console.log(fingerprint);
		});
	});
</script>

Rate limits

Free usage of our API is limited to 1,000 daily requests. If you exceed 1,000 queries in a 24 hour period, we'll return a rate_limit_exceeded error with a 429 HTTP status code. You must sign up and add a credit card to your account if you need to make more requests.

Support

If you have any questions or difficulties, feel free to submit an issue on GitHub.

Please include as much detail as possible. If the problem is reproducible, sample code is also helpful. If you wish to discuss an issue privately, send us an email via the contact page.

This product includes GeoLite2 data created by MaxMind, available from maxmind.com.