Hello. I am looking for an API to search for a string across my bitbucket repo. Basically when we want to search a string in bitbucket, we would use the search box on the top right corner and input the string. This would return us the files (and its contents) and which have that string.
I am able to get a list of all my files, under a certain repo using the API mentioned at the bottom. The project key is the parent repo. repo_slug is the child repo.
The baseURL is
https://bitbucketdc.{company-name}.net
It uses bearer token as an authentication. Is there any API that takes in the string and returns the specific file containing the string?
BASE_URL + "/rest/api/1.0/projects/" + PROJECT_KEY + "/repos/" + REPO_SLUG + "/files"
Hi @Sabyasachi Purkayastha
Currently, Bitbucket DC does not provide a search API that can search a string in a given project/repository. Instead, it communicates with the Search server by constructing a query based on parameters entered by the user in the UI search box and sending it to the Search server, which then provides the results to be displayed in the UI. Since the data resides on the Search server, you could potentially retrieve it directly, though this falls outside our support scope. Both ElasticSearch and OpenSearch offer search APIs you can utilize. You can refer to the ElasticSearch documentation or the OpenSearch documentation for examples on executing searches via API.
Regards,
Aman
Kindly assist @Theodora Boudale and others. Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.