Skip to content

Listar recargas

GET
/charges

Para listar todas as cobranças utilize o método GET na rota /charges. Este método requer os seguintes parâmetros:

  • page: Página atual
  • filter: Filtro de busca

Este método retorna um objeto com os dados das cobranças, incluindo:

  • id: ID da cobrança
  • userId: ID do usuário
  • organizationId: ID da organização
  • gateway: Gateway de pagamento
  • type: Tipo de cobrança
  • paymentMethod: Método de pagamento
  • paymentId: ID do pagamento
  • paymentLink: Link do pagamento
  • invoiceId: ID da fatura
  • invoiceLink: Link da fatura
  • dueDate: Data de vencimento
  • amount: Valor da cobrança
  • taxAmount: Valor da taxa
  • totalAmount: Valor total
  • description: Descrição da cobrança
  • status: Status da cobrança
  • statusUpdatedAt: Data de atualização do status
  • createdAt: Data de criação
  • paidAt: Data de pagamento
  • refundedAt: Data de reembolso
  • hasErpInvoice: Faturado no ERP
  • metadata: Metadados

Importante:

  • Para acessar os dados das cobranças, é necessário informar o token de autenticação no cabeçalho da requisição.

Parâmetros

Parâmetros de Consulta

filter

Campos de definição de filtro, where, include, order, offset, e limit - devem ser uma
string JSON-encoded ({"where":{"something":"value"}}).
Veja https://loopback.io/doc/en/lb3/Querying-data.html#using-stringified-json-in-rest-queries
para maiores detalhes.

Tipostring
page*

Número da página.
No "meta" você encontra total de registros, total de páginas,
número de registros por página, página atual e próxima e/ou anterior se existirem

Tiponumber
Obrigatório
Exemplo1

Respostas

Request was successful
JSON
{
"data": [
{
"id": 123,
"userId": 420,
"organizationId": 210,
"gateway": "asaas",
"type": "CREDIT",
"paymentMethod": "BOLETO",
"paymentId": "987654321",
"paymentCode": "34191120888012123154189952540420799540000010000",
"paymentLink": "https://www.asaas.com/boleto/987654321",
"invoiceId": "456789123",
"invoiceLink": "https://www.asaas.com/invoice/456789123",
"dueDate": "2025-01-01T00:00:00Z",
"amount": 100,
"taxAmount": 0.1,
"totalAmount": 110,
"description": "Recarga de créditos",
"status": "PAID",
"statusUpdatedAt": "2025-01-01T00:00:00Z",
"createdAt": "2025-01-01T00:00:00Z",
"paidAt": "2025-01-01T00:00:00Z",
"refundedAt": "2025-01-01T00:00:00Z",
"receivedAt": "2025-01-01T00:00:00Z",
"hasErpInvoice": true,
"metadata": {
}
}
],
"meta": {
"totalItemCount": 0,
"totalPageCount": 0,
"itemsPerPage": 0,
"currentPage": 0,
"nextPage": 0,
"previousPage": 0
}
}

Exemplos

cURL
curl -X GET \
'https://api.api4com.com/api/v1/charges?page=1' \
 -H "Content-Type: application/json"
JavaScript
fetch('https://api.api4com.com/api/v1/charges?page=1', {headers:{'Content-Type':'application/json'}})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?php
$url = 'https://api.api4com.com/api/v1/charges';
$method = 'GET';
$headers = [
    'Content-Type' => 'application/json',
];
$query = http_build_query([
    'page' => '1',
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . '?' . $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
Python
import requests

url = 'https://api.api4com.com/api/v1/charges'
params = {
    'page': 1
}
headers = {
    'Content-Type': 'application/json'
}

response = requests.get(url, params=params, headers=headers)
print(response.json())

Released under the MIT License.