Fatura Listeleme
Şirketinize ait faturaları listeleme ve filtreleme.
Endpoint
GET /kolaybi/v1/invoices
Parametreler
Parametre | Tip | Açıklama |
---|---|---|
type | InvoiceType | Fatura türü ile filtreleme |
Fatura Türleri
Tür | Açıklama |
---|---|
sale_invoice | Satış faturası |
sale_return_invoice | Satış iade faturası |
purchase_invoice | Alış faturası |
purchase_return_invoice | Alış iade faturası |
self_employment_receipt | Serbest meslek makbuzu |
Örnekler
- cURL
- JavaScript
- PHP
- Python
- C#
# Tüm faturalar
curl -X GET "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL"
# Sadece satış faturaları
curl -X GET "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices?type=sale_invoice" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL"
async function listInvoices(filters = {}) {
const params = new URLSearchParams(filters);
const response = await fetch(
`https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices?${params}`,
{
headers: {
Authorization: `Bearer ${accessToken}`,
Channel: channel,
},
}
);
return await response.json();
}
// Kullanım
const saleInvoices = await listInvoices({ type: "sale_invoice" });
const allInvoices = await listInvoices();
function listInvoices($filters = []) {
$url = 'https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices';
if (!empty($filters)) {
$url .= '?' . http_build_query($filters);
}
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $accessToken,
'Channel: ' . $channel
],
CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Kullanım
$saleInvoices = listInvoices(['type' => 'sale_invoice']);
import requests
def list_invoices(filters=None):
if filters is None:
filters = {}
url = "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices"
headers = {
"Authorization": f"Bearer {access_token}",
"Channel": channel
}
response = requests.get(url, headers=headers, params=filters)
return response.json()
# Kullanım
sale_invoices = list_invoices({"type": "sale_invoice"})
all_invoices = list_invoices()
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;
async Task<dynamic> ListInvoicesAsync(Dictionary<string, string> filters = null)
{
using var client = new HttpClient();
var url = "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices";
if (filters != null && filters.Count > 0)
{
var query = await new FormUrlEncodedContent(filters).ReadAsStringAsync();
url += "?" + query;
}
var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
request.Headers.Add("Channel", channel);
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<dynamic>(content);
}
// Kullanım
var saleInvoices = await ListInvoicesAsync(new Dictionary<string, string> { { "type", "sale_invoice" } });
Yanıt Formatı
{
"success": true,
"data": [
{
"id": 1,
"serial_no": "FAT-2024-001",
"order_date": "2024-01-15",
"due_date": "2024-02-15",
"total_amount": 240.0,
"currency": "TRY",
"status": "ready_to_send",
"type": "sale_invoice",
"contact": {
"id": 1,
"name": "Ahmet",
"surname": "Yılmaz"
}
}
],
"pagination": {
"current_page": 1,
"per_page": 20,
"total": 1
}
}
Fatura Durumları
Durum | Açıklama |
---|---|
draft | Taslak |
ready_to_send | Gönderime hazır |
sent | GİB'e gönderildi |
approved | Onaylandı |
rejected | Reddedildi |
cancelled | İptal edildi |