# API hızlı bir başlangıç

Google Search ve YouTube API'leri doğrudan HTTP üzerinde arayın. Bir istek gönderin ve JSON yanıtını okuyun; SDK gerekli değildir.

Canonical referans: https://flashdata.dev/tr/docs/guides/http-quickstart
İnceleme: 2026-11-04 Tarafından FlashData

<a id="application"></a>

## İlk HTTP isteğinizi yapın

API anahtarını ayarlayın, bir Google arama gönderin ve kurtarılan cevabı kontrol edin.


<a id="prepare"></a>

### Kimlik Doğrulama

Bir hesap oluşturun, e-postanızı doğrulayın ve Google Search izni ile anahtar oluşturun. Mevcut bir anahtarı yeniden kullanabilirsiniz.

Terminalde çalıştırın ve anahtarı gizli giriş istemine yapıştırın. FLASHDATA_API_KEY zaten ayarlıysa bu adımı atlayın.

#### Bash

##### Anahtarınızı ayarlayın

```bash
# Bash: paste the key into a hidden prompt, not into this command.
read -r -s -p "FlashData API key: " FLASHDATA_API_KEY
printf '\n'
export FLASHDATA_API_KEY
```


#### PowerShell 7

##### Anahtarınızı ayarlayın

```powershell
# PowerShell 7: paste the key into a hidden prompt.
$flashdataSecureKey = Read-Host "FlashData API key" -AsSecureString
$env:FLASHDATA_API_KEY = [System.Net.NetworkCredential]::new("", $flashdataSecureKey).Password
Remove-Variable flashdataSecureKey
```


