Introdução
Olá desenvolvedor! Você está na documentação da API da Central do Frete!
O objetivo dessa documentação é mostrar todos os métodos da nossa API e auxiliar você a realizar a integração com nosso sistema de uma maneira simples e divertida 😃
Nossa API foi construída na arquitetura REST sob o protocolo HTTP. No ambiente de produção, todas as requisições devem ser feitas no endpoint https://api.centraldofrete.com
Para começar a consumir a API, você vai precisar de um token de acesso. Clique aqui para saber como gerar um.
Ambiente de testes
Disponibilizamos um ambiente sandbox para você realizar seus testes. Assim você poderá realizar seus testes sem preocupação!
O endpoint é https://sandbox.centraldofrete.com
Postman
O Postman é um software que ajuda a consumir e testar API`s.
Você pode importar a especificação da nossa API no Postman utilizando a collection abaixo:
Saiba mais como importar no link https://learning.getpostman.com/docs/postman/collections/data_formats/#importing-postman-data
API Cotações
Listar cotações
Requires
authentication
Utilize esse recurso para listar as cotações realizadas.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->get("https://api.centraldofrete.com/v1/quotation", [
'headers' => [
'Authorization' => '{token}',
],
'query' => [
'page' => '1',
'limit' => '15',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET -G "https://api.centraldofrete.com/v1/quotation" \
-H "Authorization: {token}"
const url = new URL("https://api.centraldofrete.com/v1/quotation");
let params = {
"page": "1",
"limit": "15",
};
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
let headers = {
"Authorization": "{token}",
"Accept": "application/json",
"Content-Type": "application/json",
}
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"current_page": 1,
"data": [
{
"code": "CW2AS412",
"recipient": {
"name": "Joao da Silva",
"document": 27978654567,
"address": {
"zipcode": "31030080",
"street": "Rua A",
"district": "Centro",
"city": {
"name": "Belo Horizonte",
"state": "MG"
}
}
},
"status": "Escolha a transportadora",
"created_at": "2019-01-01 23:00:00"
}
],
"first_page_url": "https:\/\/api.centraldofrete.com\/v1\/quotation?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "https:\/\/api.centraldofrete.com\/v1\/quotation?page=1",
"next_page_url": "https:\/\/api.centraldofrete.com\/v1\/quotation?page=1",
"path": "https:\/\/api.centraldofrete.com\/v1\/quotation",
"per_page": 15,
"prev_page_url": null,
"to": 1,
"total": 1
}
Example response (500):
{
"error": "Needs Authorization header."
}
HTTP Request
GET v1/quotation
Query Parameters
| Parameter | Status | Description |
|---|---|---|
| page | optional | Página. |
| limit | optional | Quantidade por página. |
Criar cotação
Requires
authentication
Esse recurso permite você criar uma nova cotação de frete.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->post("https://api.centraldofrete.com/v1/quotation", [
'headers' => [
'Authorization' => '{token}',
'Content-Type' => 'application/json',
],
'json' => [
'from' => '09531190',
'to' => '30240440',
'cargo_types' => [13, 37],
'invoice_amount' => 201.92,
'volumes' => [
[
"quantity" => 1,
"width" => 10.2,
"height" => 8,
"length" => 4,
"weight" => 3
]
],
'recipient' => [
"document" => "22531311000110",
"name" => "Nome do Destinatário"
],
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X POST "https://api.centraldofrete.com/v1/quotation" \
-H "Authorization: {token}" \
-H "Content-Type: application/json" \
-d '{"from":"09531190","to":"30240440","cargo_types":[13, 37],"invoice_amount":201.92,"volumes":[{"quantity": 1, "width": 10.2, "height": 8, "length": 4, "weight": 3 }],"recipient":{"document": "22531311000110", "name": "Nome do Destinat\u00e1rio"}}'
const url = new URL("https://api.centraldofrete.com/v1/quotation");
let headers = {
"Authorization": "{token}",
"Content-Type": "application/json",
"Accept": "application/json",
}
let body = {
"from": "09531190",
"to": "30240440",
"cargo_types": [13, 37],
"invoice_amount": 201.92,
"volumes": [{"quantity": 1, "width": 10.2, "height": 8, "length": 4, "weight": 3 }],
"recipient": {"document": "22531311000110", "name": "Nome do Destinatario"}
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"code": "KXITLBYF",
"sender": {
"name": "Central do Frete",
"document": "22531311000110",
"address": {
"zipcode": "09531190",
"street": "Alameda Terracota",
"number": null,
"complement": null,
"district": "Cerâmica",
"city": {
"name": "São Caetano do Sul",
"state": "SP"
}
}
},
"recipient": {
"name": "João da Silva",
"document": "12312312300",
"address": {
"zipcode": "09521310",
"street": "Avenida Goias",
"number": null,
"complement": null,
"district": "Centro",
"city": {
"name": "São Caetano do Sul",
"state": "MG"
}
}
},
"volumes": [
{
"quantity": 1,
"width": 10.2,
"height": 8,
"length": 4,
"weight": 3
}
],
"weight": 3,
"cubed_weight": 0.1,
"freight_payer": null,
"invoice_amount": 201.92,
"invoice_access_key": null,
"invoice_number": null,
"prices": [
{
"id": 954888,
"shipping_carrier": "Correios",
"shipping_carrier_document": "34028316000103",
"price": 81.98,
"logo": "https://centraldofrete.com/logo.png",
"is_required_term": false,
"delivery_time": 3,
"service_type": "PAC",
"modal": "Rodoviário",
"dispatch": "Balcão",
"delivery": "Destinatário"
},
{
"id": 954889,
"shipping_carrier": "GroupTrans",
"shipping_carrier_document": "28441388000185",
"price": 85.98,
"logo": "https://centraldofrete.com/logo.png",
"is_required_term": false,
"delivery_time": 3,
"service_type": null,
"modal": "Rodoviário",
"dispatch": "Coleta",
"delivery": "Destinatário"
}
],
"expiration": "2019-06-22",
"created_at": "2019-06-17 19:22:41",
"is_recipient_countryside": false
}
HTTP Request
POST v1/quotation
Body Parameters
| Parameter | Type | Status | Description |
|---|---|---|---|
| from | string | required | O CEP de origem com 8 dígitos. |
| to | string | required | O CEP de destino com 8 dígitos. |
| cargo_types | array | optional | Informe um array de inteiros, com ID`s dos tipos de carga. Ver GET /cargo-types |
| invoice_amount | float | required | O valor da nota fiscal. |
| volumes | array | required | Informe um array com os volumes (cm) a serem transportados. |
| recipient | object | optional | Se desejar, informe o nome e o documento do destinatário. |
Detalhar cotação
Requires
authentication
Utilize esse recurso para detalhar uma cotação de frete.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->get("https://api.centraldofrete.com/v1/quotation/1", [
'headers' => [
'Authorization' => '{token}',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET -G "https://api.centraldofrete.com/v1/quotation/1" \
-H "Authorization: {token}"
const url = new URL("https://api.centraldofrete.com/v1/quotation/1");
let headers = {
"Authorization": "{token}",
"Accept": "application/json",
"Content-Type": "application/json",
}
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"code": "KXITLBYF",
"sender": {
"name": "Central do Frete",
"document": "22531311000110",
"address": {
"zipcode": "09531190",
"street": "Alameda Terracota",
"number": null,
"complement": null,
"district": "Cerâmica",
"city": {
"name": "São Caetano do Sul",
"state": "SP"
}
}
},
"recipient": {
"name": "João da Silva",
"document": "12312312300",
"address": {
"zipcode": "09521310",
"street": "Avenida Goias",
"number": null,
"complement": null,
"district": "Centro",
"city": {
"name": "São Caetano do Sul",
"state": "MG"
}
}
},
"volumes": [
{
"quantity": 1,
"width": 10.2,
"height": 8,
"length": 4,
"weight": 3
}
],
"weight": 3,
"cubed_weight": 0.1,
"freight_payer": null,
"invoice_amount": 201.92,
"invoice_access_key": null,
"invoice_number": null,
"prices": [
{
"id": 954888,
"shipping_carrier": "Correios",
"shipping_carrier_document": "34028316000103",
"price": 81.98,
"logo": "https://centraldofrete.com/logo.png",
"is_required_term": false,
"delivery_time": 3,
"service_type": "PAC",
"modal": "Rodoviário",
"dispatch": "Balcão",
"delivery": "Destinatário"
},
{
"id": 954889,
"shipping_carrier": "GroupTrans",
"shipping_carrier_document": "28441388000185",
"price": 85.98,
"logo": "https://centraldofrete.com/logo.png",
"is_required_term": false,
"delivery_time": 3,
"service_type": null,
"modal": "Rodoviário",
"dispatch": "Coleta",
"delivery": "Destinatário"
}
],
"expiration": "2019-06-22",
"created_at": "2019-06-17 19:22:41",
"is_recipient_countryside": false
}
Example response (500):
{
"error": "Needs Authorization header."
}
HTTP Request
GET v1/quotation/{code}
API Motivos de cancelamento de pedido
Listar motivos de cancelamento de pedido
Requires
authentication
Utilize esse recurso para listar os motivos de cancelamento de pedido disponíveis.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->get("https://api.centraldofrete.com/v1/cancel_reasons", [
'headers' => [
'Authorization' => '{token}',
],
'query' => [
'page' => '1',
'limit' => '15',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET -G "https://api.centraldofrete.com/v1/cancel_reasons" \
-H "Authorization: {token}"
const url = new URL("https://api.centraldofrete.com/v1/cancel_reasons");
let params = {
"page": "1",
"limit": "15",
};
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
let headers = {
"Authorization": "{token}",
"Accept": "application/json",
"Content-Type": "application/json",
}
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"current_page": 1,
"data": [
{
"id": 1,
"name": "Transportadora atrasou coleta"
},
{
"id": 2,
"name": "Contratei frete direto com a transportadora"
},
{
"id": 3,
"name": "Contratei frete com outra transportadora"
},
{
"id": 4,
"name": "Cotação cancelada, fiz outro pedido"
},
{
"id": 5,
"name": "Destinatário cancelou a compra"
},
{
"id": 6,
"name": "Destinatário não pagou o frete"
},
{
"id": 7,
"name": "Minha carga não está pronta"
},
{
"id": 8,
"name": "Transportadora escolhida não leva meu tipo de carga"
},
{
"id": 9,
"name": "Outros motivos"
}
],
"first_page_url": "http:\/\/localhost\/v1\/cancel_reasons?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http:\/\/localhost\/v1\/cancel_reasons?page=1",
"next_page_url": null,
"path": "http:\/\/localhost\/v1\/cancel_reasons",
"per_page": 15,
"prev_page_url": null,
"to": 9,
"total": 9
}
Example response (500):
{
"error": "Needs Authorization header."
}
HTTP Request
GET v1/cancel_reasons
Query Parameters
| Parameter | Status | Description |
|---|---|---|
| page | optional | Página. |
| limit | optional | Quantidade por página. |
API Pedidos
Listar pedidos
Requires
authentication
Utilize esse recurso para listar os pedidos gerados.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->get("https://api.centraldofrete.com/v1/order", [
'headers' => [
'Authorization' => '{token}',
],
'query' => [
'page' => '1',
'limit' => '15',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET -G "https://api.centraldofrete.com/v1/order" \
-H "Authorization: {token}"
const url = new URL("https://api.centraldofrete.com/v1/order");
let params = {
"page": "1",
"limit": "15",
};
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
let headers = {
"Authorization": "{token}",
"Accept": "application/json",
"Content-Type": "application/json",
}
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"current_page": 1,
"data": [
{
"code": "X6RY3MEQ",
"recipient": {
"name": "João da Silva",
"document": "12312312399",
"address": {
"zipcode": "09531190",
"street": "Alameda Terracota",
"district": "Cerâmica",
"city": {
"name": "São Caetano do Sul",
"state": "SC"
}
}
},
"status": "Aguardando Coleta",
"created_at": "2019-04-12 06:25:04"
}
],
"first_page_url": "https:\/\/api.centraldofrete.com\/v1\/order?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "https:\/\/api.centraldofrete.com\/v1\/order?page=1",
"next_page_url": "https:\/\/api.centraldofrete.com\/v1\/order?page=1",
"path": "https:\/\/api.centraldofrete.com\/v1\/order",
"per_page": 15,
"prev_page_url": null,
"to": 1,
"total": 1
}
Example response (500):
{
"error": "Needs Authorization header."
}
HTTP Request
GET v1/order
Query Parameters
| Parameter | Status | Description |
|---|---|---|
| page | optional | Página. |
| limit | optional | Quantidade por página. |
Gerar pedido
Requires
authentication
Esse recurso permite você gerar uma pedido a partir de uma cotação de frete.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->post("https://api.centraldofrete.com/v1/order", [
'headers' => [
'Authorization' => '{token}',
'Content-Type' => 'application/json',
],
'json' => [
'quotation_code' => 'KC09SAM2',
'freight_payer' => 'CIF',
'sender' => [
"address" => [
"number" => "1023",
"complement" => "ap204"
]
],
'recipient' => [
"document" => "12312312399",
"name" => "João da Silva",
"email" => "joao@teste.com",
"phone" => "011988880000",
"address" => [
"number" => "203",
"complement" => "ap102"
]
],
'price_id' => 40394,
'nfe_xml' => '<?xml version="1.0" encoding="UTF-8"?>',
'cce_issued' => 1,
'collect_here' => 1,
'schedule_collect' => '2019-08-01',
'sign_exemption_term' => 1,
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X POST "https://api.centraldofrete.com/v1/order" \
-H "Authorization: {token}" \
-H "Content-Type: application/json" \
-d '{"quotation_code":"KC09SAM2","freight_payer":"CIF","sender":{"address": {"number": "1023", "complement": "ap204"}},"recipient":{"document": "12312312399", "name": "Joao da Silva", "email": "joao@teste.com", "phone": "011988880000", "address": {"number": "203", "complement": "ap102"}},"price_id":40394,"nfe_xml":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>","cce_issued":true,"collect_here":true,"schedule_collect":"2019-08-01","sign_exemption_term":true}'
const url = new URL("https://api.centraldofrete.com/v1/order");
let headers = {
"Authorization": "{token}",
"Content-Type": "application/json",
"Accept": "application/json",
}
let body = {
"quotation_code": "KC09SAM2",
"freight_payer": "CIF",
"sender": {"address": {"number": "1023", "complement": "ap204"}},
"recipient": {"document": "12312312399", "name": "Joao da Silva", "email": "joao@teste.com", "phone": "011988880000", "address": {"number": "203", "complement": "ap102"}},
"price_id": 40394,
"nfe_xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"cce_issued": true,
"collect_here": true,
"schedule_collect": "2019-08-01",
"sign_exemption_term": true
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"code": "OVDXX230"
}
HTTP Request
POST v1/order
Body Parameters
| Parameter | Type | Status | Description |
|---|---|---|---|
| quotation_code | string | required | O código da cotação. |
| freight_payer | string | required | Informe CIF ou FOB. |
| sender | object | required | Informe os dados do remetente. |
| recipient | object | required | Informe os dados do destinatário. |
| price_id | integer | required | Informe o identificador do preço da cotação. Ver GET /quotation/{code}. |
| nfe_xml | string | required | Informe o XML da nota fiscal. |
| cce_issued | boolean | optional | Informe "1" caso tenha emitido uma Carta de Correção Eletronica. |
| collect_here | boolean | required | Informe "1" se a transportadora deverá coletar a carga e "0" se a carga será levada até a transportadora. |
| schedule_collect | string | optional | Informe somente caso queira agendar uma data a transportadora coletar a mercadoria. |
| sign_exemption_term | boolean | required | Informe "1" se a transportadora deverá assinar termo de isenção e "0" caso contrário. |
Detalhar pedido
Requires
authentication
Utilize esse recurso para detalhar um pedido gerado.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->get("https://api.centraldofrete.com/v1/order/1", [
'headers' => [
'Authorization' => '{token}',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET -G "https://api.centraldofrete.com/v1/order/1" \
-H "Authorization: {token}"
const url = new URL("https://api.centraldofrete.com/v1/order/1");
let headers = {
"Authorization": "{token}",
"Accept": "application/json",
"Content-Type": "application/json",
}
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"code": "KXITLBYF",
"status": "Em Trânsito",
"shipping_carrier": {
"name": "FEDEX"
},
"total": 70.48,
"delivery_expire_at": "2019-04-24",
"delivery_at": null,
"freight_payer": "CIF",
"sender": {
"name": "Central do Frete",
"document": "22531311000110",
"address": {
"zipcode": "09531190",
"street": "Alameda Terracota",
"number": null,
"complement": null,
"district": "Cerâmica",
"city": {
"name": "São Caetano do Sul",
"state": "SP"
}
}
},
"recipient": {
"name": "João da Silva",
"document": "12312312300",
"email": "joao@teste.com",
"phone": "11999998888",
"address": {
"zipcode": "09521310",
"street": "Avenida Goias",
"number": null,
"complement": null,
"district": "Centro",
"city": {
"name": "São Caetano do Sul",
"state": "MG"
}
}
},
"volumes": [
{
"quantity": 1,
"width": 12,
"height": 11,
"length": 238,
"weight": 9
}
],
"tracking": [
{
"datetime": "2019-04-10 00:00:00",
"event": "Processo de transporte iniciado",
"comment": null
}
],
"weight": 9,
"cubed_weight": 9.42,
"invoice_amount": 829.98,
"invoice_access_key": "35000000000002000124550010000237000000000000",
"invoice_number": "2000",
"created_at": "2019-04-10 06:28:58"
}
Example response (500):
{
"error": "Needs Authorization header."
}
HTTP Request
GET v1/order/{code}
Cancelar pedido
Requires
authentication
Esse recurso permite quer você cancele um pedido a partir do código do pedido.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->delete("https://api.centraldofrete.com/v1/order/1", [
'headers' => [
'Authorization' => '{token}',
'Content-Type' => 'application/json',
],
'json' => [
'reason' => '1',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X DELETE "https://api.centraldofrete.com/v1/order/1" \
-H "Authorization: {token}" \
-H "Content-Type: application/json" \
-d '{"reason":1}'
const url = new URL("https://api.centraldofrete.com/v1/order/1");
let headers = {
"Authorization": "{token}",
"Content-Type": "application/json",
"Accept": "application/json",
}
let body = {
"reason": 1
}
fetch(url, {
method: "DELETE",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"message": "O pedido foi cancelado com sucesso!"
}
HTTP Request
DELETE v1/order/{code}
Body Parameters
| Parameter | Type | Status | Description |
|---|---|---|---|
| reason | integer | required | Informe o identificador do motivo de cancelamento de pedido. |
Confirmar Coleta
Requires
authentication
Esse recurso permite quer você confirme se a coleta de um pedido foi realizada. Ao confirmar o status do
pedido é alterado para Coleta Efetuada. Caso, você não chame este endpoint, o pedido será atualizado
assim que o pedido entrar em trânsito.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->put("https://api.centraldofrete.com/v1/order/confirm_collect/1", [
'headers' => [
'Authorization' => '{token}',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X PUT "https://api.centraldofrete.com/v1/order/confirm_collect/1" \
-H "Authorization: {token}"
const url = new URL("https://api.centraldofrete.com/v1/order/confirm_collect/1");
let headers = {
"Authorization": "{token}",
"Accept": "application/json",
"Content-Type": "application/json",
}
fetch(url, {
method: "PUT",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"message": "A coleta foi confirmada com sucesso!"
}
HTTP Request
PUT v1/order/confirm_collect/{code}
API Produtos
Listar produtos
Requires
authentication
Utilize esse recurso para listar os produtos.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->get("https://api.centraldofrete.com/v1/products", [
'headers' => [
'Authorization' => '{token}',
],
'query' => [
'page' => '1',
'limit' => '15',
'like' => 'LAT-350',
'vendor' => 'MANUAL',
'orderBy' => 'TODAS_COLUNAS',
'orderDirection' => 'DESC',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET -G "https://api.centraldofrete.com/v1/products" \
-H "Authorization: {token}"
const url = new URL("https://api.centraldofrete.com/v1/products");
let params = {
"page": "1",
"limit": "15",
"like": "LAT-350",
"vendor": "MANUAL",
"orderBy": "TODAS_COLUNAS",
"orderDirection": "DESC",
};
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
let headers = {
"Authorization": "{token}",
"Accept": "application/json",
"Content-Type": "application/json",
}
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"current_page": 1,
"data": [
{
"id": 6,
"sku": "bc12312",
"description": "Produto com descricao um pouco mais longa",
"price": 8.5,
"weight": 0.3,
"height": 3,
"width": 120.3,
"length": 10,
"cargo_type": {
"id": 12,
"name": "Anzóis e acessórios",
"required_term": false,
"parent": {
"id": 6,
"name": "Acessórios de Náutica \/ Pesca",
"required_term": true,
"parent": null
}
},
"vendor": "MANUAL"
},
{
"id": 7,
"sku": "dsa2131",
"description": "curta",
"price": 3.2,
"weight": 0.4,
"height": 4,
"width": 15,
"length": 10,
"cargo_type": {
"id": 416,
"name": "Bolsa Térmica",
"required_term": false,
"parent": {
"id": 6,
"name": "Acessórios de Náutica \/ Pesca",
"required_term": true,
"parent": null
}
},
"vendor": "UPLOAD"
}
],
"first_page_url": "http:\/\/localhost\/v1\/products?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http:\/\/localhost\/v1\/products?page=1",
"next_page_url": null,
"path": "http:\/\/localhost\/v1\/products",
"per_page": 15,
"prev_page_url": null,
"to": 2,
"total": 2
}
Example response (500):
{
"error": "Needs Authorization header."
}
HTTP Request
GET v1/products
Query Parameters
| Parameter | Status | Description |
|---|---|---|
| page | optional | Página. |
| limit | optional | Quantidade por página. |
| like | optional | Informe o termo que será buscado nos SKUs e descrições dos produto. |
| vendor | optional | Informe o tipo de fornecimento dos produtos no sistema. Valores permitidos: ['MANUAL', 'UPLOAD', 'API']. |
| orderBy | optional | Informe o tipo de ordenação dos produtos. Valores permitidos: ['TODAS_COLUNAS']. |
| orderDirection | optional | Informe a ordem de ordenação dos produtos. Valores permitidos: ['ASC', 'DESC']. |
Criar produto
Requires
authentication
Esse recurso permite você criar um novo produto.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->post("https://api.centraldofrete.com/v1/products", [
'headers' => [
'Authorization' => '{token}',
'Content-Type' => 'application/json',
],
'json' => [
'description' => 'Stock Keeping Units',
'sku' => 'CC-LAT-350',
'price' => '100',
'weight' => '3.5',
'height' => '0.75',
'width' => '1.25',
'length' => '1',
'cargo_type_id' => '1',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X POST "https://api.centraldofrete.com/v1/products" \
-H "Authorization: {token}" \
-H "Content-Type: application/json" \
-d '{"description":"Stock Keeping Units","sku":"CC-LAT-350","price":100,"weight":3.5,"height":0.75,"width":1.25,"length":1,"cargo_type_id":1}'
const url = new URL("https://api.centraldofrete.com/v1/products");
let headers = {
"Authorization": "{token}",
"Content-Type": "application/json",
"Accept": "application/json",
}
let body = {
"description": "Stock Keeping Units",
"sku": "CC-LAT-350",
"price": 100,
"weight": 3.5,
"height": 0.75,
"width": 1.25,
"length": 1,
"cargo_type_id": 1
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"id": 12,
"sku": "bc12312",
"description": "Produto com descricao um pouco mais longa",
"price": 8.5,
"weight": 0.3,
"height": 3,
"width": 120.3,
"length": 10,
"cargo_type": {
"id": 12,
"name": "Anzóis e acessórios",
"required_term": false,
"parent": {
"id": 6,
"name": "Acessórios de Náutica \/ Pesca",
"required_term": true,
"parent": null
}
},
"vendor": "MANUAL"
}
HTTP Request
POST v1/products
Body Parameters
| Parameter | Type | Status | Description |
|---|---|---|---|
| description | string | required | Informe a descrição do produto. |
| sku | string | required | Informe o SKU do produto. |
| price | float | required | Informe o preço do produto. |
| weight | float | optional | Informe o peso do produto. |
| height | float | required | Informe a altura do produto. |
| width | float | required | Informe a largura do produto. |
| length | float | required | Informe o comprimento do produto. |
| cargo_type_id | integer | optional | Informe o identificador do tipo de carga do produto. |
Detalhar produto
Requires
authentication
Utilize esse recurso para detalhar um produto.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->get("https://api.centraldofrete.com/v1/products/1", [
'headers' => [
'Authorization' => '{token}',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET -G "https://api.centraldofrete.com/v1/products/1" \
-H "Authorization: {token}"
const url = new URL("https://api.centraldofrete.com/v1/products/1");
let headers = {
"Authorization": "{token}",
"Accept": "application/json",
"Content-Type": "application/json",
}
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"id": 6,
"sku": "bc12312",
"description": "Produto com descricao um pouco mais longa",
"price": 8.5,
"weight": 0.3,
"height": 3,
"width": 120.3,
"length": 10,
"cargo_type": {
"id": 12,
"name": "Anzóis e acessórios",
"required_term": false,
"parent": {
"id": 6,
"name": "Acessórios de Náutica \/ Pesca",
"required_term": true,
"parent": null
}
},
"vendor": "UPLOAD"
}
Example response (500):
{
"error": "Needs Authorization header."
}
HTTP Request
GET v1/products/{id}
Apagar produto
Requires
authentication
Utilize esse recurso para apagar um produto.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->delete("https://api.centraldofrete.com/v1/products/1", [
'headers' => [
'Authorization' => '{token}',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X DELETE "https://api.centraldofrete.com/v1/products/1" \
-H "Authorization: {token}"
const url = new URL("https://api.centraldofrete.com/v1/products/1");
let headers = {
"Authorization": "{token}",
"Accept": "application/json",
"Content-Type": "application/json",
}
fetch(url, {
method: "DELETE",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"message": "O produto foi apagado com sucesso!"
}
HTTP Request
DELETE v1/products/{id}
API Tipos de Carga
Listar tipos de carga
Requires
authentication
Utilize esse recurso para listar os tipos de carga disponíveis.
Example request:
$client = new \GuzzleHttp\Client();
$response = $client->get("https://api.centraldofrete.com/v1/cargo-type", [
'headers' => [
'Authorization' => '{token}',
],
]);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl -X GET -G "https://api.centraldofrete.com/v1/cargo-type" \
-H "Authorization: {token}"
const url = new URL("https://api.centraldofrete.com/v1/cargo-type");
let headers = {
"Authorization": "{token}",
"Accept": "application/json",
"Content-Type": "application/json",
}
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
[
{
"id": 570,
"name": "Abrigos de aço carbono",
"cargo_type_id": 391
},
{
"id": 572,
"name": "Abrigos de fibra de vidro",
"cargo_type_id": 391
},
{
"id": 571,
"name": "Abrigos de inox",
"cargo_type_id": 391
}
]
Example response (500):
{
"error": "Needs Authorization header."
}
HTTP Request
GET v1/cargo-type