Badge API - bounswe/2021SpringGroup2 GitHub Wiki
GET 'api/badges/<badge_name>/'
-
Definition: Allows a user to fetch a badge by name
-
Example Response Value:
{ "@context": "https://www.wikidata.org/wiki/Q491", "type": "Badge", "name": "Friendly", "content": "This user is friendly towards other team players", "icon": { "type": "Image", "content":<base64_string> } }
-
Response Messages
- 200: OK
- 400: Bad request
GET 'api/badges/'
-
Definition: Allows a user to fetch all badges in the database
-
Example Response Value:
{ "@context": "https://www.w3.org/ns/activitystreams", "summary": "Badge list", "type": "Collection", "totalItems": 2, "items": [ { "object": { "type": "Badge", "name": "Friendly", "@context": "https://www.wikidata.org/wiki/Q491", "content": "This user is friendly towards other team players", "icon": { "type": "Image", "content":<base64_string> } } }, { "object": { "type": "Badge", "name": "Fair play", "@context": " https://www.wikidata.org/wiki/Q995616", "content": "This user plays fairly", "icon": { "type": "Image", "content":<base64_string> } } } ] }
-
Response Messages
- 200: OK
- 400: Bad request
GET 'api/users/<username>/related-events/'
-
Definition: Allows a user to fetch all events of the target user where the user can give a badge
-
Example Response Value:
{ "@context": "https://www.w3.org/ns/activitystreams", "summary": "Event list", "type": "Collection", "totalItems": 2, "items": [ { "object": { "type": "Event", "postId": 1, "title": "Beginner friendly tennis game", "eventSport": "Tennis", "eventDate": "2014-12-31T23 00 00-08 00" } }, { "object": { "type": "Event", "postId": 2, "title": "Beginner friendly football game", "eventSport": "Football", "eventDate": "2014-12-31T23 00 00-08 00" } } ] }
-
Parameters
Parameter Description Parameter Type Data Type target Username of the target user Path String -
Response Messages
- 200: OK
- 400: Bad request
POST 'api/users/<username>/badges/'
-
Definition: Allows a user to give a badge to another user
-
Example Response Value:
{
"@context": "https://www.w3.org/ns/activitystreams",
"summary": "Sally gave badge to Lewis",
"type": "Offer",
"actor": {
"type": "Person",
"name": "Sally",
"id": "1"
},
"object": {
"type": "Badge",
"name": "Friendly",
"attributedTo": [
{
"type": "Event",
"id": "2"
}
]
},
"target": {
"type": "Person",
"name": "Lewis",
"id": "2"
}
}
-
Parameters
Parameter Description Parameter Type Data Type target Username of the target user Path String badge_name Name of the badge to be given Body String event_id ID of the event where badge is awarded Body Integer -
Response Messages
- 201: OK
- 400: Bad request
- 404: Not found