Otomovena Developer Platform

Kod Örnekleri

Şu an için resmi bir paket/kütüphane (npm/composer/pip) yayınlanmış değildir — API tek bir Authorization header'ı gerektiren düz REST/JSON olduğu için buna genelde ihtiyaç kalmaz. Aşağıda her dil için, projenize direkt kopyalayabileceğiniz küçük bir sarmalayıcı (wrapper) fonksiyon bulacaksınız.

PHP

<?php

class OtomovenaClient
{
    public function __construct(private string $apiKey, private string $baseUrl = 'https://otomovena.com/api/v1/') {}

    public function get(string $path, array $query = []): array
    {
        $url = $this->baseUrl . ltrim($path, '/');
        if ($query) {
            $url .= '?' . http_build_query($query);
        }
        $ch = curl_init($url);
        curl_setopt_array($ch, [
            CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $this->apiKey],
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => 15,
        ]);
        $response = json_decode(curl_exec($ch), true);
        if (($response['success'] ?? false) !== true) {
            throw new RuntimeException($response['error']['message'] ?? 'Otomovena API hatası');
        }
        return $response;
    }
}

$client = new OtomovenaClient('otv_live_xxxxx...');
$vehicles = $client->get('vehicles.php', ['status' => 'Stokta', 'limit' => 50])['data'];

Node.js / JavaScript

class OtomovenaClient {
  constructor(apiKey, baseUrl = 'https://otomovena.com/api/v1/') {
    this.apiKey = apiKey;
    this.baseUrl = baseUrl;
  }

  async get(path, query = {}) {
    const url = new URL(path, this.baseUrl);
    Object.entries(query).forEach(([k, v]) => url.searchParams.set(k, v));
    const res = await fetch(url, { headers: { Authorization: `Bearer ${this.apiKey}` } });
    const body = await res.json();
    if (!body.success) throw new Error(body.error?.message || 'Otomovena API hatası');
    return body;
  }
}

const client = new OtomovenaClient('otv_live_xxxxx...');
const { data: vehicles } = await client.get('vehicles.php', { status: 'Stokta', limit: 50 });

Python

import requests


class OtomovenaClient:
    def __init__(self, api_key, base_url="https://otomovena.com/api/v1/"):
        self.api_key = api_key
        self.base_url = base_url

    def get(self, path, params=None):
        res = requests.get(
            self.base_url + path.lstrip("/"),
            params=params or {},
            headers={"Authorization": f"Bearer {self.api_key}"},
            timeout=15,
        )
        body = res.json()
        if not body.get("success"):
            raise RuntimeError(body.get("error", {}).get("message", "Otomovena API hatası"))
        return body


client = OtomovenaClient("otv_live_xxxxx...")
vehicles = client.get("vehicles.php", {"status": "Stokta", "limit": 50})["data"]

n8n / Zapier gibi Otomasyon Araçları

Resmi bir n8n node'u henüz yoktur; genel amaçlı HTTP Request düğümünü kullanabilirsiniz: Method GET, URL https://otomovena.com/api/v1/vehicles.php, Header Authorization: Bearer <key>. Otomovena'nın kendi n8n altyapısını kullanan galeriler için, webhook olaylarını doğrudan bir n8n Webhook düğümüne yönlendirmek de mümkündür — bkz. Webhook'lar.