-
Notifications
You must be signed in to change notification settings - Fork 8
docs(API): improve GET /projects/:id/documents documentation #1178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,16 @@ | ||
| --- | ||
| summary: List documents | ||
| description: List all documents the current user has access to. | ||
| description: | | ||
| Returns a paginated list of documents in the specified project that the current user has access to. | ||
|
|
||
| Use this endpoint to retrieve the document inventory for a project — for example, to display a list of source files in a dashboard, or to programmatically determine which documents are available before fetching segments. | ||
|
|
||
| Documents are ordered by creation date (newest first). Pagination is communicated via the `Link` response header following RFC 5988 (Web Linking); use the `next` and `prev` relations to traverse pages. The `q` parameter performs a case-insensitive substring match on document names. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as mentioned, I think pagination information is superfluous here. Other information (such as sorting, on endpoints which do not offer sorting-specific parameters which are documented separately) is welcome. |
||
|
|
||
| Pitfalls: | ||
| - Results are scoped to documents the authenticated user can read via `DocumentPolicy#list_documents?`. Users without project read access see an empty list, not a 403. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not expose identifier names from internal applications. |
||
| - The `per_page` parameter defaults to 25 and is capped at 100. Requests exceeding this cap are clamped silently. | ||
| - Rate limits apply; requests exceeding the account limit return 429. Retry after the interval indicated by the `X-Rate-Limit-Reset` response header. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rate limiting applies universally and is explained on a dedicated place. I see no benefit of repeating this information everywhere (similar to pagination). |
||
| operationId: documents/list | ||
| tags: | ||
| - Documents | ||
|
|
@@ -9,22 +19,31 @@ parameters: | |
| - "$ref": "../../parameters.yaml#/page" | ||
| - "$ref": "../../parameters.yaml#/per_page" | ||
| - "$ref": "../../parameters.yaml#/project_id" | ||
| - description: |- | ||
| Search query. Filters documents by name (case-insensitive substring match). | ||
| - description: | | ||
| Filter documents by name. Case-insensitive substring match against the document name field. | ||
| name: q | ||
| in: query | ||
| example: invoice | ||
| schema: | ||
| type: string | ||
| responses: | ||
| '200': | ||
| description: OK | ||
| description: OK — returns an array of document objects. Pagination metadata is in the `Link` response header. | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: array | ||
| items: | ||
| "$ref": "../../schemas/document.yaml#/document" | ||
| example: | ||
| - id: abcd1234cdef1234abcd1234cdef1234 | ||
| name: email.html | ||
| created_at: '2024-03-15T10:22:00Z' | ||
| updated_at: '2024-03-16T08:45:00Z' | ||
| - id: beef5678cafe5678beef5678cafe5678 | ||
| name: marketing-landing.html | ||
| created_at: '2024-02-01T14:00:00Z' | ||
| updated_at: '2024-02-10T09:10:00Z' | ||
| headers: | ||
| X-Rate-Limit-Limit: | ||
| "$ref": "../../headers.yaml#/X-Rate-Limit-Limit" | ||
|
|
@@ -38,19 +57,19 @@ responses: | |
| "$ref": "../../headers.yaml#/Pagination" | ||
| '400': | ||
| "$ref": "../../responses.yaml#/400" | ||
| '404': | ||
| "$ref": "../../responses.yaml#/404" | ||
| '401': | ||
| "$ref": "../../responses.yaml#/401" | ||
| '403': | ||
| "$ref": "../../responses.yaml#/403" | ||
| description: Forbidden. Returned when the access token lacks the `read` scope or when the requesting user is not allowed to list documents in this project. | ||
| '404': | ||
| "$ref": "../../responses.yaml#/404" | ||
| '429': | ||
| "$ref": "../../responses.yaml#/429" | ||
| x-code-samples: | ||
| - lang: Curl | ||
| source: |- | ||
| curl "https://api.phrase.com/v2/documents?project_id=asdf" \ | ||
| curl "https://api.phrase.com/v2/projects/:project_id/documents?q=invoice&page=1&per_page=25" \ | ||
| -u USERNAME_OR_ACCESS_TOKEN | ||
| - lang: CLI v2 | ||
| source: |- | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's helpful to say the list is paginated here. Most of our responses are paginated and pagination is explained in the separate section.