loading-img
Login Register

Getting Started

This is the Purk Button public stats api.

You can use the Purk Button public stats API to build advanced websites and applications that accept donations and micropayments. Whether you want to monetize website content, create fundraising platforms or raise money for charitable causes; the Purk Button API has everything you need to integrate Purk with your website and retrieve detailed statistics about payments and donations being made by your users.

Please do note that in order to query this api you need an apikey needs to be sent in the Purk-API-Key header. You can obtain such a key by registering a website in the user portal. After registering a website, you can use the given apikey to make requests from that website: the Origin header will be checked and Access-Control-Allow-Origin will be set accordingly.

Each Purk Button can be used on different webpages, the stats API collects data per-webpage. In this API, a webpage containing a button is defined as a Location. For every Location data is stored about activities (views/clicks) and payments.

Every Activity contains the date when the button was clicked/viewed. Every Payment contains the date, the amount and the transaction hash (txHash) of the donation.

Get Stats

https://api.purkproject.com/api/stats/{Button-API-Key}?start={{rangeStart}}&end={{rangeEnd}}

Get all the stats (payments, activities and locations) about a button, by using its apikey

Headers

Header Value Description
Origin http://www.example.com The website making the request (origin)
Purk-API-Key a8c634ab569ea9854422a0c791fcf3e5f76aaa61 Your Purk stats apikey

Params

Parameter Value Description
start 2018-08-10 08:41:00 Range start date
end 2018-08-10 23:51:00 Range end date

Path Variables

Variable Value Description
Button-API-Key f44bcaf081e4fcc193cdf97b79a81ef0 The button's apikey
Example request

curl --request GET \
  --url 'https://api.purkproject.com/api/stats/{Button-API-Key}?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00' \
  --header 'Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61' \
  --header 'Origin: http://www.example.com'
        

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.purkproject.com/api/stats/{Button-API-Key}?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  "method": "GET",
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
        

require 'uri'
require 'net/http'

url = URI("https://api.purkproject.com/api/stats/{Button-API-Key}?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Origin"] = 'http://www.example.com'
request["Purk-API-Key"] = 'a8c634ab569ea9854422a0c791fcf3e5f76aaa61'

response = http.request(request)
puts response.read_body
        

import requests

url = "https://api.purkproject.com/api/stats/{Button-API-Key}"

querystring = {"start":"2018-08-01%2008:41:00","end":"2018-08-10%2023:51:00"}

headers = {
    'Origin': "http://www.example.com",
    'Purk-API-Key': "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
    }

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
        

var http = require("http");

