Skip to content

Commit 0facea6

Browse files
authored
Merge pull request #32 from DeepLcom/usage-endpoint-updates
feat: add updated usage endpoint
2 parents c0bc89c + 452d3fa commit 0facea6

File tree

4 files changed

+243
-43
lines changed

4 files changed

+243
-43
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ number is used only for corrections to the OpenAPI specification, for example:
1010
typos, schema fixes, or adding examples.
1111

1212

13+
### [3.1.0] - 2024-06-13
14+
### Changed
15+
* `/v2/usage`: Now returns a detailed response for API Pro users, including per-product usage and billing period information. For API users not on the Pro plan, the response remains unchanged and only includes `character_count` and `character_limit`.
16+
17+
1318
### [3.0.2] - 2025-04-24
1419
### Fixed
1520
* Fixed new server URLs to avoid double slash in paths

openapi.json

Lines changed: 94 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,19 +1993,37 @@
19931993
"content": {
19941994
"application/json": {
19951995
"schema": {
1996-
"type": "object",
1997-
"properties": {
1998-
"character_count": {
1999-
"description": "Characters translated so far in the current billing period.",
2000-
"type": "integer",
2001-
"format": "int64",
2002-
"example": 180118
2003-
},
2004-
"character_limit": {
2005-
"description": "Current maximum number of characters that can be translated per billing period. If cost control is set, the cost control limit will be returned in this field.",
2006-
"type": "integer",
2007-
"format": "int64",
2008-
"example": 1250000
1996+
"$ref": "#/components/schemas/UsageResponse"
1997+
},
1998+
"examples": {
1999+
"free": {
2000+
"summary": "Response for API users not on the Pro plan",
2001+
"value": {
2002+
"character_count": 180118,
2003+
"character_limit": 1250000
2004+
}
2005+
},
2006+
"pro": {
2007+
"summary": "Response for API Pro users",
2008+
"value": {
2009+
"character_count": 5947223,
2010+
"character_limit": 1000000000000,
2011+
"products": [
2012+
{
2013+
"product_type": "write",
2014+
"api_key_character_count": 0,
2015+
"character_count": 5643
2016+
},
2017+
{
2018+
"product_type": "translate",
2019+
"api_key_character_count": 636,
2020+
"character_count": 5941580
2021+
}
2022+
],
2023+
"api_key_character_count": 636,
2024+
"api_key_character_limit": 1000000000000,
2025+
"start_time": "2025-05-13T09:18:42Z",
2026+
"end_time": "2025-06-13T09:18:42Z"
20092027
}
20102028
}
20112029
}
@@ -2045,6 +2063,69 @@
20452063
"auth_header": []
20462064
}
20472065
]
2066+
},
2067+
"UsageResponse": {
2068+
"type": "object",
2069+
"properties": {
2070+
"character_count": {
2071+
"description": "Characters translated so far in the current billing period.",
2072+
"type": "integer",
2073+
"format": "int64",
2074+
"example": 180118
2075+
},
2076+
"character_limit": {
2077+
"description": "Current maximum number of characters that can be translated per billing period. If cost control is set, the cost control limit will be returned in this field.",
2078+
"type": "integer",
2079+
"format": "int64",
2080+
"example": 1250000
2081+
},
2082+
"products": {
2083+
"type": "array",
2084+
"description": "Only present for API Pro users. Per-product usage details.",
2085+
"items": {
2086+
"type": "object",
2087+
"properties": {
2088+
"product_type": {
2089+
"type": "string",
2090+
"description": "The type of product (e.g., 'write', 'translate').",
2091+
"example": "write"
2092+
},
2093+
"api_key_character_count": {
2094+
"type": "integer",
2095+
"description": "Characters used for this product by this API key in the current period.",
2096+
"example": 0
2097+
},
2098+
"character_count": {
2099+
"type": "integer",
2100+
"description": "Total characters used for this product in the current period.",
2101+
"example": 5643
2102+
}
2103+
}
2104+
}
2105+
},
2106+
"api_key_character_count": {
2107+
"type": "integer",
2108+
"description": "Only present for API Pro users. Total characters used by this API key in the current period.",
2109+
"example": 636
2110+
},
2111+
"api_key_character_limit": {
2112+
"type": "integer",
2113+
"description": "Only present for API Pro users. Character limit for this API key in the current period.",
2114+
"example": 1000000000000
2115+
},
2116+
"start_time": {
2117+
"type": "string",
2118+
"format": "date-time",
2119+
"description": "Only present for API Pro users. Start time of the current billing period (ISO 8601).",
2120+
"example": "2025-05-13T09:18:42Z"
2121+
},
2122+
"end_time": {
2123+
"type": "string",
2124+
"format": "date-time",
2125+
"description": "Only present for API Pro users. End time of the current billing period (ISO 8601).",
2126+
"example": "2025-06-13T09:18:42Z"
2127+
}
2128+
}
20482129
}
20492130
},
20502131
"/v2/languages": {

openapi.yaml

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,21 +1458,29 @@ paths:
14581458
content:
14591459
application/json:
14601460
schema:
1461-
type: object
1462-
properties:
1463-
character_count:
1464-
description: Characters translated so far in the current billing
1465-
period.
1466-
type: integer
1467-
format: int64
1468-
example: 180118
1469-
character_limit:
1470-
description: Current maximum number of characters that can be
1471-
translated per billing period. If cost control is set, the
1472-
cost control limit will be returned in this field.
1473-
type: integer
1474-
format: int64
1475-
example: 1250000
1461+
$ref: '#/components/schemas/UsageResponse'
1462+
examples:
1463+
free:
1464+
summary: Response for API users not on the Pro plan
1465+
value:
1466+
character_count: 180118
1467+
character_limit: 1250000
1468+
pro:
1469+
summary: Response for API Pro users
1470+
value:
1471+
character_count: 5947223
1472+
character_limit: 1000000000000
1473+
products:
1474+
- product_type: write
1475+
api_key_character_count: 0
1476+
character_count: 5643
1477+
- product_type: translate
1478+
api_key_character_count: 636
1479+
character_count: 5941580
1480+
api_key_character_count: 636
1481+
api_key_character_limit: 1000000000000
1482+
start_time: '2025-05-13T09:18:42Z'
1483+
end_time: '2025-06-13T09:18:42Z'
14761484
400:
14771485
$ref: '#/components/responses/BadRequest'
14781486
403:
@@ -1493,6 +1501,55 @@ paths:
14931501
$ref: '#/components/responses/TooManyRequests'
14941502
security:
14951503
- auth_header: []
1504+
UsageResponse:
1505+
type: object
1506+
properties:
1507+
character_count:
1508+
description: Characters translated so far in the current billing period.
1509+
type: integer
1510+
format: int64
1511+
example: 180118
1512+
character_limit:
1513+
description: Current maximum number of characters that can be translated per billing period. If cost control is set, the cost control limit will be returned in this field.
1514+
type: integer
1515+
format: int64
1516+
example: 1250000
1517+
products:
1518+
type: array
1519+
description: Only present for API Pro users. Per-product usage details.
1520+
items:
1521+
type: object
1522+
properties:
1523+
product_type:
1524+
type: string
1525+
description: The type of product (e.g., 'write', 'translate').
1526+
example: write
1527+
api_key_character_count:
1528+
type: integer
1529+
description: Characters used for this product by this API key in the current period.
1530+
example: 0
1531+
character_count:
1532+
type: integer
1533+
description: Total characters used for this product in the current period.
1534+
example: 5643
1535+
api_key_character_count:
1536+
type: integer
1537+
description: Only present for API Pro users. Total characters used by this API key in the current period.
1538+
example: 636
1539+
api_key_character_limit:
1540+
type: integer
1541+
description: Only present for API Pro users. Character limit for this API key in the current period.
1542+
example: 1000000000000
1543+
start_time:
1544+
type: string
1545+
format: date-time
1546+
description: Only present for API Pro users. Start time of the current billing period (ISO 8601).
1547+
example: '2025-05-13T09:18:42Z'
1548+
end_time:
1549+
type: string
1550+
format: date-time
1551+
description: Only present for API Pro users. End time of the current billing period (ISO 8601).
1552+
example: '2025-06-13T09:18:42Z'
14961553
/v2/languages:
14971554
get:
14981555
tags:

openapi_gitbook.yaml

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,21 +1356,29 @@ paths:
13561356
content:
13571357
application/json:
13581358
schema:
1359-
type: object
1360-
properties:
1361-
character_count:
1362-
description: Characters translated so far in the current billing
1363-
period.
1364-
type: integer
1365-
format: int64
1366-
example: 180118
1367-
character_limit:
1368-
description: Current maximum number of characters that can be
1369-
translated per billing period. If cost control is set, the
1370-
cost control limit will be returned in this field.
1371-
type: integer
1372-
format: int64
1373-
example: 1250000
1359+
$ref: '#/components/schemas/UsageResponse'
1360+
examples:
1361+
free:
1362+
summary: Response for API users not on the Pro plan
1363+
value:
1364+
character_count: 180118
1365+
character_limit: 1250000
1366+
pro:
1367+
summary: Response for API Pro users
1368+
value:
1369+
character_count: 5947223
1370+
character_limit: 1000000000000
1371+
products:
1372+
- product_type: write
1373+
api_key_character_count: 0
1374+
character_count: 5643
1375+
- product_type: translate
1376+
api_key_character_count: 636
1377+
character_count: 5941580
1378+
api_key_character_count: 636
1379+
api_key_character_limit: 1000000000000
1380+
start_time: '2025-05-13T09:18:42Z'
1381+
end_time: '2025-06-13T09:18:42Z'
13741382
400:
13751383
$ref: '#/components/responses/BadRequest'
13761384
403:
@@ -2242,3 +2250,52 @@ components:
22422250
- prefer_diplomatic
22432251
- prefer_enthusiastic
22442252
- prefer_friendly
2253+
UsageResponse:
2254+
type: object
2255+
properties:
2256+
character_count:
2257+
description: Characters translated so far in the current billing period.
2258+
type: integer
2259+
format: int64
2260+
example: 180118
2261+
character_limit:
2262+
description: Current maximum number of characters that can be translated per billing period. If cost control is set, the cost control limit will be returned in this field.
2263+
type: integer
2264+
format: int64
2265+
example: 1250000
2266+
products:
2267+
type: array
2268+
description: Only present for API Pro users. Per-product usage details.
2269+
items:
2270+
type: object
2271+
properties:
2272+
product_type:
2273+
type: string
2274+
description: The type of product (e.g., 'write', 'translate').
2275+
example: write
2276+
api_key_character_count:
2277+
type: integer
2278+
description: Characters used for this product by this API key in the current period.
2279+
example: 0
2280+
character_count:
2281+
type: integer
2282+
description: Total characters used for this product in the current period.
2283+
example: 5643
2284+
api_key_character_count:
2285+
type: integer
2286+
description: Only present for API Pro users. Total characters used by this API key in the current period.
2287+
example: 636
2288+
api_key_character_limit:
2289+
type: integer
2290+
description: Only present for API Pro users. Character limit for this API key in the current period.
2291+
example: 1000000000000
2292+
start_time:
2293+
type: string
2294+
format: date-time
2295+
description: Only present for API Pro users. Start time of the current billing period (ISO 8601).
2296+
example: '2025-05-13T09:18:42Z'
2297+
end_time:
2298+
type: string
2299+
format: date-time
2300+
description: Only present for API Pro users. End time of the current billing period (ISO 8601).
2301+
example: '2025-06-13T09:18:42Z'

0 commit comments

Comments
 (0)