blog_web_api /

Filename Size Date modified Message
28 B
5 B
5.9 KB
921 B
17 B
1.1 KB
3.1 KB

Try it out


Url Http method Parameters Description
/user/create POST username / password Create a user.
/user/login POST username / password Get an authentication token.
/user/remove POST username / password Remove an existing user (and all his posts).
/user/change_password POST username / password / newPassword Change the password.
/user/invalidate_tokens POST username / password Invalidate all of the user's previous tokens. Returns a new one.
/user/getall GET Get a list with all the users.
/user/random GET Get a random user.
/blog/add POST token / title / body Add a post to the blog.
/blog/get/:blogId GET Get a specific blog post.
/blog/remove POST token / blogId Remove a blog post.
/blog/update POST token / title / body / blogId Update an existing blog post.
/blog/:username/getall GET Get all the blog posts of a specific user.
/blog/random GET Get a random blog post.
/blog/getall GET Get a list with all blog ids available.

Usage Example

Use either http://localhost:8000 (when testing locally) or the url (live server).



To try out the application locally, first install swift and redis, then run:

  • redis-server
  • swift run

Now you can use curl for example to make requests.


Start the database (redis-server) and the application (swift run) and then run the tests.

  • python3 Tests/

Relevant Commands

Command Description
redis-cli Redis client for testing purposes.
redis-server Start the redis server.
swift package update Update all dependencies to latest version.
swift run Compile and run the server.
python3 Tests/ Run the tests.
autopep8 --in-place Tests/ Run the auto-formatter for the tests.
git push heroku master Deploy to heroku.

Database Keys

Key Description Data Type
LAST_POST_ID ID of the last post. Integer
user_* User information. Hash
users Set with all the usernames. Set
user_posts_* Set of IDs of posts made by this user. Set
user_tokens_* Set with all the tokens of a given user. Set
token_* Authentication token. String
post_* Blog post information. Hash
posts All post IDs. Set