- [Hesap oluştur](https://flashdata.dev/signup)
- [API Keys sayfasını aç](https://flashdata.dev/app/api-keys)
- [Agent kimlik doğrulama](https://flashdata.dev/auth.md)

<a id="curl"></a>

### Arama çalıştırın

Bir müşteri seçin ve aynı terminalde örneği çalıştırın. Her biri bir tane gönderir POST İstek istemek https://data.flashdata.dev/v1/queries/realtime Baskılar ve baskılar JSON. Kimlikle X-API-KeyGönder; JSON with with with ile Content-Type: application/json.

#### cURL

cURL 7.76+ · Bash Onda Linux, macOS veya veya veya Git Bash. Paste ve koşmak.

##### Arama · Bash / cURL

```bash
curl --fail-with-body --silent --show-error --max-time 70 \
  --request POST https://data.flashdata.dev/v1/queries/realtime \
  --header "X-API-Key: $FLASHDATA_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "source": "google_search",
  "query": "battery recycling research",
  "params": {
    "num": 5
  }
}'
```


#### PowerShell 7

PowerShell 7+ · Bu yerli PowerShell komutunu yapıştırın.

##### Arama · PowerShell

```powershell
$flashdataRequest = '{"source":"google_search","query":"battery recycling research","params":{"num":5}}'
$flashdataSearch = @{
  Uri = 'https://data.flashdata.dev/v1/queries/realtime'
  Method = 'Post'
  Headers = @{ 'X-API-Key' = $env:FLASHDATA_API_KEY }
  ContentType = 'application/json'
  Body = $flashdataRequest
  TimeoutSec = 70
  MaximumRedirection = 0
  SkipHttpErrorCheck = $true
  ErrorAction = 'Stop'
}
$flashdataResponse = Invoke-WebRequest @flashdataSearch
$flashdataResponse.Content
if ($flashdataResponse.StatusCode -ge 400) {
  throw "HTTP $($flashdataResponse.StatusCode). Inspect the response above before retrying."
}
```


#### JavaScript

Node.js 22+ · search.mjs olarak tasarruf edin ve yerel olarak veya sunucunuzda çalıştırın. Yapın - getir; npm yükleme.

##### search.mjs

```javascript
const key = process.env.FLASHDATA_API_KEY;
if (!key) throw new Error("Set FLASHDATA_API_KEY in this terminal.");

let response;
try {
  response = await fetch("https://data.flashdata.dev/v1/queries/realtime", {
    method: "POST",
    redirect: "error",
    signal: AbortSignal.timeout(70000),
    headers: { "X-API-Key": key, "Content-Type": "application/json" },
    body: JSON.stringify({"source":"google_search","query":"battery recycling research","params":{"num":5}}),
  });
} catch {
  throw new Error("Request did not complete. Check History before resubmitting.");
}

const body = await response.text();
console.log(body); // Print the full response before checking its status.
if (!response.ok) {
  const retryAfter = response.headers.get("retry-after");
  throw new Error("HTTP " + response.status + ". See the response above." +
    (retryAfter ? " Retry-After: " + retryAfter : ""));
}
let result;
try {
  result = JSON.parse(body);
} catch {
  throw new Error("Expected JSON. Inspect the response above and the API URL.");
}
if (!result || result.error === true || result.status !== "done" || !Array.isArray(result.results)) {
  throw new Error("Query did not succeed. Inspect status and error in the response above.");
}
```

##### Run · JavaScript

```bash
node search.mjs
```


#### Python

Python 3.10+ · search.py olarak tasarruf edin. Sadece standart kütüphaneyi kullanın; pip install. python3 veya py -3 eğer bu sizin Python komutunuzsa.

##### search.py

```python
import json
import os
import urllib.error
import urllib.request

key = os.environ.get("FLASHDATA_API_KEY")
if not key:
    raise SystemExit("Set FLASHDATA_API_KEY in this terminal.")

# Do not forward the API key to a redirect destination.
class NoRedirect(urllib.request.HTTPRedirectHandler):
    def redirect_request(self, req, fp, code, msg, headers, newurl):
        return None

request = urllib.request.Request(
    "https://data.flashdata.dev/v1/queries/realtime",
    data=json.dumps({"source":"google_search","query":"battery recycling research","params":{"num":5}}).encode("utf-8"),
    headers={"X-API-Key": key, "Content-Type": "application/json"},
    method="POST",
)
try:
    with urllib.request.build_opener(NoRedirect).open(request, timeout=70) as response:
        body = response.read().decode("utf-8")
except urllib.error.HTTPError as error:
    print(error.read().decode("utf-8", errors="replace"))
    retry_after = error.headers.get("Retry-After")
    raise SystemExit("HTTP " + str(error.code) + ". See the response above." +
                     (" Retry-After: " + retry_after if retry_after else ""))
except (urllib.error.URLError, TimeoutError):
    raise SystemExit("Request did not complete. Check History before resubmitting.")

print(body)  # The run command saves this full response to result.json.
try:
    result = json.loads(body)
except json.JSONDecodeError:
    raise SystemExit("Expected JSON. Inspect the response above and the API URL.")
if (not isinstance(result, dict) or result.get("error") is True
        or result.get("status") != "done" or not isinstance(result.get("results"), list)):
    raise SystemExit("Query did not succeed. Inspect status and error in the response above.")
```

##### Run · Python

```bash
python -X utf8 search.py
```



<a id="result"></a>

### Sonucu kontrol edin

HTTP başarısını ve status: done'yu doğrulayın. Kaynak başlıklarını, bağlantıları ve parçaları okuyun results[].organic, ve sorumlu usage.credits.

status: done ile boş bir sonuç veya organik bir liste geçerli bir boş sonuçtur.

| Field | Bunu için kullanın |
| --- | --- |
| status | "done", sorgunun başarıyla tamamlandığını onaylar. |
| results[0].organic[] | Arama sonuçları. Bu sonuçları indekslemeden önce boş değildir. |
| title / link / snippet | Kaynak adı, URL ve alıntı. |
| usage.credits | Bu sorgu için kanunen krediler ücretlendi. |

#### Örnek yanıt

```json
{
  "source": "google_search",
  "status": "done",
  "results": [
    {
      "organic": [
        {
          "title": "Battery recycling research",
          "link": "https://example.org/recycling",
          "snippet": "An example search excerpt."
        }
      ]
    }
  ],
  "usage": {
    "credits": 0.02
  }
}
```


<a id="diagnostics"></a>

## Debugging için bir cevap Kaydet

Bir sonraki amaçlanan isteği yakalamak için, yukarıdaki cURL komutlarına bu seçenekleri ekleyin. Başarısız bir istek yeniden denemeye karar vermeden önce dosyaları ihmal edin.

### cURL

```bash
--dump-header response-headers.txt --output result.json
```

- [HTTP hataları ve kurtarma](https://flashdata.dev/tr/docs/errors/reference.md)

<a id="check"></a>

## Giriş ve kredi kontrol

Bu GET, sorgu kredilerini kullanmadan kimlik, denge ve fiyat okumasını talep ediyor. HTTP 200'u bekleyin ve ücretli iş göndermeden önce alanları kontrol edin.

Hesap okur: https://api.flashdata.dev/v2. Data requests: https://data.flashdata.dev/v1. Her ikisi de X-API-Key kullanıyor; JSON POST talepleri de Content-Type: application/json.

| Read Oku | Yanıtda ne kontrol edilir |
| --- | --- |
| identity | Amaçlananı doğrulayın accountId, access: "ready", içeren kapsamı "google_search"Ve herhangi bir şey expiresAt. accountType Is is is is Is is Is Is is'dir. "owned" Bir sahibi anahtar veya "temporary" Bir deneme anahtarı için. |
| balance | availableCredits'u okuyun. Bu hesap için tüm anahtarlar aynı dengeyi kullanır. |
| pricing | prices[0] için doğru kaynak google_search ve mevcut true. estimatedCredits için requestCount: 1 ile availableCredits. Fiyatlar ve dengeler, teslim almadan önce değişebilir. |

### Bash / cURL

#### Ücretsiz kontroller · Bash

```bash
(
for endpoint in 'identity' 'balance' 'pricing?source=google_search&request_count=1'; do
  printf '\n%s\n' "$endpoint"
  curl --fail-with-body --silent --show-error --max-time 20 \
    --header "X-API-Key: $FLASHDATA_API_KEY" \
    --write-out '\nHTTP %{http_code}\n' \
    "https://api.flashdata.dev/v2/api-access/$endpoint" || exit
done
)
```


### PowerShell 7

#### Ücretsiz kontroller · PowerShell

```powershell
try {
  foreach ($flashdataPath in @('identity', 'balance', 'pricing?source=google_search&request_count=1')) {
    Write-Host $flashdataPath
    $flashdataRead = @{
      Uri = "https://api.flashdata.dev/v2/api-access/$flashdataPath"
      Headers = @{ 'X-API-Key' = $env:FLASHDATA_API_KEY }
      TimeoutSec = 20
      MaximumRedirection = 0
      ErrorAction = 'Stop'
    }
    Invoke-RestMethod @flashdataRead | ConvertTo-Json -Depth 20
  }
} catch {
  throw
}
```



<a id="next"></a>

## Sonraki adımlar

- [Google Search en iyi uygulamalar](https://flashdata.dev/tr/docs/guides/google-search-guide/reference.md)
- [YouTube Data](https://flashdata.dev/tr/docs/guides/youtube-data-guide/reference.md)
- [YouTube Download](https://flashdata.dev/tr/docs/guides/youtube-download-guide/reference.md)
- [API başvurusu](https://flashdata.dev/tr/docs/api-reference/reference.md)
- [OpenAPI spesifikasyonu](https://flashdata.dev/docs/openapi.json)

<a id="troubleshooting"></a>

## Bir adım başarısız olursa

Terminalinizde basılan cevabı okuyun. JavaScript ve Python raporu HTTP hataları ve Retry-After'yu stderr'ye rapor edin. Her örnek bir kez gönderir; otomatik olarak yeniden denemez.

| Symptom | Sonraki eylem |
| --- | --- |
| Komut eksik veya desteklenmemiş bir seçenek | Seçilmiş örnekteki gerekli sürümü kontrol edin. PowerShell 7'dan ziyade Windows PowerShell 5.1 veya Bash'yu cURL7.76+ ile kullanın. JavaScript'un 22+'ya ihtiyacı yok; Python'un 3.10+'ya ihtiyacı var. Kayıp runtime'yı resmi indirme sayfasından yükleyin, terminali yeniden açın. |
| Eksik anahtar / 401 | Bu süreçte FLASHDATA_API_KEY'u ayarlayın ve tekrar kimlik kontrol edin. Tüm aktif API anahtarı, bir Bearer ön ek olmadan. Eğer sona erseydi veya iptal edildiyse, mevcut bir yetkili credential kullanın; onu sohbete dökmeyin. |
| 403 | identity.scopes for google_search ve hazır erişim. Sahibinden eksik izin talep edin; istekteki kaynağı değiştirmek erişim sağlamaz. |
| 402 | Tekrar dengeyi okuyun ve mevcut fiyatla karşılaştırın. Sahibi Billing'u inceleyebilir. Bir tükenmiş denemenin sahibinin iddia yoluyla erişimine ihtiyacı vardır; bir yedek deneme oluşturmak iyileşme değildir. |
| 400 / 422 | Geri dönüş hata mesajını okuyun. Tam veri hostunu kontrol edin, POST yöntemi, Content-Type ve JSON alan isimlerini kontrol edin. Doğru alıntılar ve sayısal bir params.num kullanın, sonra reddedilen isteği düzeltin. |
| 429 | Retry-After'a saygı gösterin; aksi takdirde bir geri dönüş kullanın ve koncurrency azaltır. Hızlı bir şekilde döngüsü yapmayın, sınırı atlamak için yeni anahtarlar oluşturun veya başka bir deneme kayıt edin. |
| HTTP 200 başarısız statü veya hatayla | Vücuttaki hatayı okuyun ve herhangi bir istek veya işi korur ID. Başarılı bir görev olarak parsed JSON vücuduna tedavi etmeyin veya otomatik olarak yeniden ortaya çıkarın. |
| Boş sonuçlar | Durum yapılırsa, doğrulama çalıştı. Boş sonucu tutun veya yeni ücretli bir istek olarak daha geniş bir sorgu deneyin. |
| Zaman, bağlantı kaybı, 5xx veya HTML yerine JSON | Bir POST cevabı kaybedilmiş olsa bile kabul edilebilir. History'u orijinal sorgu için kontrol edin ve geri dönmeden önce IDs'ya geri dön. Free GET checks yeniden kullanılabilir. URL, data.flashdata.dev'u kullanarak onaylayın ve TLS doğrulamasını engellemeyin. |

- [Tarih İstek Tarihi](https://flashdata.dev/app/jobs)
- [Anahtarları yönetin](https://flashdata.dev/app/api-keys)
- [cURL downloads](https://curl.se/download.html)
- [Yükleme yükleme PowerShell](https://learn.microsoft.com/powershell/scripting/install/installing-powershell)
- [Node.js downloads](https://nodejs.org/en/download)
- [Python downloads](https://www.python.org/downloads/)
