-
Notifications
You must be signed in to change notification settings - Fork 6
Search API
Megan-VanHumbeck edited this page Mar 9, 2018
·
1 revision
A search finds all questions whose title contains any word found within the search string. The structure returned will be an array of questions.
[
{"id": 100, "title": 'How does Questions API work?', "text": 'I want to know!', ...},
{"id": 101, "title": 'Questions in a list?', "text": 'Same as title', ...},
{"id": 102, "title": 'I can question?', "text": 'blah blah blah', ...}
]
For example in a programming language like JavaScript or Python if the variable questionsArray
contained a questions object we might access the text the first question:
# JS:
questionsArray[0].text
# Python:
questionsArray[0]['text']
In this case it will return 'I want to know!'. Remember these objects are JSON. In Python they map to dict
and in JavaScript they map to object
.
route: /api/search/
Note below that * indicates the data is optional. sort
can be any string of the keys of the question
object, example sort="ups"
.
HTTP Requests | Description of Action | Expected Data from Front-End | Response (JSON) |
---|---|---|---|
POST | Finds matching questions. | searchString | success, status, message, *questions |