Knowledge-Universe / test_github_query.py
vlsiddarth's picture
New Version Update
dc6eb4c
import httpx
import os
from dotenv import load_dotenv
load_dotenv()
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
# Test different query variations
queries = [
# Your current query (likely returns 0)
'machine learning tutorial tutorial OR learning OR education stars:>10 beginner OR introduction OR basic pushed:>2021-01-01',
# Simplified query (should work)
'machine learning stars:>3 in:name,description,readme',
# Even simpler
'machine learning stars:>5',
]
for i, query in enumerate(queries, 1):
print(f"\n{'='*60}")
print(f"TEST {i}: {query[:60]}...")
print('='*60)
response = httpx.get(
'https://api.github.com/search/repositories',
params={'q': query, 'per_page': 3},
headers={'Authorization': f'Bearer {GITHUB_TOKEN}'},
timeout=10
)
if response.status_code == 200:
data = response.json()
total = data.get('total_count', 0)
items = data.get('items', [])
print(f"βœ… Status: 200")
print(f"Total results: {total:,}")
print(f"Returned: {len(items)}")
if items:
print("\nTop 3:")
for repo in items:
print(f" - {repo['full_name']} ({repo['stargazers_count']:,} stars)")
else:
print("❌ No results!")
else:
print(f"❌ Status: {response.status_code}")
print(response.text[:200])
print("\n" + "="*60)