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.
A autenticacação é feita por Basic Auth, o seus token e chave serão usados para acessar o endpoint.
https://app.binds.co/api/
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. :)
Por meio desta API é possível consultar as informações e detalhes de uma lista de pesquisas criadas.
Headers | Description |
---|---|
Authorization
|
Basic [gerar hash base64 do token:chave] |
Content-Type
|
application/json;utf-8 |
GET /api/surveys Host: app.binds.co Content-Type: application/json Authorization: Basic xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW
curl -X GET \ https://app.binds.co/api/surveys \ -H 'Authorization: Basic xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW' \ -H 'Content-Type: application/json' \
var http = require("https"); var options = { "method": "GET", "hostname": [ "app", "binds", "co" ], "path": [ "api", "surveys" ], "headers": { "Content-Type": "application/json", "Authorization": "Basic xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW", "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();
<?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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW", "Content-Type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
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"] = 'xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW' response = http.request(request) puts response.read_body
import http.client conn = http.client.HTTPConnection("app,binds,co") headers = { 'Content-Type': "application/json", 'Authorization': "xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW" } conn.request("GET", "api,surveys", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW") .build(); Response response = client.newCall(request).execute();
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) }
[ { "_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" } ]
Por meio desta API é possível obter "collectors" que são as chaves para envio de pesquisas.
Headers | Description |
---|---|
Authorization
|
Basic [gerar hash base64 do token:chave] |
Content-Type
|
application/json;utf-8 |
GET /api/collectors Host: app.binds.co Content-Type: application/json Authorization: Basic xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW
curl -X GET \ https://app.binds.co/api/collectors \ -H 'Authorization: Basic xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW' \ -H 'Content-Type: application/json' \
var http = require("https"); var options = { "method": "GET", "hostname": [ "app", "binds", "co" ], "path": [ "api", "collectors" ], "headers": { "Content-Type": "application/json", "Authorization": "Basic xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW", "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); });
<?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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW", "Content-Type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
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"] = 'xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW' response = http.request(request) puts response.read_body
import http.client conn = http.client.HTTPConnection("app,binds,co") headers = { 'Content-Type': "application/json", 'Authorization': "xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW" } conn.request("GET", "api,collectors", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW") .build(); Response response = client.newCall(request).execute();
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) }
[ { "_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" } ]
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.
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 |
POST /api/seeds Host: app.binds.co Content-Type: application/json Authorization: Basic xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW { "collector": "f82fbe29b6f45253470c0f4079c2", "from": { "name": "Charlie Parker", "email": "hello@binds.co" }, "metadata": { "campoPersonalizado1": "Charlie", "campoPersonalizado2": "São Paulo", "campoPersonalizado3": "5511000000000" } }
#! /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"
var http = require("https"); var options = { "method": "POST", "hostname": [ "app", "binds", "co" ], "path": [ "api", "seeds" ], "headers": { "Content-Type": "application/json", "Authorization": "Basic xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW", "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();
<?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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW", "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; }
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW' 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
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW", '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"))
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW") .addHeader("Cache-Control", "no-cache") .addHeader("Postman-Token", "4482c09f-a925-e32e-6b92-5f10bf4c9845") .build(); Response response = client.newCall(request).execute();
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) }
{ "__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 }
Por meio desta API é possível capturar as respostas e detalhes de uma pesquisa.
Path Params | Description |
---|---|
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
Headers | Description |
---|---|
Authorization
|
Basic [gerar hash base64 do token:chave] |
Content-Type
|
application/json;utf-8 |
Range
|
paginação de resultados ex: items=0-9 |
GET /api/surveys/a05fa4cc286de86011a265b1b849/responses Host: app.binds.co Content-Type: application/json; charset=UTF-8 Authorization: Basic xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW
curl -X GET \ https://app.binds.co/api/surveys/a05fa4cc286de86011a265b1b849/responses \ -H 'Authorization: Basic xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW' \ -H 'Content-Type: application/json; charset=UTF-8' \
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW", "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();
<?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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW", "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; }
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW' request["Cache-Control"] = 'no-cache' request["Postman-Token"] = '4fe9010e-b44e-6508-0343-ae380fe83d1a' response = http.request(request) puts response.read_body
import http.client conn = http.client.HTTPConnection("app,binds,co") headers = { 'Content-Type': "application/json; charset=UTF-8", 'Authorization': "Basic xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW", '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"))
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW") .build(); Response response = client.newCall(request).execute();
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 xZ5QYTJAXu5M5msYJZ0eYWluW0HYazg6rZW3HX94J=ZZW") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) }
[ { "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!" } ] } ]