The API provides the following endpoints:
GET /submissions/1/
200 OK
{
'url': 'https://api.redthat.com/submissions/1/',
'title': 'List of HTTP Status Codes',
'external_link': 'https://en.wikipedia.org/wiki/List_of_HTTP_status_codes',
'upvotes': 0,
'downvotes': 0
}
GET /submissions/
A paginated list of all submissions in the database
200 OK
{
'count': 1,
'next': null, # the URL for the next page of results
'previous': null, # the URL for the previous page of results
'results': [
{
'url': 'https://api.redthat.com/sumbmissions/1/',
'title': 'List of HTTP Status Code',
'external_link': 'https://en.wikipedia.org/wiki/List_of_HTTP_status_codes',
'upvotes': 0,
'downvotes': 0
},
...
]
}
POST /submissions/
Authorization: Token <token>
{
'external_link': 'http://www.django-rest-framework.org/api-guide/serializers'
}
201 Created
{
'url': 'https://api.redthat.com/submissions/2/',
'title': 'Serializers - Django REST Framework',
'external_link': 'http://www.django-rest-framework.org/api-guide/serializers',
'upvotes': 0,
'downvotes': 0
}
POST /get-token/
{
'email': 'username@example.com'
}
201 Created (or 200 OK if it already existed)
{
'token': 'abc123',
}
POST /submission/1/upvote/
Authorization: Token <token>
201 Created
{
'url': 'https://api.redthat.com/submissions/1/',
'title': 'List of HTTP Status Codes from Wikipedia', # updated
'external_link': 'https://en.wikipedia.org/wiki/List_of_HTTP_status_codes',
'upvotes': 1, # incremented
'downvotes': 0
}
POST /submission/1/downvote/
Authorization: Token <token>
201 Created
{
'url': 'https://api.redthat.com/submissions/1/',
'title': 'List of HTTP Status Codes from Wikipedia', # updated
'external_link': 'https://en.wikipedia.org/wiki/List_of_HTTP_status_codes',
'upvotes': 0,
'downvotes': 1 # incremented
}