Introduction
Welcome to the Grepper API! Grepper allows you to quickly search, add and edit code snippets & technical answers to all those little coding problems you run into every day (It’s Basically stackoverflow, but tightly integrated into your workflow… and without the overzealous moderators…).
This API is a work in progress and we are calling on all community members to help build it out. Specifically we need language bindings/client libraries for [Javascript, Python, Java, Go, .NET, Node, Ruby]. We also want feature requests from the community, so we can unlock all the value of Grepper through this API.
Note: You will need a grepper account, after creating an account you can find your api key here
You can hit the API endpoints directly or use one of our API client libraries:
Language | Github Repo | Status | Notes |
---|---|---|---|
PHP | grepper-php | In Progress | Authors: Taylor Hawkes |
Javascript | grepper-javascript | Need Contributors | Authors: TBD |
Python | grepper-python | Need Contributors | Authors: TBD |
Node | grepper-node | Need Contributors | Authors: TBD |
Go | grepper-go | Need Contributors | Authors: TBD |
Here is an example of doing a grepper search through the api:
curl https://api.grepper.com/v1/answers/search \
-u your_grepper_api_key_here: \
--data-urlencode query="javascript loop array backwords" \
-G
Authentication
The Grepper API uses API keys to authenticate requests. You can view and manage your API key in your Grepper Account Settings.
Authentication to the API is performed via HTTP Basic Auth. Provide your API key as the basic auth username value. You do not need to provide a password.
If you need to authenticate via bearer auth (e.g., for a cross-origin request), use -H "Authorization: Bearer youapikeyhere" instead of -u youapikeyhere.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.
Answers
Search All Answers
curl https://api.grepper.com/v1/answers/search \
-u your_grepper_api_key_here: \
--data-urlencode query="javascript loop array backwords" \
-G
$grepper = new \Grepper\GrepperClient(
'your_api_key_here'
);
$grepper->answers->search([
'query' => 'javascript loop array backwords',
]);
Response:
{
"object": "list",
"data": [
{
"id": 560676,
"content": "let arr = [1, 2, 3];\n\narr.slice().reverse().forEach(x => console.log(x))\n Run code snippetHide results",
"author_name": "Homely Hyena",
"author_profile_url": "https://www.grepper.com/profile/homely-hyena-qrcy8ksj0gew",
"title": "javascript loop through array backwords",
"upvotes": 0,
"object": "answer",
"downvotes": 0
},
{
"id": 504956,
"content": "var arr=[1,2,3];\narr.reverse().forEach(x=> console.log(x))",
"author_name": "Yanislav Ivanov",
"author_profile_url": "https://www.grepper.com/profile/yanislav-ivanov-r2lfrl14s6xy",
"title": "js loop array back",
"upvotes": 2,
"object": "answer",
"downvotes": 2
}
]
}
This endpoint searches all answers based on a query.
HTTP Request
GET https://api.grepper.com/v1/answers/search
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
query | true | false | query to search through answer titles ex: "Javascript loop array backwords" |
similarity | false | 60 | How similar the query has to be to the answer title. 1-100 where 1 is really loose matching and 100 is really strict/tight match. |
Retreive an Answer
curl https://api.grepper.com/v1/answers/560676 \
-u your_api_key_here:
$grepper = new \Grepper\GrepperClient(
'your_api_key_here'
);
$answer=$stripe->answers->retrieve(560676);
Response:
{
"id": 560676,
"content": "let arr = [1, 2, 3];\n\narr.slice().reverse().forEach(x => console.log(x))\n Run code snippetHide results",
"author_name": "Homely Hyena",
"author_profile_url": "https://www.grepper.com/profile/homely-hyena-qrcy8ksj0gew",
"title": "javascript loop through array backwords",
"upvotes": 0,
"object": "answer",
"downvotes": 0
}
This endpoint retrieves a specific answer.
HTTP Request
GET https://api.grepper.com/v1/answers/:id
URL Parameters
Parameter | Description |
---|---|
id | The answer id of the answer to retrieve |
Update a specific answer
import kittn
api = kittn.authorize('meowmeowmeow')
api.kittens.delete(2)
curl https://api.grepper.com/v1/answers/560676 \
-u your_api_key_here: \
-d "answer[content]"="new answer content here"
$grepper = new \Grepper\GrepperClient(
'your_api_key_here'
);
$grepper->answers->update(
'560676',
['answer' => ['content' => 'new answer content here']]
);
The above command returns JSON structured like this:
{
"id": 2,
"success" : "true"
}
This endpoint updates a specific answer.
HTTP Request
POST https://api.grepper.com/v1/answers/:id
URL Parameters
Parameter | Description |
---|---|
id | The answer id of the answer to update |
Errors
The Grepper API uses the following error codes:
Error Code | Meaning |
---|---|
400 | Bad Request -- Your request is invalid. |
401 | Unauthorized -- Your API key is wrong. |
403 | Forbidden -- You do not have access to the requested resource. |
404 | Not Found -- The specified enpoint could not be found. |
405 | Method Not Allowed -- You tried to access an enpoint with an invalid method. |
429 | Too Many Requests -- You're making too many requests! Slow down! |
500 | Internal Server Error -- We had a problem with our server. Try again later. |
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. |