Skip to main content
Question

How to fetch BOX file metadata information using Box API with python SDK?

  • May 22, 2025
  • 8 replies
  • 41 views

Forum|alt.badge.img

Hi

 

Can anyone please let me know how to fetch BOX file metadata information using Box API with python SDK?

I am using the JWTauth process for authentication.

 

 

8 replies

Forum|alt.badge.img

 

The documentation has been recently updated and organised on GitHub, please take a read and you should be able to find most things here : https://github.com/box/box-python-sdk/tree/master/docs/usage

 

metadata = client.file(file_id='11111').metadata(scope='enterprise', template='myMetadata').get()
print('Got metadata instance {0}'.format(metadata['$id']))

Forum|alt.badge.img

Thanks for your response 


Forum|alt.badge.img

I actually want the metadata of the file which are uploaded on current day. I mean I want to read the file which came in today in a folder. 


Forum|alt.badge.img

Can I fetch the metadata of today's files only ?


Forum|alt.badge.img

If I execute the below statement, I could see some metadata of the file is getting displayed in json format.

client.file(file_id='123').get()

 

I want to save this metadata into a file in the same format of json. How can I do that ?

 
 

Forum|alt.badge.img

BOX_2p2ielztz1velw50d3ha0owjksiyv4qt.png

This whole json content I want to save it to a file. How can I do that ?

 


Forum|alt.badge.img

When I execute this command.

>>> x = client.file(file_id=34***phone number removed for privacy***).get()

>>>type(x)

Output:

 It's actually a box object, I need to convert it to a json object, so that I can save it to a file. 

Can someone help me please.


Forum|alt.badge.img

 

have you tried using the json library?

 

import json

x = client.file(file_id).get()

print(json.dumps(x))

 

or

print(json.dumps(x.__dict__))