Python Örnekleri
Python ile KolayBi API'sini kullanma örnekleri.
🔐 Yetkilendirme
Access Token Alma
import requests
def get_access_token(api_key, channel):
url = 'https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/access_token'
headers = {
'Channel': channel,
'Content-Type': 'application/json'
}
data = {
'api_key': api_key
}
response = requests.post(url, headers=headers, json=data)
data = response.json()
return data['data']
👥 Cari Hesap İşlemleri
Müşteri Listeleme
def list_associates(access_token, channel):
url = 'https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/associates'
headers = {
'Authorization': f'Bearer {access_token}',
'Channel': channel
}
response = requests.get(url, headers=headers)
return response.json()
Müşteri Oluşturma
def create_associate(access_token, channel, associate_data):
url = 'https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/associates'
headers = {
'Authorization': f'Bearer {access_token}',
'Channel': channel,
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.post(url, headers=headers, data=associate_data)
return response.json()
📦 Ürün İşlemleri
Ürün Listeleme
def list_products(access_token, channel):
url = 'https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products'
headers = {
'Authorization': f'Bearer {access_token}',
'Channel': channel
}
response = requests.get(url, headers=headers)
return response.json()
🧾 Fatura İşlemleri
Fatura Listeleme
def list_invoices(access_token, channel):
url = 'https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices'
headers = {
'Authorization': f'Bearer {access_token}',
'Channel': channel
}
response = requests.get(url, headers=headers)
return response.json()