This repository has been archived by the owner on Aug 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Badges
Adrien Pétremann edited this page Jun 28, 2016
·
4 revisions
As an authenticated user, visible badges are limited to the tags you belong to.
You can't update, delete nor give a badge unless you are authenticated as an admin.
You need to be an administrator to do this.
POST /badges
Name | Type | Description |
---|---|---|
title |
string |
Required. Title of the badge. |
description |
string |
Required. A description of the badge, on how to obtain it. |
tags |
array of strings
|
Array of tag codes the badge will belong to. Every users that belong to at least one of this tags will be able to see this badge. |
{
"title": "Say 'What' Again",
"description": "To unlock this badge, say 'what' again, I dare you.",
"tags": [
"community",
"movie"
]
}
Status: 201 Created
Location: https://api.badger.local/badges/1265f62f-f4ff-11e5-832b-b86b23bc0685
{
"id": "1265f62f-f4ff-11e5-832b-b86b23bc0685",
"url": "https://api.badger.local/badges/1265f62f-f4ff-11e5-832b-b86b23bc0685",
"image_url": "https://api.badger.local/uploads/badges/1265f62f-f4ff-11e5-832b-b86b23bc0685.png",
"title": "Say What Again",
"description": "To unlock this badge, say what again, I dare you.",
"tags": [
{
"url": "https://api.badger.local/tags/community",
"name": "Community",
"code": "community",
"created_at": "2011-04-10T20:09:31Z",
"is_default": true
},
{
"url": "https://api.badger.local/tags/movie",
"name": "Movie",
"code": "movie",
"created_at": "2012-07-11T20:00:34Z",
"is_default": false
}
],
"possessors": []
}
Note that administrators can see all badges, regardless of tags they belong to.
GET /badges
Name | Type | Description |
---|---|---|
filter |
string |
Indicates which sorts of badges to return. Can be one of: * unlocked : Badges you unlocked* claimed : Badges claimed by you* all : All badges the authenticated user can see, regardless of claim or unlockDefault: all
|
tags |
string |
A list of comma separated tag codes. Example: community,movie,game
|
sort |
string |
What to sort results by. Can be either name , description . Default: name
|
direction |
string |
The direction of the sort. Can be either asc or desc . Default: desc
|
Status: 200 OK
Link: <https://api.badger.local/badges?page=2>; rel="next",
<https://api.badger.local/badges?page=5>; rel="last"
[
{
"id": "f5e3fb6f-f52d-11e5-832b-b86b23bc0685",
"url": "https://api.badger.local/badges/f5e3fb6f-f52d-11e5-832b-b86b23bc0685",
"image_url": "https://api.badger.local/uploads/badges/f5e3fb6f-f52d-11e5-832b-b86b23bc0685.png",
"title": "Master of Potatoes",
"description": "You built a machine with at least 250 potatoes.",
"tags": [
{
"url": "https://api.badger.local/tags/game",
"name": "Game",
"code": "game",
"created_at": "2011-04-10T20:09:31Z",
"is_default": false
}
],
"possessors_url": "https://api.badger.local/badges/f5e3fb6f-f52d-11e5-832b-b86b23bc0685/possessors"
}
]
GET /badges/123
Status: 200 OK
{
"id": "f5e3fb6f-f52d-11e5-832b-b86b23bc0685",
"url": "https://api.badger.local/badges/f5e3fb6f-f52d-11e5-832b-b86b23bc0685",
"image_url": "https://api.badger.local/uploads/badges/f5e3fb6f-f52d-11e5-832b-b86b23bc0685.png",
"title": "Master of Potatoes",
"description": "You built a machine with at least 250 potatoes.",
"tags": [
{
"url": "https://api.badger.local/tags/game",
"name": "Game",
"code": "game",
"created_at": "2011-04-10T20:09:31Z",
"is_default": false
}
],
"possessors": [
{
"username": "bender",
"id": "a42ba74c-f205-11e5-a7ca-b86b23bc0685",
"url": "https://api.badger.local/users/a42ba74c-f205-11e5-a7ca-b86b23bc0685",
"avatar_url": "https://avatars0.githubusercontent.com/u/301169?v=3&s=460",
"badges_url": "https://api.badger.local/users/a42ba74c-f205-11e5-a7ca-b86b23bc0685/badges",
"quests_url": "https://api.badger.local/users/a42ba74c-f205-11e5-a7ca-b86b23bc0685/quests",
"adventures_url": "https://api.badger.local/users/a42ba74c-f205-11e5-a7ca-b86b23bc0685/adventures",
"nuts": 225
}
]
}
Only administrators can edit a badge.
PATCH /badges/123
Name | Type | Description |
---|---|---|
title |
string |
Required. Title of the badge. |
description |
string |
Required. A description of the badge, on how to obtain it. |
tags |
array of strings
|
Array of tag codes the badge will belong to. Every users that belong to at least one of this tags will be able to see this badge. |
{
"title": "Say 'What' Again",
"description": "To unlock this badge, say 'what' again, I dare you.",
"tags": [
"community",
"movie",
"legendary"
]
}
Status: 200 OK
{
"id": "1265f62f-f4ff-11e5-832b-b86b23bc0685",
"url": "https://api.badger.local/badges/1265f62f-f4ff-11e5-832b-b86b23bc0685",
"image_url": "https://api.badger.local/uploads/badges/1265f62f-f4ff-11e5-832b-b86b23bc0685.png",
"title": "Say What Again",
"description": "To unlock this badge, say what again, I dare you.",
"tags": [
{
"url": "https://api.badger.local/tags/community",
"name": "Community",
"code": "community",
"created_at": "2011-04-10T20:09:31Z",
"is_default": true
},
{
"url": "https://api.badger.local/tags/movie",
"name": "Movie",
"code": "movie",
"created_at": "2012-07-11T20:00:34Z",
"is_default": false
},
{
"url": "https://api.badger.local/tags/legendary",
"name": "Legendary",
"code": "legendary",
"created_at": "2012-07-11T20:00:34Z",
"is_default": false
}
],
"possessors": [
{
"username": "bender",
"id": "a42ba74c-f205-11e5-a7ca-b86b23bc0685",
"url": "https://api.badger.local/users/a42ba74c-f205-11e5-a7ca-b86b23bc0685",
"avatar_url": "https://avatars0.githubusercontent.com/u/301169?v=3&s=460",
"badges_url": "https://api.badger.local/users/a42ba74c-f205-11e5-a7ca-b86b23bc0685/badges",
"quests_url": "https://api.badger.local/users/a42ba74c-f205-11e5-a7ca-b86b23bc0685/quests",
"adventures_url": "https://api.badger.local/users/a42ba74c-f205-11e5-a7ca-b86b23bc0685/adventures",
"nuts": 225
}
]
}