Familiar with v1 or v2? The date-based versions map to: v1 =
2022-01-01, v2 = 2024-01-01, v3 = 2026-05-25. This guide uses both naming schemes.Version comparison
Migrating from v1 to v2
What changed
- Response envelope:
{ success, total, data }→{ success, totalHits, articles } - Pagination:
total→totalHits,pageSize,totalPages - Article fields: Added
thumbnail,description,keywords
Before (v1)
After (v2)
Code changes
Before (v1):Migrating from v2 to v3
What changed
- Response envelope:
{ success, totalHits, articles }→{ metadata, parameters, news_articles } - Article
typediscriminator: Addedtypefield to distinguish articles, stories, storylines, social posts - Error format:
{ success: false, code }→{ metadata, errors } - Pagination:
totalHits→total_hits,pageSize→hits_per_page
Before (v2)
After (v3)
Code changes
Before (v2):Migrating from v1 to v3 (skip v2)
If you’re on v1 and want to go directly to v3, combine both migrations:- Update response parsing:
{ success, total, data }→{ metadata, parameters, news_articles } - Handle new
typediscriminator onnews_articlesitems - Update error handling:
{ success: false, code }→{ metadata, errors } - Update pagination:
total→total_hits
Testing checklist
After migrating, verify:- Requests include the
api-versionheader with the target version - Response parsing uses the new envelope structure
- Article field names match the new schema
- Error handling uses the new error format
- Pagination uses the new field names
- New
typediscriminator onnews_articlesis handled correctly