REST API for Code Search #13155

Open
opened 2025-11-02 10:33:00 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @kremerd on GitHub (Jun 14, 2024).

Feature Description

One of Giteas best features is the blazing fast indexed full text search available at /explore/code. Unfortunately it seems that there is no REST API to access this feature programmatically. Such an API would be very useful to visualize results or present them in some other way.

Therefore I propose to introduce a new REST API

GET /api/v1/version/code?q=<queryString>&t=<fuzzy>&page=<pageNumber>&limit=<pageSize>

It should return a list of search results, containing at least the matched repository, file path, line number und line content

[{
    "repository": "my-repository",
    "path": "src/test/resources/strings.properties",
    "lineNumber": 255,
    "line": "TEXT=Lorem ipsum solor delet"
}]

Screenshots

No response

Originally created by @kremerd on GitHub (Jun 14, 2024). ### Feature Description One of Giteas best features is the blazing fast indexed full text search available at /explore/code. Unfortunately it seems that there is no REST API to access this feature programmatically. Such an API would be very useful to visualize results or present them in some other way. Therefore I propose to introduce a new REST API GET /api/v1/version/code?q=<queryString>&t=<fuzzy>&page=<pageNumber>&limit=<pageSize> It should return a list of search results, containing at least the matched repository, file path, line number und line content [{ "repository": "my-repository", "path": "src/test/resources/strings.properties", "lineNumber": 255, "line": "TEXT=Lorem ipsum solor delet" }] ### Screenshots _No response_
GiteaMirror added the topic/apitype/proposal labels 2025-11-02 10:33:00 -06:00
Author
Owner

@knudtty commented on GitHub (Jun 28, 2024):

I've put out a PR for this feature. It required refactoring the existing code search related modules in addition to adding new files for the api route. I decided to duplicate much of the web/explore/code.go function and adapt it for the API rather than a large refactor.

@knudtty commented on GitHub (Jun 28, 2024): I've put out a PR for this feature. It required refactoring the existing code search related modules in addition to adding new files for the api route. I decided to duplicate much of the web/explore/code.go function and adapt it for the API rather than a large refactor.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13155