Integração com a plataforma binds.co

Olá, bem-vindo à binds.co! Nessa página você encontrará informações práticas e condensadas de como integrar com as APIs da binds.co. Mas primeiro, para que você possa começar a utiliza-las, você deve criar uma conta em nossa plataforma. Você pode criá-la por aqui.

A seguir reunimos as principais informações para integrar com a plataforma binds.co.

A informação deve ser enviada no formato JSON com encoding UTF-8. Em resposta, a API sempre retorna dados em UTF-8.

API Reference

A autenticacação é feita por Basic Auth, o seus token e chave serão usados para acessar o endpoint.

https://app.binds.co/api/

Autenticação

Como para acessar qualquer sistema, o primeiro passo para usar as APIs é se autenticar. É nessa etapa que você vai se conectar com os nossos serviços e estará apto a iniciar o desenvolvimento de sua aplicação. Para fazer as requisições em nossas APIs você vai precisar das chaves de acesso. As chaves de acesso são confidenciais e recomendamos não compartilhá-las em ambientes públicos ou com terceiros.

A autenticação para as APIs é feita via HTTP Basic Auth e deve seguir os passos descritos a seguir:

1. Crie uma conta binds.co
2. Valide seu e-email, é importante, você usará ele para acessar o ambiente.
3. Em sua ferramenta de desenvolvimento utilize como chaves de acesso seu e-mail e senha da conta binds.co. Nós utilizaremos o Postman! Caso você queira usá-lo, ele será usado nos próximos exemplos. Como abaixo, em um exemplo de como os dados da autenticação devem ser preenchidos. :)

Image

Listar Pesquisas

Por meio desta API é possível consultar as informações e detalhes de uma lista de pesquisas criadas.

  • GET https://app.binds.co/api/surveys
Headers Description
Authorization Basic [gerar hash base64 do token:chave]
Content-Type application/json;utf-8
Request Example:
GET /api/surveys
Host: app.binds.co
Content-Type: application/json
Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/
                      
Request Example:
curl -X GET \
    https://app.binds.co/api/surveys \
    -H 'Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/' \
    -H 'Content-Type: application/json' \
  
Request Example:
var http = require("https");

var options = {
  "method": "GET",
  "hostname": [
    "app",
    "binds",
    "co"
  ],
  "path": [
    "api",
    "surveys"
  ],
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/",
    "Cache-Control": "no-cache",
    "Postman-Token": "bee10047-0936-ee83-cf56-d0c733c86e30"
  }
};

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();
    
Request Example:
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://app.binds.co/api/surveys",
  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(
    "Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/",
    "Content-Type: application/json"
  ),
));

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

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
Request Example:
require 'uri'
require 'net/http'

url = URI("https://app.binds.co/api/surveys")

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

request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/'

response = http.request(request)
puts response.read_body
Request Example:
import http.client

conn = http.client.HTTPConnection("app,binds,co")

headers = {
    'Content-Type': "application/json",
    'Authorization': "YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/"
    }

conn.request("GET", "api,surveys", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
Request Example:
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://app.binds.co/api/surveys")
  .get()
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/")
  .build();

Response response = client.newCall(request).execute();
Request Example:
package main

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

func main() {

    url := "https://app.binds.co/api/surveys"

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

    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Authorization", "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/")
    res, _ := http.DefaultClient.Do(req)

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

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

}
Result Example:
[
      {
          "_id": "a05fa4cc286de86011a265b1b849",
          "title": "Pesquisa NPS",
          "updatedAt": "2018-05-14T14:20:20.893Z",
          "createdAt": "2018-05-14T14:20:20.889Z",
          "hashId": "wYgvnZrDEqbPaKoHJKHJKHd9IjZgD7BNxv3VWBN765mplA8e"
      },
      {
          "_id": "ecf57f429307842fb0bc26549f02",
          "title": "Pesquisa pós-atendimento",
          "updatedAt": "2018-05-14T22:07:29.122Z",
          "createdAt": "2018-05-14T14:20:20.834Z",
          "hashId": "iGwTnZrDEqbPaKoHJKHJKHd9IjZgD7BNxv3VWBN765mplA6e"
      }
  ]

Obter collector (chave para envio de pesquisa)

Por meio desta API é possível obter "collectors" que são as chaves para envio de pesquisas.

  • GET https://app.binds.co/api/collectors/
Headers Description
Authorization Basic [gerar hash base64 do token:chave]
Content-Type application/json;utf-8
Request Example:
GET /api/collectors
Host: app.binds.co
Content-Type: application/json
Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/
  
Request Example:
curl -X GET \
    https://app.binds.co/api/collectors \
    -H 'Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/' \
    -H 'Content-Type: application/json' \
  
Request Example:
var http = require("https");

var options = {
  "method": "GET",
  "hostname": [
    "app",
    "binds",
    "co"
  ],
  "path": [
    "api",
    "collectors"
  ],
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/",
    "Cache-Control": "no-cache",
    "Postman-Token": "e1abcd9a-b859-f58b-c906-f181ab7b03f0"
  }
};

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

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });
    
