Hacker News new | ask | show | jobs
by sdesol 3338 days ago
@sqs

Since you are posting in here, I figure I would ask. Are there plans to provide an API for Sourcegraph in the near future? My product is more focused on code history discovery and I was thinking it would be nice to be able to quickly transition into Sourcegraph for code browsing and search/analysis.

The discovery workflow would go something like this:

https://gitsense.com/media/source-graph-integration.mp4

For the API, it would nice to be able to just query Sourcegraph to see if the tree for that commit has been indexed and is searchable.

2 comments

We do have an API available to customers running Sourcegraph internally. We plan to open it up to users of Sourcegraph.com in the future, but I don't have a date for that.

In the meantime, URLs like the following will stay around forever:

https://sourcegraph.com/REPO@GITREV/-/blob/DIR/FILE#L123

And there is no indexing step required (except for the initial clone), so you don't need to query for that. Sourcegraph's code analysis is realtime.

Feel free to email if you want more info! sqs@sourcegraph.com

This is definitely not a documented "API" but if you want to take the user to sourcegraph for a specific repo/file:line@commit then the url (currently) is:

sourcegraph.com/[repo]@[commit]/-/blob/[path/file]#L[line]

afaik repo must be on github.com (iirc bitbucket and GCP support was in the works) and commit can be either an absolute commit hash or a relative one like a branch name.

ie. https://sourcegraph.com/github.com/gorilla/mux@master/-/blob...