Search code examples
performancegithubgithub-api

GitHub REST API: Get issue based only on title


I need to modify the body of an existing GitHub issue in a Project. All I'll be passed is the title of the issue, and a word (the word exists in the body, and I'll just need to fill the checkbox next it). It looks like to do this I'll need to use this GET endpoint to get the body of the issue, modify it, and then use this endpoint to swap in the new body. However the GET API can only be called with the issue number. I need to do all this as quickly as possible. Is there some way to search via an API call?

Thoughts much appreciated!

Edit: All my issues are in the same project (and issue titles will be unique there). I've also recently discovered GitHub's GraphQL API, which may be applicable here.


Solution

  • You can use the issue search endpoint with the in and repo¹ keywords:

    GET /search/issues?q=text+to+search+in:title+repo:some/repo
    

    Of course, issue titles aren't guaranteed to be unique. You'll have to request each of the issues that comes back and see if its body contains the word you're looking for. Even in that case you could get multiple positive results.

    It would be much better if you could search by issue number.


    ¹I've assumed that you really mean "repository" when you say "project". But if you're actually talking about GitHub Project Boards you can use the project keyword as well or instead.