Request Example:
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://app.binds.co/api/collectors",
  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(
    "Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/",
    "Content-Type: application/json"
  ),
));

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

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
Request Example:
require 'uri'
require 'net/http'

url = URI("https://app.binds.co/api/collectors")

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

request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/'

response = http.request(request)
puts response.read_body
Request Example:
import http.client

conn = http.client.HTTPConnection("app,binds,co")

headers = {
    'Content-Type': "application/json",
    'Authorization': "YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/"
    }

conn.request("GET", "api,collectors", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
Request Example:
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://app.binds.co/api/collectors")
  .get()
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/")
  .build();

Response response = client.newCall(request).execute();
Request Example:
package main

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

func main() {

    url := "https://app.binds.co/api/collectors"

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

    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Authorization", "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/")
    res, _ := http.DefaultClient.Do(req)

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

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

}
Result Example:
[
    {
        "_id": "f82fbe29b6f45253470c0f4079c2",
        "survey": "5ac4e1224b1e5123c58767d3",
        "name": "Pesquisa NPS",
        "updatedAt": "2018-06-14T20:12:06.736Z",
        "createdAt": "2018-06-14T20:12:06.736Z"
    },
    {
        "_id": "4756540007cb2bf23c92f4ef92f8",
        "survey": "5b17eab879b5c823cecdc46e",
        "name": "Pesquisa pós-atendimento",
        "updatedAt": "2018-06-14T20:12:06.736Z",
        "createdAt": "2018-06-14T20:12:06.736Z"
    }
]

Disparando uma pesquisa pela API

A ideia é notificar a plataforma binds.co quando ocorre o evento em questão, por exemplo uma venda na loja, ou uma entrega. Isso acontece através de um POST simples, por HTTPS, em nossa API REST.

O campo collector é obrigatório, ele é usado para identificar a origem desta integração. O nome e e-mail também são obrigatórios. Também é possível incluir outros campos, em metadata, para enriquecer os relatórios.

  • POST https://app.binds.co/api/seeds
Body Params Description
collector
string
Chave de integração ou Identificação da pesquisa a ser enviada.
from
object
from.name
string
Nome da pessoa a ser pesquisada.
from.email
string
E-mail da pessoa a ser pesquisada.
from.phone
string
Número celular(+5511000000000) da pessoa a ser pesquisada, para envios via SMS.
metadata
object
Campos livres, podem ser utilizados para enriquecer e/ou parametrizar relatórios.
Headers Description
Authorization Basic [gerar hash base64 do token:chave]
Content-Type application/json;utf-8
Request Example:
POST /api/seeds
Host: app.binds.co
Content-Type: application/json
Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/
{
  "collector": "f82fbe29b6f45253470c0f4079c2",
  "from": {
    "name": "Charlie Parker",
    "email": "hello@binds.co"
  },
    "metadata": {
     "campoPersonalizado1": "Charlie",
     "campoPersonalizado2": "São Paulo",
     "campoPersonalizado3": "5511000000000"
    }
}

  
Request Example:
#! /bin/bash
curl -X POST -H "Content-Type: application/json; charset=UTF-8" -d '{
  "collector": "f82fbe29b6f45253470c0f4079c2",
  "from": {
    "name": "Charlie Parker",
    "email": "hello@binds.co"
  },
    "metadata": {
     "campoPersonalizado1": "Charlie",
     "campoPersonalizado2": "São Paulo",
     "campoPersonalizado3": "5511000000000"
    }
}' "https://app.binds.co/api/seeds"
  
