Skip to content

AdamJ77/microblog

Repository files navigation

microblog

API

Installing API sources in development mode

pip install -e '.[dev]'

Running API

uvicorn api.app:create_app --host 127.0.0.1 --port 8000

Swagger UI will be available @ https://127.0.0.1:8000/docs

API response prototype

{
  "links": {
    "self": "https://microblog.com/posts?start=0&count=2",
    "next": "https://microblog.com/posts?start=2&count=5"
  },
  "data": [{
    "id": "65773e12ab916aacd90d2cf5",
    "type": "posts",
    "attributes": {
      "author": {
        "id": "213",
        "attributes": {
          "name": "Greg",
          "avatar": {
            "src": "https://microblog.com/users/avatars/Greg.png"
          }
        }
      },
      "body": "Bajojajo",
      "created": "2023-04-20T18:34:59.000Z",
      "media": []
    }
  }, {
    "id": "1f7c3713cb9c68b7d98d2c63",
    "type": "posts",
    "attributes": {
      "author": {
        "id": "411",
        "attributes": {
          "name": "Mediocrates",
          "avatar": {
            "src": "https://microblog.com/users/avatars/Mediocrates.png"
          }
        }
      },
      "body": "Eh... good enough",
      "created": "2023-11-07T23:20:47.000Z",
      "media": [{
          "type": "image",
          "src": "https://microblog.com/posts/13/image1.jpg"
        }, {
          "type": "video",
          "src": "https://microblog.com/posts/13/movie1.mp4"
        }
      ]
    }
  }]
}

API request prototype for adding a post

{
  "data": {
    "type": "posts",
    "attributes": {
      "body": "Bajojajo",
      "media": [{
          "type": "image",
          "src": "https://microblog.com/posts/13/image1.jpg"
      }]
    }
  }
}