Spaces:
Running
Running
| 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) |