from cognite.client.data_classes import filters
from cognite.client.data_classes.documents import DocumentProperty
is_pdf = filters.Equals(DocumentProperty.mime_type, "application/pdf")
pdf_documents = client.documents.list(filter=is_pdf)
from cognite.client.data_classes.documents import DocumentProperty
for document in client.documents:
print(document.name)
from cognite.client.data_classes.documents import SortableDocumentProperty
documents = client.documents.list(sort=(SortableDocumentProperty.mime_type, "desc")){
"items": [
{
"id": 2384,
"createdTime": 1519862400000,
"sourceFile": {
"name": "hamlet.txt",
"directory": "plays/shakespeare",
"source": "SubsurfaceConnectors",
"mimeType": "application/octet-stream",
"size": 1000,
"hash": "23203f9264161714cdb8d2f474b9b641e6a735f8cea4098c40a3cab8743bd749",
"assetIds": [],
"labels": [
{
"externalId": "play"
},
{
"externalId": "tragedy"
}
],
"geoLocation": {
"type": "Point",
"coordinates": [
10.74609,
59.91273
]
},
"datasetId": 4503599627370496,
"securityCategories": [],
"metadata": {}
},
"externalId": "haml001",
"instanceId": {
"space": "<string>",
"externalId": "<string>"
},
"title": "Hamlet",
"author": "William Shakespeare",
"producer": "<string>",
"modifiedTime": 1519958703000,
"lastIndexedTime": 1521062805000,
"mimeType": "text/plain",
"extension": "pdf",
"pageCount": 2,
"type": "Document",
"language": "en",
"truncatedContent": "ACT I\nSCENE I. Elsinore. A platform before the castle.\n FRANCISCO at his post. Enter to him BERNARDO\nBERNARDO\n Who's there?\n",
"assetIds": [
42,
101
],
"labels": [
{
"externalId": "my.known.id"
}
],
"geoLocation": {
"type": "Point",
"coordinates": [
10.74609,
59.91273
]
}
}
],
"nextCursor": "<string>"
}Required capabilities:
filesAcl:READ
Retrieves a list of the documents in a project. You can use filters to narrow down the list. Unlike the search endpoint, the pagination isn’t restricted to 1000 documents in total, meaning this endpoint can be used to iterate through all the documents in your project.
For more information on how the filtering works, see the documentation for the search endpoint.
from cognite.client.data_classes import filters
from cognite.client.data_classes.documents import DocumentProperty
is_pdf = filters.Equals(DocumentProperty.mime_type, "application/pdf")
pdf_documents = client.documents.list(filter=is_pdf)
from cognite.client.data_classes.documents import DocumentProperty
for document in client.documents:
print(document.name)
from cognite.client.data_classes.documents import SortableDocumentProperty
documents = client.documents.list(sort=(SortableDocumentProperty.mime_type, "desc")){
"items": [
{
"id": 2384,
"createdTime": 1519862400000,
"sourceFile": {
"name": "hamlet.txt",
"directory": "plays/shakespeare",
"source": "SubsurfaceConnectors",
"mimeType": "application/octet-stream",
"size": 1000,
"hash": "23203f9264161714cdb8d2f474b9b641e6a735f8cea4098c40a3cab8743bd749",
"assetIds": [],
"labels": [
{
"externalId": "play"
},
{
"externalId": "tragedy"
}
],
"geoLocation": {
"type": "Point",
"coordinates": [
10.74609,
59.91273
]
},
"datasetId": 4503599627370496,
"securityCategories": [],
"metadata": {}
},
"externalId": "haml001",
"instanceId": {
"space": "<string>",
"externalId": "<string>"
},
"title": "Hamlet",
"author": "William Shakespeare",
"producer": "<string>",
"modifiedTime": 1519958703000,
"lastIndexedTime": 1521062805000,
"mimeType": "text/plain",
"extension": "pdf",
"pageCount": 2,
"type": "Document",
"language": "en",
"truncatedContent": "ACT I\nSCENE I. Elsinore. A platform before the castle.\n FRANCISCO at his post. Enter to him BERNARDO\nBERNARDO\n Who's there?\n",
"assetIds": [
42,
101
],
"labels": [
{
"externalId": "my.known.id"
}
],
"geoLocation": {
"type": "Point",
"coordinates": [
10.74609,
59.91273
]
}
}
],
"nextCursor": "<string>"
}Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.
Fields to be set for the list request.
Filter with exact match
A query that matches items matching boolean combinations of other queries.
It is built using one or more boolean clauses, which can be of types: and, or or not
Show child attributes
List of properties to sort by. Currently only supports 1 property.
1 elementShow child attributes
Maximum number of items per page. Use the cursor to get more pages.
1 <= x <= 1000Cursor for paging through results.
Was this page helpful?