var options = {
  "method": "GET",
  "hostname": [
    "https://api.purkproject.com/api"
  ],
  "path": [
    "stats",
    "{Button-API-Key}"
  ],
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
        

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.purkproject.com/api/stats/{Button-API-Key}?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61",
    "Origin: http://www.example.com"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
        

package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.purkproject.com/api/stats/{Button-API-Key}?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Origin", "http://www.example.com")
  req.Header.Add("Purk-API-Key", "a8c634ab569ea9854422a0c791fcf3e5f76aaa61")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
        
Example response

[
  {
    "views": 3,
    "clicks": 1,
    "payments": [],
    "paymentsCount": 0,
    "url": "http://www.example.com/page-3",
    "total": 0
  },
  {
    "views": 2,
    "clicks": 2,
    "payments": [],
    "paymentsCount": 0,
    "url": "http://www.example.com/page-2",
    "total": 0
  },
  {
    "views": 1,
    "clicks": 3,
    "payments": [],
    "paymentsCount": 0,
    "url": "http://www.example.com/page-1",
    "total": 0
  },
  {
    "views": 5,
    "clicks": 3,
    "payments": [
      {
        "amount": 10000,
        "date": "2018-08-08T17:22:15.542Z",
        "txHash": "<2ddf598e948be2a886d283d10f5d16a8f9d0c8230d6cf547e5fb5781b1ef2579>",
        "paymentIdHex": "0e2751d7449983583b380a4de96377fb5ef0eb89d55cacd676f280eebfa9c3e4"
      },
      {
        "amount": 10000,
        "date": "2018-08-08T16:02:04.227Z",
        "txHash": "<6e3bda27e7bc9b5a9c2f4614dd68183b4f553c6454a66cb8a9ea2622f9b7bb12>",
        "paymentIdHex": "0e2751d7449983583b380a4de96377fb5ef0eb89d55cacd676f280eebfa9c3e4"
      }
    ],
    "paymentsCount": 2,
    "url": "http://localhost:8000/",
    "total": 20000
  }
]
        

Get Payments

https://api.purkproject.com/api/stats/{Button-API-Key}/payments?start={{rangeStart}}&end={{rangeEnd}}

Get all the payments of a button, by using its apikey

Headers

Header Value Description
Origin http://www.example.com The website making the request (origin)
Purk-API-Key a8c634ab569ea9854422a0c791fcf3e5f76aaa61 Your Purk stats apikey

Params

Parameter Value Description
start 2018-08-10 08:41:00 Range start date
end 2018-08-10 23:51:00 Range end date

Path Variables

Variable Value Description
Button-API-Key f44bcaf081e4fcc193cdf97b79a81ef0 The button's apikey
Example request

curl --request GET \
  --url 'https://api.purkproject.com/api/stats/{Button-API-Key}/payments?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00' \
  --header 'Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61' \
  --header 'Origin: http://www.example.com'
        

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.purkproject.com/api/stats/{Button-API-Key}/payments?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  "method": "GET",
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
        

require 'uri'
require 'net/http'

url = URI("https://api.purkproject.com/api/stats/{Button-API-Key}/payments?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Origin"] = 'http://www.example.com'
request["Purk-API-Key"] = 'a8c634ab569ea9854422a0c791fcf3e5f76aaa61'

response = http.request(request)
puts response.read_body
        

import requests

url = "https://api.purkproject.com/api/stats/{Button-API-Key}/payments"

querystring = {"start":"2018-08-01%2008:41:00","end":"2018-08-10%2023:51:00"}

headers = {
    'Origin': "http://www.example.com",
    'Purk-API-Key': "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
    }

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
        

var http = require("http");

var options = {
  "method": "GET",
  "hostname": [
    "https://api.purkproject.com/api"
  ],
  "path": [
    "stats",
    "{Button-API-Key}",
    "payments"
  ],
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
        

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.purkproject.com/api/stats/{Button-API-Key}/payments?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61",
    "Origin: http://www.example.com"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
        

package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.purkproject.com/api/stats/{Button-API-Key}/payments?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Origin", "http://www.example.com")
  req.Header.Add("Purk-API-Key", "a8c634ab569ea9854422a0c791fcf3e5f76aaa61")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
        
Example response

{
  "payments": [
    {
      "amount": 10000,
      "date": "2018-08-08T17:22:15.542Z",
      "txHash": "<2ddf598e948be2a886d283d10f5d16a8f9d0c8230d6cf547e5fb5781b1ef2579>",
      "paymentIdHex": "0e2751d7449983583b380a4de96377fb5ef0eb89d55cacd676f280eebfa9c3e4"
    },
    {
      "amount": 10000,
      "date": "2018-08-08T16:02:04.227Z",
      "txHash": "<6e3bda27e7bc9b5a9c2f4614dd68183b4f553c6454a66cb8a9ea2622f9b7bb12>",
      "paymentIdHex": "0e2751d7449983583b380a4de96377fb5ef0eb89d55cacd676f280eebfa9c3e4"
    }
  ],
  "count": 2,
  "total": 20000
}
      

Get Activities

https://api.purkproject.com/api/stats/{Button-API-Key}/activities?start={{rangeStart}}&end={{end}}

Get all the activities (views/clicks) regarding a button, by using its apikey

Headers

Header Value Description
Origin http://www.example.com The website making the request (origin)
Purk-API-Key a8c634ab569ea9854422a0c791fcf3e5f76aaa61 Your Purk stats apikey

Params

Parameter Value Description
start 2018-08-10 08:41:00 Range start date
end 2018-08-10 23:51:00 Range end date

Path Variables

Variable Value Description
Button-API-Key f44bcaf081e4fcc193cdf97b79a81ef0 The button's apikey
Example request
 
curl --request GET \
  --url 'https://api.purkproject.com/api/stats/{Button-API-Key}/activities?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00' \
  --header 'Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61' \
  --header 'Origin: http://www.example.com'
         

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.purkproject.com/api/stats/{Button-API-Key}/activities?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  "method": "GET",
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
        

require 'uri'
require 'net/http'

url = URI("https://api.purkproject.com/api/stats/{Button-API-Key}/activities?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Origin"] = 'http://www.example.com'
request["Purk-API-Key"] = 'a8c634ab569ea9854422a0c791fcf3e5f76aaa61'

response = http.request(request)
puts response.read_body
        

import requests

url = "https://api.purkproject.com/api/stats/{Button-API-Key}/activities"

querystring = {"start":"2018-08-01%2008:41:00","end":"2018-08-10%2023:51:00"}

headers = {
    'Origin': "http://www.example.com",
    'Purk-API-Key': "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
    }

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
        

var http = require("http");

var options = {
  "method": "GET",
  "hostname": [
    "https://api.purkproject.com/api"
  ],
  "path": [
    "stats",
    "{Button-API-Key}",
    "activities"
  ],
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
        

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.purkproject.com/api/stats/{Button-API-Key}/activities?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61",
    "Origin: http://www.example.com"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
        

package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.purkproject.com/api/stats/{Button-API-Key}/activities?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Origin", "http://www.example.com")
  req.Header.Add("Purk-API-Key", "a8c634ab569ea9854422a0c791fcf3e5f76aaa61")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
        
Example response

{
  "views": 8,
  "clicks": 8
}
        

Get Locations

https://api.purkproject.com/api/stats/{Button-API-Key}/locations

Get all the locations (webpages) a button was seen in, by using its apikey

Headers

Header Value Description
Origin http://www.example.com The website making the request (origin)
Purk-API-Key a8c634ab569ea9854422a0c791fcf3e5f76aaa61 Your Purk stats apikey

Path Variables

Variable Value Description
Button-API-Key f44bcaf081e4fcc193cdf97b79a81ef0 The button's apikey
Example request

curl --request GET \
  --url 'https://api.purkproject.com/api/stats/{Button-API-Key}/locations?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00' \
  --header 'Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61' \
  --header 'Origin: http://www.example.com'
        

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.purkproject.com/api/stats/{Button-API-Key}/locations?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  "method": "GET",
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
        

require 'uri'
require 'net/http'

url = URI("https://api.purkproject.com/api/stats/{Button-API-Key}/locations?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Origin"] = 'http://www.example.com'
request["Purk-API-Key"] = 'a8c634ab569ea9854422a0c791fcf3e5f76aaa61'

response = http.request(request)
puts response.read_body
        

import requests

url = "https://api.purkproject.com/api/stats/{Button-API-Key}/locations"

querystring = {"start":"2018-08-01%2008:41:00","end":"2018-08-10%2023:51:00"}

headers = {
    'Origin': "http://www.example.com",
    'Purk-API-Key': "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
    }

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
        

var http = require("http");

var options = {
  "method": "GET",
  "hostname": [
    "https://api.purkproject.com/api"
  ],
  "path": [
    "stats",
    "{Button-API-Key}",
    "locations"
  ],
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
        

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.purkproject.com/api/stats/{Button-API-Key}/locations?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61",
    "Origin: http://www.example.com"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
        

package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.purkproject.com/api/stats/{Button-API-Key}/locations?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Origin", "http://www.example.com")
  req.Header.Add("Purk-API-Key", "a8c634ab569ea9854422a0c791fcf3e5f76aaa61")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
        
Example response

[
  {
    "url": "http://www.example.com/page-3",
    "id": 1
  },
  {
    "url": "http://www.example.com/page-2",
    "id": 2
  },
  {
    "url": "http://www.example.com/page-1",
    "id": 3
  },
  {
    "url": "http://localhost:8000/",
    "id": 4
  }
]
        

Get Location Payments

https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/payments?start={{rangeStart}}&end={{rangeEnd}}

Get all the payments (donations) made to a button on a given location, by using the button's apikey and the location's ID

NOTE: you can get the locations' IDs by using Get Locations method of the API

Headers

Header Value Description
Origin http://www.example.com The website making the request (origin)
Purk-API-Key a8c634ab569ea9854422a0c791fcf3e5f76aaa61 Your Purk stats apikey

Params

Parameter Value Description
start 2018-08-10 08:41:00 Range start date
end 2018-08-10 23:51:00 Range end date

Path Variables

Variable Value Description
Button-API-Key f44bcaf081e4fcc193cdf97b79a81ef0 The button's apikey
Example request

curl --request GET \
  --url 'https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/payments?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00' \
  --header 'Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61' \
  --header 'Origin: http://www.example.com'
        

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/payments?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  "method": "GET",
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
        

require 'uri'
require 'net/http'

url = URI("https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/payments?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Origin"] = 'http://www.example.com'
request["Purk-API-Key"] = 'a8c634ab569ea9854422a0c791fcf3e5f76aaa61'

response = http.request(request)
puts response.read_body
        

import requests

url = "https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/payments"

querystring = {"start":"2018-08-01%2008:41:00","end":"2018-08-10%2023:51:00"}

headers = {
    'Origin': "http://www.example.com",
    'Purk-API-Key': "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
    }

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
        

var http = require("http");

var options = {
  "method": "GET",
  "hostname": [
    "https://api.purkproject.com/api"
  ],
  "path": [
    "stats",
    "{Button-API-Key}",
    "locations",
    ":locationId",
    "payments"
  ],
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
        

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/payments?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61",
    "Origin: http://www.example.com"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
        

package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/payments?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Origin", "http://www.example.com")
  req.Header.Add("Purk-API-Key", "a8c634ab569ea9854422a0c791fcf3e5f76aaa61")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
        
Example response

{
  "payments": [
    {
      "amount": 10000,
      "date": "2018-08-08T17:22:15.542Z",
      "txHash": "<2ddf598e948be2a886d283d10f5d16a8f9d0c8230d6cf547e5fb5781b1ef2579>",
      "paymentIdHex": "0e2751d7449983583b380a4de96377fb5ef0eb89d55cacd676f280eebfa9c3e4"
    },
    {
      "amount": 10000,
      "date": "2018-08-08T16:02:04.227Z",
      "txHash": "<6e3bda27e7bc9b5a9c2f4614dd68183b4f553c6454a66cb8a9ea2622f9b7bb12>",
      "paymentIdHex": "0e2751d7449983583b380a4de96377fb5ef0eb89d55cacd676f280eebfa9c3e4"
    }
  ],
  "count": 2,
  "total": 20000
}
        

Get Location Activities

https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/activities?start={{rangeStart}}&end={{rangeEnd}}

Get all the activities (views/clicks) of a button on a given location, by using the button's apikey and the location's ID

NOTE: you can get the locations' IDs by using Get Locations method of the API

Headers

Header Value Description
Origin http://www.example.com The website making the request (origin)
Purk-API-Key a8c634ab569ea9854422a0c791fcf3e5f76aaa61 Your Purk stats apikey

Params

Parameter Value Description
start 2018-08-10 08:41:00 Range start date
end 2018-08-10 23:51:00 Range end date

Path Variables

Variable Value Description
Button-API-Key f44bcaf081e4fcc193cdf97b79a81ef0 The button's apikey
locationId 4 The location's ID
Example request

curl --request GET \
  --url 'https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/activities?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00' \
  --header 'Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61' \
  --header 'Origin: http://www.example.com'
        

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/activities?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  "method": "GET",
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
        

require 'uri'
require 'net/http'

url = URI("https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/activities?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Origin"] = 'http://www.example.com'
request["Purk-API-Key"] = 'a8c634ab569ea9854422a0c791fcf3e5f76aaa61'

response = http.request(request)
puts response.read_body
        

import requests

url = "https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/activities"

querystring = {"start":"2018-08-01%2008:41:00","end":"2018-08-10%2023:51:00"}

headers = {
    'Origin': "http://www.example.com",
    'Purk-API-Key': "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
    }

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
        

var http = require("http");

var options = {
  "method": "GET",
  "hostname": [
    "https://api.purkproject.com/api"
  ],
  "path": [
    "stats",
    "{Button-API-Key}",
    "locations",
    ":locationId",
    "activities"
  ],
  "headers": {
    "Origin": "http://www.example.com",
    "Purk-API-Key": "a8c634ab569ea9854422a0c791fcf3e5f76aaa61"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
        

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/activities?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Purk-API-Key: a8c634ab569ea9854422a0c791fcf3e5f76aaa61",
    "Origin: http://www.example.com"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
        

package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.purkproject.com/api/stats/{Button-API-Key}/locations/:locationId/activities?start=2018-08-01%2008:41:00&end=2018-08-10%2023:51:00"

  req, _ := http.NewRequest("GET", url, nil)

  req.Header.Add("Origin", "http://www.example.com")
  req.Header.Add("Purk-API-Key", "a8c634ab569ea9854422a0c791fcf3e5f76aaa61")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
        
Example response

{
  "views": 3,
  "clicks": 3
}
        

Error Glossary

Authorization Errors

Code Body Description
400 missing header "Purk-API-Key" Header "Purk-API-Key" was not supplied
401 invalid stats api key Supplied api key isn't valid
403 invalid header "Origin" The Origin header doesn't match the supplied api key

Button Errors

Code Body Description
401 invalid button api key Supplied button's api key is not valid
403 private stats The requested button doesn't allow public stats