Request Example:
var http = require("https");

var options = {
  "method": "POST",
  "hostname": [
    "app",
    "binds",
    "co"
  ],
  "path": [
    "api",
    "seeds"
  ],
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/",
    "Cache-Control": "no-cache",
    "Postman-Token": "8fc16b67-6c12-b70a-bbe4-cabb0409c259"
  }
};

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.write(JSON.stringify({ collector: 'f82fbe29b6f45253470c0f4079c2',
  from: { name: 'Charlie Parker', email: 'hello@binds.co' },
  metadata:
   { campoPersonalizado1: 'Charlie',
     campoPersonalizado2: 'São Paulo',
     campoPersonalizado3: '5511000000000' } }));
req.end();
    
Request Example:
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://app.binds.co/api/seeds",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{"collector": "f82fbe29b6f45253470c0f4079c2",
"from": {
"name": "Charlie Parker",
"email": "hello@binds.co"
},
"metadata": {
"campoPersonalizado1": "Charlie",
"campoPersonalizado2": "São Paulo",
"campoPersonalizado3": "5511000000000"
}
}", CURLOPT_HTTPHEADER => array( "Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/", "Cache-Control: no-cache", "Content-Type: application/json", "Postman-Token: adf678f0-7117-1106-3976-d4a342c0a3bf" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
Request Example:
require 'uri'
require 'net/http'

url = URI("https://app.binds.co/api/seeds")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/'
request["Cache-Control"] = 'no-cache'
request["Postman-Token"] = '024dbbf4-1059-80db-636c-761ebe063980'
request.body = "{  
"collector":"f82fbe29b6f45253470c0f4079c2",
"from":{
"name":"Charlie Parker",
"email":"hello@binds.co"
},
"metadata":{
"campoPersonalizado1":"Charlie",
"campoPersonalizado2":"São Paulo",
"campoPersonalizado3":"5511000000000"
}
}" response = http.request(request) puts response.read_body
Request Example:
import http.client

conn = http.client.HTTPConnection("app,binds,co")

payload = "{  
"collector":"f82fbe29b6f45253470c0f4079c2",
"from":{
"name":"Charlie Parker",
"email":"hello@binds.co"
},
"metadata":{
"campoPersonalizado1":"Charlie",
"campoPersonalizado2":"São Paulo",
"campoPersonalizado3":"5511000000000"
}
}" headers = { 'Content-Type': "application/json", 'Authorization': "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/", 'Cache-Control': "no-cache", 'Postman-Token': "48d20844-c016-32af-83f4-fb0eecf9ad67" } conn.request("POST", "api,seeds", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
Request Example:
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{  
"collector":"f82fbe29b6f45253470c0f4079c2",
"from":{
"name":"Charlie Parker",
"email":"hello@binds.co"
},
"metadata":{
"campoPersonalizado1":"Charlie",
"campoPersonalizado2":"São Paulo",
"campoPersonalizado3":"5511000000000"
}
}"); Request request = new Request.Builder() .url("https://app.binds.co/api/seeds") .post(body) .addHeader("Content-Type", "application/json") .addHeader("Authorization", "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/") .addHeader("Cache-Control", "no-cache") .addHeader("Postman-Token", "4482c09f-a925-e32e-6b92-5f10bf4c9845") .build(); Response response = client.newCall(request).execute();
Request Example:
package main

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

