Consistent patterns
URL structure
All v2 endpoints follow a predictable pattern:Response structure
All responses use the same top-level structure:ID format
All IDs are returned as strings to ensure language compatibility:Fields and expansions
The same fields and expansions parameters work consistently:| Object | Fields parameter | Works across |
|---|---|---|
| Post | tweet.fields | All endpoints returning posts |
| User | user.fields | All endpoints returning users |
| Media | media.fields | All endpoints with media expansions |
| Poll | poll.fields | All endpoints with poll expansions |
| Place | place.fields | All endpoints with place expansions |
Object schemas
The same object type has the same fields regardless of which endpoint returns it:- A Post from search has the same fields as a Post from lookup
- A User from followers has the same fields as a User from search
- Expanded objects match their standalone counterparts
Authentication
All endpoints use the same authentication methods:| Method | Header format |
|---|---|
| Bearer Token | Authorization: Bearer {token} |
| OAuth 1.0a | Authorization: OAuth {parameters} |
| OAuth 2.0 | Authorization: Bearer {user_token} |
Error handling
Errors follow a consistent format:Pagination
All paginated endpoints use the same token system:| Parameter | Description |
|---|---|
max_results | Results per page |
pagination_token | Token from next_token or previous_token |
Naming conventions
- American English spelling (
favoritesnotfavourites) - Snake_case for field names (
author_id,created_at) - Consistent terminology (
retweet_count, notrepost_countin fields)
Empty values
Fields with no value are omitted rather than returned asnull:
Entity consistency
Theentities object only contains entities parsed from text:
urlshashtagsmentionscashtags
attachments, not entities.
What this means for you
Learn once, use everywhere
Patterns you learn on one endpoint apply to all endpoints.
Predictable responses
Same object types have same structures across the API.
Simpler code
Build reusable functions for common patterns.
Easier debugging
Consistent error formats simplify troubleshooting.