Welcome to the new Box Support website. Check out all the details here on what’s changed.

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

New post

Comments

8 comments

  • BB_Jake

     

    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']))
    0
    Comment actions Permalink
  • ch_srikanth

    Thanks for your response 

    0
    Comment actions Permalink
  • ch_srikanth

    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. 

    0
    Comment actions Permalink
  • ch_srikanth

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

    0
    Comment actions Permalink
  • ch_srikanth

    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 ?

     
     
    0
    Comment actions Permalink
  • ch_srikanth

    image.png

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

     

    0
    Comment actions Permalink
  • ch_srikanth

    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.

    0
    Comment actions Permalink
  • BB_Jake

     

    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__))

     

     

    0
    Comment actions Permalink

Please sign in to leave a comment.