func main() {

    url := "https://app.binds.co/api/seeds"

    payload := strings.NewReader("{  
"collector":"f82fbe29b6f45253470c0f4079c2",
"from":{
"name":"Charlie Parker",
"email":"hello@binds.co"
},
"metadata":{
"campoPersonalizado1":"Charlie",
"campoPersonalizado2":"São Paulo",
"campoPersonalizado3":"5511000000000"
}
}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") req.Header.Add("Authorization", "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) }
Result Example:
{
    "__v": 0,
    "collector": "f82fbe29b6f45253470c0f4079c2",
    "metadata": {
        "campoPersonalizado3": "5511000000000",
        "campoPersonalizado2": "São Paulo",
        "campoPersonalizado1": "Charlie"
    },
    "account": "5a33fcd10f095724385c2a90",
    "updatedAt": "2018-06-18T21:52:02.808Z",
    "createdAt": "2018-06-18T21:52:02.807Z",
    "_id": "5b28298241a2052454fddacb",
    "products": [],
    "from": {
        "name": "Charlie Parker",
        "email": "hello@binds.co",
        "ip": "::ffff:200.162.228.91"
    },
    "processed": 0
}

Capturando Respostas

Por meio desta API é possível capturar as respostas e detalhes de uma pesquisa.

  • GET https://app.binds.co/api/surveys/{surveyId}/responses
Path Params Description
skip e limit paginação de resultados ex: skip=0&limit=1000
surveyId Código identificador da pesquisa. Exemplo: a05fa4cc286de86011a265b1b849

DICA: Você pode filtrar intervalos entre datas, passando os parâmetros startDate e endDate.

Exemplo: https://app.binds.co/api/surveys/a05fa4cc286de86011a265b1b849/responses/?startDate=2018-05-25T00:00:00.000Z&endDate=2018-05-25T23:59:00.000Z&skip=0&limit=1000

 
Headers Description
Authorization Basic [gerar hash base64 do token:chave]
Content-Type application/json;utf-8
Request Example:
                           GET /api/surveys/a05fa4cc286de86011a265b1b849/responses
                           Host: app.binds.co
                           Content-Type: application/json; charset=UTF-8
                           Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/
                        
Request Example:
                           curl -X GET \
                           https://app.binds.co/api/surveys/a05fa4cc286de86011a265b1b849/responses \
                           -H 'Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/' \
                           -H 'Content-Type: application/json; charset=UTF-8' \
                        
Request Example:
var http = require("https");

var options = {
  "method": "GET",
  "hostname": [
    "app",
    "binds",
    "co"
  ],
  "path": [
    "api",
    "surveys",
    "a05fa4cc286de86011a265b1b849",
    "responses"
  ],
  "headers": {
    "Content-Type": "application/json; charset=UTF-8",
    "Authorization": "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/",
    "Cache-Control": "no-cache",
    "Postman-Token": "0286d43b-d504-0a0c-b0d7-3c1d4c0869f0"
  }
};

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();
    
Request Example:
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://app.binds.co/api/surveys/a05fa4cc286de86011a265b1b849/responses",
  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(
    "Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/",
    "Cache-Control: no-cache",
    "Content-Type: application/json; charset=UTF-8",
    "Postman-Token: 4fb89b55-9111-97f8-a8fd-dd4cd3057db4"
  ),
));

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

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
Request Example:
require 'uri'
require 'net/http'

url = URI("https://app.binds.co/api/surveys/a05fa4cc286de86011a265b1b849/responses")

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

request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json; charset=UTF-8'
request["Authorization"] = 'Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/'
request["Cache-Control"] = 'no-cache'
request["Postman-Token"] = '4fe9010e-b44e-6508-0343-ae380fe83d1a'

response = http.request(request)
puts response.read_body
Request Example:
import http.client

conn = http.client.HTTPConnection("app,binds,co")

headers = {
    'Content-Type': "application/json; charset=UTF-8",
    'Authorization': "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/",
    'Cache-Control': "no-cache",
    'Postman-Token': "3f5d40c7-a3e8-b4ac-9367-f3d1806d8288"
    }

