https://restful.training was created to give you some experience with using RESTful APIs. It is an API for a basic blog that has articles, comments, and tags.
- Authentication
- End Points:
All requests should:
- Use the basename
https://restful.training/api/
- Be sent using JSON and with the
Accept: application/json
header. - Include an authentication token (see below)
In order to use the service you'll need to create an account. You only need to do this once.
POST https://restful.training/api/accounts
name
: your full namekey
: the password you've been given
name
: the name you providedapi_token
: your unique API token, write this down you'll need it for all other requests
You'll need to use your token for all requests.
For example, if your response was:
{
"name": "Jenny Flannigan",
"api_token": "15beab53cc8880738da99953d2f6ceffbe83418a"
}
All your requests should have the following header:
Authorization: Bearer 15beab53cc8880738da99953d2f6ceffbe83418a
Will return a list of all blog articles.
Does not include the full article text.
Will create a new blog article
title
: required, article titlecontent
: required, article contenttags
: an array of tags
Will return an article with the given id
Will update an entire existing article
title
: required, article titlecontent
: required, article contenttags
: an array of tags
Will update parts of an existing article
title
: article titlecontent
: article contenttags
: an array of tags
Will delete an existing article
Get the comments for an article
Add a comment to an article
email
: required, email of commentcomment
: required, comment content
List all tags
List all articles for a specific tag
Create and display animal facts.
Animal facts are shared between users, so don't add any facts you wouldn't be happy with other people seeing
Creates a new animal fact
fact
: required, string, maximum length 255made_up
: required, boolean
A random animal fact
fact
: a random factmade_up
: whether it's made upby
: who posted it
If there are no animal facts in the database a 204 No Content
response will be returned
Will return a list of all tasks.
Will create a new task
task
: required, task text
Will return the task with the given id
Will update a task
task
: required, the task text
Marks a task as complete
Will delete an existing task
Each user gets one counter
Will return your counter
Sets the count
value
count
: required, integer
Sets the step
value
step
: required, integer
Resets the counter
id
complete
: boolean - is the game overwinning_score
: integer - score to stop onchange_serve
: integer - how often to alternate serveplayer_1
: object - player 1 objectname
: string - namescore
: string - scoreserving
: bool - is this player serving?won
: bool - has this player won?
player_2
: object - player 2 objectname
: string - namescore
: string - scoreserving
: bool - is this player serving?won
: bool - has this player won?
All of the games that have been played, with the latest game first.
The specified game
Create a new game of ping-pong
player_1
: string - player 1 nameplayer_2
: string - player 2 namewinning_score
: optional integer - score to stop on (default: 21)change_serve
: optional integer - how often to alternate serve (default: 5)
Add one point to a player's score
player
: integer (1
|2
) - the player to add a point for
Delete a game of ping-pong