api issues

This commit is contained in:
salvacybersec
2025-11-13 08:51:55 +03:00
parent 86ce4913b8
commit bff8164c5d
26 changed files with 15284 additions and 57 deletions

152
API.md
View File

@@ -16,18 +16,28 @@ Production için base URL değişebilir.
API key'i iki şekilde gönderebilirsiniz:
### 1. HTTP Header (Önerilen)
### 1. HTTP Header (Programatik kullanım için önerilen)
```http
X-API-Key: your_api_key_here
```
### 2. Query Parameter
**Not:** RSS okuyucular HTTP header gönderemediği için bu yöntem sadece programatik kullanım için uygundur.
### 2. Query Parameter (RSS okuyucular ve tarayıcılar için zorunlu)
```
?api_key=your_api_key_here
```
**Önemli:** RSS okuyucular, tarayıcılar ve feed aggregator'lar için **mutlaka query parameter** kullanılmalıdır çünkü bu uygulamalar HTTP header gönderemez.
**Güvenlik Notu:** API key'i URL'de kullanmak güvenlik açısından ideal değildir çünkü:
- URL'ler log dosyalarında, tarayıcı geçmişinde ve referrer header'larında görünebilir
- Ancak RSS okuyucular için bu tek seçenektir
- Production'da farklı API key'ler kullanarak riski azaltabilirsiniz
- API key'lerinizi düzenli olarak rotate edin
### API Key Alma
API key'ler `config/security.yaml` dosyasından yönetilir. Yeni bir API key eklemek için:
@@ -93,21 +103,46 @@ YouTube kanalı için transcript feed'i oluşturur.
**Örnek İstekler:**
**URL-Based Sorgular (RSS Okuyucular ve Tarayıcılar için):**
```bash
# Channel ID ile
# Channel ID ile (API key URL'de)
http://localhost:5000/?channel_id=UC9h8BDcXwkhZtnqoQJ7PggA&api_key=demo_key_12345&format=Atom
# Channel handle ile (API key URL'de)
http://localhost:5000/?channel=@tavakfi&api_key=demo_key_12345&format=Atom&max_items=10
# Channel URL ile (API key URL'de) - ÖNERİLEN
http://localhost:5000/?channel_url=https://www.youtube.com/@tavakfi&api_key=demo_key_12345&format=Atom&max_items=50
# RSS format ile
http://localhost:5000/?channel_url=https://www.youtube.com/@politicalfronts&api_key=demo_key_12345&format=Rss&max_items=20
```
**Programatik Kullanım (HTTP Header ile):**
```bash
# Channel ID ile (Header'da API key)
curl -H "X-API-Key: demo_key_12345" \
"http://localhost:5000/?channel_id=UC9h8BDcXwkhZtnqoQJ7PggA&format=Atom"
# Channel handle ile
# Channel handle ile (Header'da API key)
curl -H "X-API-Key: demo_key_12345" \
"http://localhost:5000/?channel=@tavakfi&format=Atom"
# Channel URL ile
# Channel URL ile (Header'da API key)
curl -H "X-API-Key: demo_key_12345" \
"http://localhost:5000/?channel_url=https://www.youtube.com/@tavakfi&format=Atom&max_items=50"
```
# Query parametresi ile API key
curl "http://localhost:5000/?channel_id=UC9h8BDcXwkhZtnqoQJ7PggA&api_key=demo_key_12345&format=Rss"
**Production URL Örnekleri:**
```
# Production URL ile Channel URL kullanımı
https://yt2feed.aligundogar.com.tr/?channel_url=https://www.youtube.com/@politicalfronts&api_key=your_api_key&format=Atom
# Production URL ile Channel ID kullanımı
https://yt2feed.aligundogar.com.tr/?channel_id=UC9h8BDcXwkhZtnqoQJ7PggA&api_key=your_api_key&format=Rss&max_items=50
```
**Başarılı Yanıt:**
@@ -332,10 +367,60 @@ API CORS desteği sağlar. Preflight request'ler için `OPTIONS` metodu kullanı
RSS reader uygulamanızda feed URL'si olarak kullanın:
**Önemli:** RSS okuyucular HTTP header gönderemediği için API key'i **mutlaka query parametresi** olarak eklemeniz gerekir.
**URL Formatı:**
```
http://your-api.com/?channel_id=UC9h8BDcXwkhZtnqoQJ7PggA&format=Rss&api_key=your_api_key
BASE_URL/?channel_url=YOUTUBE_CHANNEL_URL&api_key=YOUR_API_KEY&format=Atom&max_items=10
```
**Örnek URL'ler (Production):**
```
# Channel URL ile (ÖNERİLEN - En kolay ve güvenilir)
https://yt2feed.aligundogar.com.tr/?channel_url=https://www.youtube.com/@politicalfronts&api_key=your_api_key&format=Atom
# Channel URL ile RSS format
https://yt2feed.aligundogar.com.tr/?channel_url=https://www.youtube.com/@politicalfronts&api_key=your_api_key&format=Rss&max_items=50
# Channel ID ile
https://yt2feed.aligundogar.com.tr/?channel_id=UC9h8BDcXwkhZtnqoQJ7PggA&api_key=your_api_key&format=Atom&max_items=20
# Channel Handle ile
https://yt2feed.aligundogar.com.tr/?channel=@tavakfi&api_key=your_api_key&format=Atom&max_items=50
# Channel URL ile (Channel ID formatında)
https://yt2feed.aligundogar.com.tr/?channel_url=https://www.youtube.com/channel/UC9h8BDcXwkhZtnqoQJ7PggA&api_key=your_api_key&format=Rss
```
**Örnek URL'ler (Localhost - Test için):**
```
# Localhost test URL'i
http://localhost:5000/?channel_url=https://www.youtube.com/@politicalfronts&api_key=demo_key_12345&format=Atom
# Localhost ile Channel ID
http://localhost:5000/?channel_id=UC9h8BDcXwkhZtnqoQJ7PggA&api_key=demo_key_12345&format=Rss&max_items=10
```
**RSS Okuyucu Adımları:**
1. RSS okuyucunuzda "Feed Ekle", "Subscribe" veya "Add Feed" seçeneğini açın
2. Feed URL alanına yukarıdaki formatlardan birini yapıştırın
3. `your_api_key` kısmını kendi API key'inizle değiştirin
4. Feed'i ekleyin ve kaydedin
**Popüler RSS Okuyucular:**
- **Feedly**: Feed URL'sini direkt yapıştırın
- **Inoreader**: "Add New" > "Feed" > URL yapıştırın
- **NewsBlur**: "Add Site" > URL yapıştırın
- **The Old Reader**: "Add Subscription" > URL yapıştırın
- **NetNewsWire**: "File" > "Add Feed" > URL yapıştırın
**Not:**
- İlk istekte transcript'ler henüz işlenmemiş olabilir. Birkaç dakika bekleyip tekrar deneyin.
- API key'inizi URL'de paylaşmayın, sadece kendi RSS okuyucunuzda kullanın.
### 2. Programatik Kullanım (Python)
```python
@@ -363,6 +448,31 @@ else:
### 3. Programatik Kullanım (JavaScript)
**URL-Based (Tarayıcı için):**
```javascript
// Tarayıcıdan kullanım - API key URL'de
const apiKey = "your_api_key_here";
const channelUrl = "https://www.youtube.com/@politicalfronts";
const feedUrl = `https://yt2feed.aligundogar.com.tr/?channel_url=${encodeURIComponent(channelUrl)}&api_key=${apiKey}&format=Atom`;
fetch(feedUrl)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.text();
})
.then(feedContent => {
console.log(feedContent);
})
.catch(error => {
console.error("Error:", error);
});
```
**Header-Based (Node.js/Backend için):**
```javascript
const apiKey = "your_api_key_here";
const channelId = "UC9h8BDcXwkhZtnqoQJ7PggA";
@@ -388,13 +498,37 @@ fetch(`http://localhost:5000/?channel_id=${channelId}&format=Atom`, {
### 4. cURL ile Test
**URL-Based Sorgular (RSS Okuyucular ve Tarayıcılar için):**
```bash
# API key ile test
# API key URL'de - Channel URL ile (ÖNERİLEN)
API_KEY="demo_key_12345"
CHANNEL_URL="https://www.youtube.com/@politicalfronts"
curl "http://localhost:5000/?channel_url=${CHANNEL_URL}&api_key=${API_KEY}&format=Atom&max_items=50"
# API key URL'de - Channel ID ile
CHANNEL_ID="UC9h8BDcXwkhZtnqoQJ7PggA"
curl "http://localhost:5000/?channel_id=${CHANNEL_ID}&api_key=${API_KEY}&format=Rss&max_items=20"
# Production URL ile
curl "https://yt2feed.aligundogar.com.tr/?channel_url=https://www.youtube.com/@politicalfronts&api_key=${API_KEY}&format=Atom"
```
**Header-Based Sorgular (Programatik Kullanım için):**
```bash
# API key header'da - Channel ID ile
API_KEY="demo_key_12345"
CHANNEL_ID="UC9h8BDcXwkhZtnqoQJ7PggA"
curl -H "X-API-Key: $API_KEY" \
"http://localhost:5000/?channel_id=$CHANNEL_ID&format=Atom&max_items=50"
# API key header'da - Channel URL ile
CHANNEL_URL="https://www.youtube.com/@tavakfi"
curl -H "X-API-Key: $API_KEY" \
"http://localhost:5000/?channel_url=${CHANNEL_URL}&format=Atom&max_items=50"
```
## Notlar