cdancy/bitbucket-rest

Feature: Search API

Closed this issue · 1 comments

This is a Feature Request

Expected Behavior

This Bitbucket REST API Client implementation should provide the Search API Feature

Current Behavior

Not implemented

Context

It's not officially documented - at least I couldn't find something? But there is a Search API that gets called from the Bitbucket Server Frontend when doing a Search (e.g. across all repos). So, the API is not like the others under /rest/api/... but under /rest/search/....
There is a workaround to search via REST by calling Elasticsearch directly https://community.atlassian.com/t5/Bitbucket-questions/Rest-API-to-search-a-string-in-all-the-repositories-in-Bitbucket/qaq-p/900814.
But in my case I don't have access to ES or port 9200 on the Bitbucket Server.

Working CURL example; tested on our Bitbucket Server v7.3.1:

curl --location --request POST 'https://<your-bitbucket-server>/rest/search/1.0/search' \
--header 'Accept: application/json' \
--header 'Authorization: Basic <base64-of:username:personal-access-token>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "query": "<my-search-phrase>",
  "entities": {
    "code": {}
  },
  "limits": {
    "primary": 25,
    "secondary": 10
  }
}'

Your Environment

Tested on Atlassian Bitbucket Server 7.3.1 with API-versions 1.0 and latest.

Documentation of Search feature from a GUI point of view: https://confluence.atlassian.com/bitbucketserver/search-for-code-in-bitbucket-server-814204781.html. The search syntax can be passed in the query field of the request.