The YouVersion Bible API uses standard HTTP status codes to indicate the success or failure of requests. This page documents all possible error responses and how to handle them.
HTTP Status Codes
2xx Success
- 200 OK: Request was successful
- 204 No Content: Request was successful but no data was returned
4xx Client Errors
- 400 Bad Request: Invalid query string parameters or request format
- 401 Unauthorized: Missing or invalid App Key
- 404 Not Found: The requested resource was not found
- 406 Not Acceptable: Invalid Accept header
5xx Server Errors
- 500 Internal Server Error: An unexpected error occurred on the server
- 503 Service Unavailable: The service is temporarily unavailable
Common Error Scenarios
Authentication Errors
Status Code: 401 Unauthorized
Cause: Missing or invalid X-YVP-App-Key header
Example Response:
Code
Solution: Ensure you're including a valid App Key in the X-YVP-App-Key header with every request.
Invalid Parameters
Status Code: 400 Bad Request
Cause: Invalid query parameters or request format
Example Response:
Code
Common Issues:
- Invalid
language_rangesformat - Invalid
version_id(must be an integer) - Invalid
book_usfm(must be 3 characters) - Invalid
chapter_number(must be a positive integer)
Resource Not Found
Status Code: 404 Not Found
Cause: The requested resource doesn't exist
Example Response:
Code
Common Scenarios:
- Bible version ID doesn't exist
- Book USFM identifier is invalid
- Chapter number exceeds the book's chapter count
- Verse number exceeds the chapter's verse count
No Content Available
Status Code: 204 No Content
Cause: Request was successful but no data matches the criteria
Example: Requesting Bible versions for a language that has no available translations
Solution: This is not an error - it's a valid response indicating no content is available for the given parameters.
Invalid Accept Header
Status Code: 406 Not Acceptable
Cause: The Accept header specifies an unsupported content type
Example Response:
Code
Solution: Use application/json in your Accept header or omit the header entirely.
Error Handling Examples
JavaScript (Fetch API)
Code
Python (Requests)
Code
cURL
Code
Rate Limiting
While not explicitly documented in the OpenAPI spec, the API may implement rate limiting. If you encounter rate limiting:
Status Code: 429 Too Many Requests
Response Headers:
X-RateLimit-Limit: Maximum requests per time windowX-RateLimit-Remaining: Remaining requests in current windowX-RateLimit-Reset: Time when the rate limit resets
Example Response:
Code
Solution: Implement exponential backoff and respect the rate limit headers.
Best Practices for Error Handling
- Always check status codes: Don't assume requests will succeed
- Handle 204 responses: These are successful but return no content
- Implement retry logic: For transient errors (5xx status codes)
- Log error details: Include status codes and error messages in logs
- Provide user-friendly messages: Translate technical errors for end users
- Validate parameters: Check parameters before making requests
- Use appropriate timeouts: Don't let requests hang indefinitely
Testing Error Scenarios
You can test error handling by:
- Invalid App Key: Use a fake App Key to test 401 responses
- Invalid Bible ID: Use a non-existent Bible ID (e.g., 99999) to test 404 responses
- Invalid parameters: Use malformed query parameters to test 400 responses
- Network issues: Disconnect from the internet to test connection errors
Getting Help
If you encounter errors that aren't documented here or need clarification:
- Check the API Reference for endpoint-specific error information
- Review the Authentication guide
- Contact the YouVersion Platform Team for support