conn.request("GET", "api,surveys,a05fa4cc286de86011a265b1b849,responses", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
Request Example:
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://app.binds.co/api/surveys/a05fa4cc286de86011a265b1b849/responses")
  .get()
  .addHeader("Content-Type", "application/json; charset=UTF-8")
  .addHeader("Authorization", "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/")
  .build();

Response response = client.newCall(request).execute();
Request Example:
package main

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

func main() {

    url := "https://app.binds.co/api/surveys/a05fa4cc286de86011a265b1b849/responses"

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

    req.Header.Add("Content-Type", "application/json; charset=UTF-8")
    req.Header.Add("Authorization", "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/")

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

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

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

}
Result Example:
[
    {
        "sendingId": "5b28298374a1d20004821cc5",
        "sendingType": "email",
        "surveyId": "a05fa4cc286de86011a265b1b849",
        "surveyTitle": "Pesquisa de NPS",
        "contactName": "Charlie Parker",
        "contactEmail": "hello@binds.co",
        "sentAt": "2018-06-18T21:52:03.518Z",
        "openedAt": "2018-06-19T10:28:20.878Z",
        "clickedAt": "2018-06-18T22:20:12.652Z",
        "respondedAt": "2018-06-18T22:20:04.096Z",
        "doneAt": "2018-06-18T22:20:13.257Z",
        "responses": [
            {
                "responseId": "5b283014fd7ca90230d476a7",
                "createdAt": "2018-06-18T22:20:04.096Z",
                "questionId": "5a7456d86f866e2441b42abd",
                "questionTitle": "Pesquisa NPS",
                "question": "Em uma escala de 0 a 10, qual é a probabilidade de você nos indicar a um amigo ou familiar?",
                "response": "9"
            },
            {
                "responseId": "5b28301cfd7ca90230d477d3",
                "createdAt": "2018-06-18T22:20:12.183Z",
                "questionId": "5a7456d86f866e2441b42abc",
                "questionTitle": "Comentário",
                "question": "Gostaria de destacar algum aspecto de sua experiência conosco?",
                "response": "Excelente atendimento, estou muito satisfeito!"
            }
        ]
    }
]

Capturando Abordagens

  • GET https://app.binds.co/api/survey-sendings/?survey={surveyId}
Path Params Description
skip e limit paginação de resultados ex: skip=0&limit=1000
surveyId Código identificador da pesquisa. Exemplo: a05fa4cc286de86011a265b1b849

DICA: Você pode filtrar intervalos entre datas, passando os parâmetros start-date e end-date.

Exemplo: https://app.binds.co/api/survey-sendings/?survey=a05fa4cc286de86011a265b1b849?start-date=2018-05-25T00:00:00.000Z&end-date=2018-05-25T23:59:00.000Z&skip=0&limit=1000

 
Headers Description
Authorization Basic [gerar hash base64 do token:chave]
Content-Type application/json;utf-8
Request Example:
                           GET api/survey-sendings/?survey=a05fa4cc286de86011a265b1b849
                           Host: app.binds.co
                           Content-Type: application/json; charset=UTF-8
                           Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/
                        
Request Example:
                           curl -X GET \
                           https://app.binds.co/api/survey-sendings/?survey=a05fa4cc286de86011a265b1b849 \
                           -H 'Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/' \
                           -H 'Content-Type: application/json; charset=UTF-8' \
                        
Request Example:
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'GET',
  'hostname': 'app.binds.co',
  'path': '/api/survey-sendings/?survey=a05fa4cc286de86011a265b1b849',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/'
  },
  'maxRedirects': 20
};

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

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

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

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
Request Example:
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://app.binds.co/api/survey-sendings/?survey=a05fa4cc286de86011a265b1b849",
  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(
    "Authorization: Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/",
    "Cache-Control: no-cache",
    "Content-Type: application/json; charset=UTF-8",
    "Postman-Token: 4fb89b55-9111-97f8-a8fd-dd4cd3057db4"
  ),
));

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

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
Request Example:
require 'uri'
require 'net/http'

url = URI("https://app.binds.co/api/survey-sendings/?survey=a05fa4cc286de86011a265b1b849")

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

request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json; charset=UTF-8'
request["Authorization"] = 'Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/'
request["Cache-Control"] = 'no-cache'
request["Postman-Token"] = '4fe9010e-b44e-6508-0343-ae380fe83d1a'

