API authentication: x-api-key returns 403, api-key header works
- Lenguaje dominante
- Python
- Estrellas
- 113
- Forks
- 18
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
## Summary
The official documentation and tutorial state that API keys should be passed via the `x-api-key` header. However, when using a valid API key, the `x-api-key` header consistently returns **403 Forbidden**, while the undocumented `api-key` header is accepted and works correctly.
## Steps to Reproduce
```python
import requests
api_key = ""
paper_id = "649def34f8be52c8b66281af98ae884c09aef38b"
url = f"https://api.semanticscholar.org/graph/v1/paper/{paper_id}"
params = {"fields": "title,year"}
# Official documented header → 403 Forbidden
r1 = requests.get(url, params=params, headers={"x-api-key": api_key})
print(f"x-api-key: {r1.status_code}") # 403
# Undocumented header → works (200 or 429 if rate limited)
r2 = requests.get(url, params=params, headers={"api-key": api_key})
print(f"api-key: {r2.status_code}") # 200
# Also confirmed on bulk search endpoint
url2 = "https://api.semanticscholar.org/graph/v1/paper/search/bulk"
params2 = {"query": "generative ai", "fields": "title,url", "year": "2023-"}
r3 = requests.get(url2, params=params2, headers={"x-api-key": api_key})
print(f"bulk x-api-key: {r3.status_code}") # 403
r4 = requests.get(url2, params=params2, headers={"api-key": api_key})
print(f"bulk api-key: {r4.status_code}") # 200
```
## Test Results
| Header | Status | Result |
|--------|--------|--------|
| `x-api-key` (documented) | 403 | Forbidden |
| `api-key` (undocumented) | 200 | Success |
| (no key) | 429 | Rate limited (anonymous) |
Also tested `partner.semanticscholar.org` — DNS does not resolve, so this is not a partner vs public endpoint issue.
## Expected Behavior
`x-api-key` should authenticate successfully as documented at https://www.semanticscholar.org/product/api/tutorial.
## Additional Notes
- Observed on 2026-05-08, confirmed on 2026-05-10.
- The official tutorial still shows `x-api-key` in all code examples.
- `s2-folks` repo has issues disabled, redirecting here.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.