5

Is it possible to use the Stack Exchange V2.2 API to search answers to questions to see if an answer contains a certain string? For example, I want to send over a line of code to see if it has been copied from an answer, without knowing the question or having any other context about the question.

1 Answer 1

8

The easiest way is just to use the search page and include the term is:answer (from the help page on searching), e.g. this query returns only answers containing NullPointerException.

It is possible to use the API for this; the q parameter supports (roughly) the same syntax as the search box on the site. You can experiment on this page to see what URL you need; the URL corresponding to the search above is https://api.stackexchange.com/2.2/search/excerpts?order=desc&sort=activity&q=NullPointerException%20is%3Aanswer&site=stackoverflow.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .