Giter Club home page Giter Club logo

yatube_api_en's Introduction

Yatube API Educational Project

Are you kiddin' me? Another educational project?

Exactly! Implementation of REST API for a sample Django project using DRF. The task was to create an API based on redoc-based documentation from scratch: models, request routing, serialization, permissions, JWT, and so on.

After installation, you'll be able to read the docs and test the project, using a built-in web interface, or some kind of software (I would recommend PostMan)

Technology stack

  • Python 3.7.13, Django 2.2.16, Django REST Framework 3.12.4, SimpleJWT 4.7.2, PyJWT 2.1.0, Djoser 2.1.0, Pillow 9.2.0, drf-yasg 1.21.4

Key points

  • This implementation is built on viewsets.
  • JWT tokens are used for authentication.
  • Read-only access for unauthenticated users to all endpoints except for /follow/.
  • Authenticated users are allowed to modify/delete their content, and read-only access in all other cases.

Installation

git clone https://github.com/holohup/yatube_api_en && cd yatube_api_en && ./yatube_api_install.sh

The project comes preloaded with some fixtures which are installed on the script execution. There's a registered admin user tester/tester, the admin web interface is accessible at http://127.0.0.1:8000/admin/

You can register a new user from there, or use the admin credentials to get a token by sending a POST request to http://127.0.0.1:8000/api/v1/jwt/create/ containing a JSON:

{
    "username": "string",
    "password": "string"
}

The JWT token will be under the key named "access". After that, set up your software to use it and explore the API at your will!

Every single Endpoint (how the project should work and how it does, on yes)

Choose a link to learn which requests it should accept, which responses it returns, and all the necessary details in a preferred format:

How it works

sequenceDiagram
User ->> API: Would you please delete this post?
API ->> Server: Post deletion service needed immediately!
Server ->> Database: Delete the post ASAP! Code red!
Database ->> Server: Fixed :-Q
Server ->> API: The post has been deleted, what's next?
API ->> User: Oh mighty one! It's done, please accept this 204 status code.

Request examples

  • get post comments

/api/v1/posts/{post_id}/comments/{id}/

Response:

{
-   "id": 0,   
-   "author": "string", 
-   "text": "string",  
-   "created": "2019-08-24T14:15:22Z",  
-   "post": 0
}

Feel free to send all allowed kinds of requests and test my solution back and forth!

yatube_api_en's People

Contributors

holohup avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.