Debugging API Requests
During the development process, closely examine the user_input
key object, which provides access to all your parameters. If any errors occur or if certain characters were not accurately parsed due to URL encoding, you will be able to identify them.
To check the user_input
object, you can use the debug
parameter. When set to 1
, the user_input
object will be included in the response.
Parameters
0
is for false and 1
is for true.
Parameter | Description | Type | Required |
---|---|---|---|
debug | Include the user_input object in the response | integer | No |
Request Example
curl "https://api.apitube.io/v1/news/everything?per_page=50&api_key=YOUR_API_KEY&debug=1"
WARNING
The debug
parameter should only be used for debugging purposes and should not be included in production environments.
This page contains useful tips for debugging API requests and solving the most common problems.
Common Issues and Solutions
1. Authentication Errors
If you're receiving 401 or 403 errors, check the following:
- Whether your API key is specified correctly
- Whether your key has not expired
- Whether you have sufficient limits in your plan
- Whether the authorization header is specified correctly
Example of a correct authentication request:
# Option 1: API key in header
curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything
# Option 2: Bearer token
curl -H "Authorization: Bearer YOUR_API_KEY" https://api.apitube.io/v1/news/everything
# Option 3: API key in URL (not recommended for production)
curl https://api.apitube.io/v1/news/everything?api_key=YOUR_API_KEY
2. Request Parameter Issues
If you're getting unexpected results or 400 errors:
- Check if the parameters are spelled correctly
- Make sure parameter values match expected formats
- Use proper URL encoding for special characters
Example of a request with multiple parameters:
curl -H "X-API-Key: YOUR_API_KEY" \
"https://api.apitube.io/v1/news/everything?title=Apple%20iPhone&language.code=en&published_at.start=2024-01-01&per_page=10"
3. Rate Limit Restrictions
If you're receiving 429 errors (Too Many Requests):
- Check your current usage in your account dashboard
- Add delays between requests
- Consider caching results
- Optimize requests to get more data in a single call
Additional Tips
- Gradual complexity: start with simple requests and gradually add parameters
- Check documentation: make sure you're using the current API version
- Test limits: understand how rate limits work for your pricing plan
- Handle errors: always include error handling in your code
- Contact support: if you can't solve an issue, contact our support team