Twitter/X Usage API
The Usage API from Twitter/X — 1 operation(s) for usage.
The Usage API from Twitter/X — 1 operation(s) for usage.
openapi: 3.0.0
info:
description: X API v2 available endpoints
version: '2.166'
title: X API v2 Account Activity Usage API
termsOfService: https://developer.x.com/en/developer-terms/agreement-and-policy.html
contact:
name: X Developers
url: https://developer.x.com/
license:
name: X Developer Agreement and Policy
url: https://developer.x.com/en/developer-terms/agreement-and-policy.html
servers:
- description: X API
url: https://api.x.com
tags:
- name: Usage
paths:
/2/usage/tweets:
get:
security:
- BearerToken: []
tags:
- Usage
summary: Get usage
description: Retrieves usage statistics for Posts over a specified number of days.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/usage/tweets/api-reference/get-usage-tweets
operationId: getUsage
parameters:
- name: days
in: query
description: The number of days for which you need usage for.
required: false
schema:
type: integer
minimum: 1
maximum: 90
format: int32
default: 7
style: form
- $ref: '#/components/parameters/UsageFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2UsageTweetsResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
components:
parameters:
UsageFieldsParameter:
name: usage.fields
in: query
description: A comma separated list of Usage fields to display.
required: false
schema:
type: array
description: The fields available for a Usage object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- cap_reset_day
- daily_client_app_usage
- daily_project_usage
- project_cap
- project_id
- project_usage
example:
- cap_reset_day
- daily_client_app_usage
- daily_project_usage
- project_cap
- project_id
- project_usage
explode: false
style: form
schemas:
Get2UsageTweetsResponse:
type: object
properties:
data:
$ref: '#/components/schemas/Usage'
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
Problem:
type: object
description: An HTTP Problem Details object, as defined in IETF RFC 7807 (https://tools.ietf.org/html/rfc7807).
required:
- type
- title
properties:
detail:
type: string
status:
type: integer
title:
type: string
type:
type: string
discriminator:
propertyName: type
mapping:
about:blank: '#/components/schemas/GenericProblem'
https://api.twitter.com/2/problems/client-disconnected: '#/components/schemas/ClientDisconnectedProblem'
https://api.twitter.com/2/problems/client-forbidden: '#/components/schemas/ClientForbiddenProblem'
https://api.twitter.com/2/problems/conflict: '#/components/schemas/ConflictProblem'
https://api.twitter.com/2/problems/disallowed-resource: '#/components/schemas/DisallowedResourceProblem'
https://api.twitter.com/2/problems/duplicate-rules: '#/components/schemas/DuplicateRuleProblem'
https://api.twitter.com/2/problems/invalid-request: '#/components/schemas/InvalidRequestProblem'
https://api.twitter.com/2/problems/invalid-rules: '#/components/schemas/InvalidRuleProblem'
https://api.twitter.com/2/problems/noncompliant-rules: '#/components/schemas/NonCompliantRulesProblem'
https://api.twitter.com/2/problems/not-authorized-for-field: '#/components/schemas/FieldUnauthorizedProblem'
https://api.twitter.com/2/problems/not-authorized-for-resource: '#/components/schemas/ResourceUnauthorizedProblem'
https://api.twitter.com/2/problems/operational-disconnect: '#/components/schemas/OperationalDisconnectProblem'
https://api.twitter.com/2/problems/resource-not-found: '#/components/schemas/ResourceNotFoundProblem'
https://api.twitter.com/2/problems/resource-unavailable: '#/components/schemas/ResourceUnavailableProblem'
https://api.twitter.com/2/problems/rule-cap: '#/components/schemas/RulesCapProblem'
https://api.twitter.com/2/problems/streaming-connection: '#/components/schemas/ConnectionExceptionProblem'
https://api.twitter.com/2/problems/unsupported-authentication: '#/components/schemas/UnsupportedAuthenticationProblem'
https://api.twitter.com/2/problems/usage-capped: '#/components/schemas/UsageCapExceededProblem'
UsageFields:
type: object
description: Represents the data for Usage
properties:
date:
type: string
description: The time period for the usage
format: date-time
example: '2021-01-06T18:40:40.000Z'
usage:
type: integer
description: The usage value
format: int32
ClientAppUsage:
type: object
description: Usage per client app
properties:
client_app_id:
type: string
description: The unique identifier for this project
format: ^[0-9]{1,19}$
usage:
type: array
description: The usage value
minItems: 1
items:
$ref: '#/components/schemas/UsageFields'
usage_result_count:
type: integer
description: The number of results returned
format: int32
Usage:
type: object
description: Usage per client app
properties:
cap_reset_day:
type: integer
description: Number of days left for the Tweet cap to reset
format: int32
daily_client_app_usage:
type: array
description: The daily usage breakdown for each Client Application a project
minItems: 1
items:
$ref: '#/components/schemas/ClientAppUsage'
daily_project_usage:
type: object
description: The daily usage breakdown for a project
properties:
project_id:
type: integer
description: The unique identifier for this project
format: int32
usage:
type: array
description: The usage value
minItems: 1
items:
$ref: '#/components/schemas/UsageFields'
project_cap:
type: integer
description: Total number of Posts that can be read in this project per month
format: int32
project_id:
type: string
description: The unique identifier for this project
format: ^[0-9]{1,19}$
project_usage:
type: integer
description: The number of Posts read in this project
format: int32
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
securitySchemes:
BearerToken:
type: http
scheme: bearer
OAuth2UserToken:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://api.x.com/2/oauth2/authorize
tokenUrl: https://api.x.com/2/oauth2/token
scopes:
block.read: View accounts you have blocked.
bookmark.read: Read your bookmarked Posts.
bookmark.write: Create and delete your bookmarks.
dm.read: Read all your Direct Messages.
dm.write: Send and manage your Direct Messages.
follows.read: View accounts you follow and accounts following you.
follows.write: Follow and unfollow accounts on your behalf.
like.read: View Posts you have liked and likes you can see.
like.write: Like and unlike Posts on your behalf.
list.read: View Lists, members, and followers of Lists you created or are a member of, including private Lists.
list.write: Create and manage Lists on your behalf.
media.write: Upload media, such as photos and videos, on your behalf.
mute.read: View accounts you have muted.
mute.write: Mute and unmute accounts on your behalf.
offline.access: Request a refresh token for the app.
space.read: View all Spaces you have access to.
timeline.read: View all Custom Timelines you can see, including public Custom Timelines from other developers.
tweet.moderate.write: Hide and unhide replies to your Posts.
tweet.read: View all Posts you can see, including those from protected accounts.
tweet.write: Post and repost on your behalf.
users.read: View any account you can see, including protected accounts.
UserToken:
type: http
scheme: OAuth