How to use "q" Query parameter in Bitbucket REST API?

1.1k views Asked by At

So I am aware of the fact that you can get the files in a repository by using

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug} API.

The API also supports the q parameter where you can query the resulting json object based on various fields in it. I wanted to know if one can use this query parameter to fetch the files based on certain extensions? Like the JSON object also contains a field "mimetype" which defines the mime type of the files.

I did use the following API call

https://api.bitbucket.org/2.0/repositories/{workspace}/openapi/src/master/?max_depth=100&q=path+%7E+%22.js%22&pagelen=100

To fetch all the files which contain the string ".js" in the path parameter.

But while querying the mimetype parameter I was not able to do the same using

https://api.bitbucket.org/2.0/repositories/{workspace}/openapi/src/master/?max_depth=100&q=mimetype+%3D+%22application%2Fjavascript%22&pagelen=100 This call returned error.

Can anybody let me know how can you query based on mimetype or if possible fetch the files based on extension

Note: I know about the Code search API but that is not an option as it has large limitations.

0

There are 0 answers