response = http.request(request)
puts response.read_body
Request Example:
import http.client

conn = http.client.HTTPConnection("app,binds,co")

headers = {
    'Content-Type': "application/json; charset=UTF-8",
    'Authorization': "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/",
    'Cache-Control': "no-cache",
    'Postman-Token': "3f5d40c7-a3e8-b4ac-9367-f3d1806d8288"
    }

conn.request("GET", "api,survey-sendings,a05fa4cc286de86011a265b1b849", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
Request Example:
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://app.binds.co/api/survey-sendings/?survey=a05fa4cc286de86011a265b1b849")
  .get()
  .addHeader("Content-Type", "application/json; charset=UTF-8")
  .addHeader("Authorization", "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/")
  .build();

Response response = client.newCall(request).execute();
Request Example:
package main

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

func main() {

    url := "https://app.binds.co/api/survey-sendings/?survey=a05fa4cc286de86011a265b1b849"

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

    req.Header.Add("Content-Type", "application/json; charset=UTF-8")
    req.Header.Add("Authorization", "Basic YcOtIG5hbyBuw6k/Pz8/OmNvbW8gYXNzaW0/")

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

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

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

}
Result Example:
[{
    "_id": "5b28298374a1d20004821cc5",
    "__v": 0,
    "account": "5abcf306cea40f23c95O7039",
    "createdAt": "2018-06-18T22:20:04.096Z",
    "doneAt": "2018-06-18T22:20:04.096Z",
    "lastAnalysisAt": "2018-06-18T22:20:04.096Z",
    "lastEvent": {
        "smtpEvents": []
    },
    "respondedAt": "2018-06-18T22:20:04.096Z",
    "responses": [
        {
            "_id": "5b28301cfd7ca90230d477d3",
            "createdAt": "2018-06-18T22:20:04.096Z",
            "question": {
                "_id": "5b28301cfd7ca90230d477d3",
                "question": "Como você avalia a sua satisfação com o produto ou serviço oferecido pela nossa empresa?",
                "title": "CSAT",
                "type": "csat",
                "ui": "5emo"
            },
            "rating": 50
        },
        {
            "_id": "5b28301cfd7ca90230d477d3",
            "createdAt": "2018-06-18T22:20:04.096Z",
            "nps": 20,
            "question": {
                "_id": "5b28301cfd7ca90230d477d3",
                "question": "Qual a possibilidade em uma escala de 0 a 10 de você indicar os serviços ou produtos de nossa empresa para um amigo ou conhecido?",
                "title": "NPS",
                "type": "nps",
                "ui": "10num"
            }
        },
        {
            "_id": "5b28301cfd7ca90230d477d3",
            "artificialAnalysis": {
                "actions": "realizar pesquisas de satisfação e identificar as principais falhas do produto para realizar melhorias",
                "analyzedAt": "2018-06-18T22:20:04.096Z",
                "classification": "critica",
                "emotion": "frustracao",
                "insights": "O produto não atendeu às expectativas do cliente e algumas características não foram eficientes. Isso pode indicar a necessidade de.....",
                "product": "bard",
                "sentiment": "negativo"
            },
            "createdAt": "2018-06-18T22:20:04.096Z",
            "question": {
                "_id": "5b28301cfd7ca90230d477d3",
                "question": "Gostaria de deixar um comentário sobre sua experiência?",
                "title": "Comentário",
                "type": "text",
                "ui": "text"
            }
        }
    ],
    "seedData": {
        "createdAt": "2018-06-18T22:20:04.096Z",
        "from": {
            "email": "hello@binds.co",
            "ip": "::ffff:255.222.222.222",
            "name": "Charlie Parker",
            "phone": ""
        },
        "metadata": {
            "estado": "SE",
            "unidade": "Unidade SE"
        },
        "updatedAt": "2018-06-18T22:20:04.096Z"
    },
    "survey": {
        "_id": "a05fa4cc286de86011a265b1b849",
        "title": "Chat GPT",
        "isAnonymous": false
    },
    "tags": []
}
]