Giter VIP home page Giter VIP logo

api_foryatubehelp's Introduction

api для социальной сети

API соцсети, позволяющий добавлять записи, комментировать, подписываться на пользователей.

Технологии:

Python, Django, DRF, JWT

Как запустить проект:

Клонировать репозиторий и перейти в него в командной строке:

git clone [email protected]:CrockoMan/api_foryatubehelp.git
cd api_foryatubehelp

Cоздать и активировать виртуальное окружение:

python3 -m venv env
source env/bin/activate

Установить зависимости из файла requirements.txt:

python3 -m pip install --upgrade pip
pip install -r requirements.txt

Выполнить миграции:

python3 manage.py migrate

Запустить проект:

python3 manage.py runserver

Работа с постами:
http://127.0.0.1:8000/api/v1/posts/

GET Получить список публикаций.
Response:
{
  "count": 123,
  "results": [
    {
      "id": 0,
      "author": "string",
      "text": "string",
      "pub_date": "2023-10-08T13:50:35.424Z",
      "image": "string",
      "group": 0
    }
  ]
}
При указании limit и offset выдача будет с  пагинацией, при наличии достаточного количества записей для пагинации
Response:
{
  "count": 123,
  "next": "http://api.example.org/accounts/?offset=400&limit=100",
  "previous": "http://api.example.org/accounts/?offset=200&limit=100",
  "results": [
    {
      "id": 0,
      "author": "string",
      "text": "string",
      "pub_date": "2023-10-08T13:50:35.424Z",
      "image": "string",
      "group": 0
    }
  ]
}
POST: Добавить публикацию
{
  "text": "string",
  "image": "string",
  "group": 0
}
Response:
{
  "id": 0,
  "author": "string",
  "text": "string",
  "pub_date": "2023-10-08T13:52:53.162Z",
  "image": "string",
  "group": 0
}

http://127.0.0.1:8000/api/v1/posts/{id}/ - Работа с постом {id}

http://127.0.0.1:8000/api/v1/posts/{id}/
GET
Response:
{
  "id": 0,
  "author": "string",
  "text": "string",
  "pub_date": "2023-10-08T13:54:21.976Z",
  "image": "string",
  "group": 0
}
PUT PATCH
{
  "text": "string",
  "image": "string",
  "group": 0
}
Response:
{
  "id": 0,
  "author": "string",
  "text": "string",
  "pub_date": "2023-10-08T13:54:21.979Z",
  "image": "string",
  "group": 0
}
DELETE
No response body

Работа с комментариями осуществляется по id поста, к которому опубликован/публикуется комментарий, например:
http://127.0.0.1:8000/api/v1/posts/{id}/comments/ - работа с комментариями поста id

GET
Response:
[
  {
    "id": 0,
    "author": "string",
    "text": "string",
    "created": "2023-10-08T14:01:43.545Z",
    "post": 0
  }
]
POST
{
  "text": "string"
}
Response:
{
  "id": 0,
  "author": "string",
  "text": "string",
  "created": "2023-10-08T14:02:11.024Z",
  "post": 0
}

http://127.0.0.1:8000/api/v1/posts/{id}/comments/{id} - При указании id поста и id комментария, возможна работа с комментарием

GET
Response:
{
  "id": 0,
  "author": "string",
  "text": "string",
  "created": "2023-10-08T14:04:24.189Z",
  "post": 0
}
PUT
{
  "text": "string"
}
Response:
{
  "id": 0,
  "author": "string",
  "text": "string",
  "created": "2023-10-08T14:04:45.939Z",
  "post": 0
}
DELETE
No response body

Работа с группами:
http://127.0.0.1:8000/api/v1/groups/

GET Получить список групп.
Response:
[
  {
    "id": 0,
    "title": "string",
    "slug": "ciYncA_9Go1aRPdDJpHtss2cZafcNoPO3k_8YUXSNUmoWkRvqw",
    "description": "string"
  }
]

http://127.0.0.1:8000/api/v1/groups/{id}/

GET Получить группу.
Response:
{
  "id": 0,
  "title": "string",
  "slug": "ktSquiMZl2Cu4PxgxWqEoocBkysxQrofmZgDGUk4-0NNFUmWqE",
  "description": "string"
}

Работа с подписками:
http://127.0.0.1:8000/api/v1/follow/

GET Получить список подписок.
Response:
[
  {
    "user": "string",
    "following": "string"
  }
]
POST Подписаться
{
  "following": "string"
}
Response:
{
  "user": "string",
  "following": "string"
}

Автор: К.Гурашкин

api_foryatubehelp's People

Contributors

crockoman 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.