使用Python调用data.bioontology.org API时遇401授权错误求助
That 401 error pops up because your request isn’t carrying a valid API key—even though you thought you could query without logging in, the Bioontology API now requires an API key for all requests, including access to public data.
Step 1: Get Your API Key
Since you already have an account on the site, follow these steps to grab your key:
- Log into data.bioontology.org
- Click your username in the top-right corner, then select "My Account"
- Look for the "API Keys" tab (it’s usually in the sidebar or top navigation of your account page)
- You’ll either see an existing key here, or you can click "Generate New Key" to create a new one
Step 2: Update Your Code
Replace the empty string in your code with the actual API key you just obtained:
API_KEY = "your-real-api-key-here"
Quick Tips
- Double-check that you copied the key correctly—no extra spaces or typos allowed!
- Your existing code already sets up the Authorization header properly in the
get_jsonfunction, so once the key is valid, authentication should pass smoothly - The URL encoding via
urllib.parse.quotein your code is already handling special characters correctly, so that’s not the issue here
Once you update the API key, your script should pull annotation data successfully without hitting the 401 error.
内容的提问来源于stack exchange,提问作者Ribhu Nirek
相关产品推荐
相关产品推荐

