Skip to main content
Question

Get files contents from search

  • May 22, 2025
  • 1 reply
  • 11 views

Forum|alt.badge.img

On the box.com site, when a user searches a phrase/word, in the results below the file name shows some file contents that match the search term. Is there a way to replicate this using the box api?

BOX_an6k11i6ewzvjm00315wixqa39cw5bc3.png

1 reply

Forum|alt.badge.img

Hi , 

 

There's not an exact way to have relevant matched content returned by the /search API. The closest behavior you could get would be to return the extracted text representation of any search results:

https://developer.box.com/en/guides/representations/text/

 

And then deciding how you'd want to display surrounding text, e.g. X letters before and after or using more advanced relevance logic. 

 

Always feel free to add suggestions to https://pulse.box.com/! It'll help us the most if you can provide context around your use case so we can understand how new features would impact customers.

 

Thanks,

Jason