Skip to content

andrewpearce-digital/python-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python-ReST-API

A python ReST API using flask and dynamodb.

Based on Jake Wright's excellent video and home automation project https://youtu.be/4T5Gnrmzjak

Starting the ReST API service

Start the service using docker-compose

docker-compose build
docker-compose up

The project will be running on localhost:5000

Run integration tests with

python -m pytest -v

Usage

All responses will have the form

{
    "data": "Mixed type holding the content of the response",
    "message": "Description of what happened"
}

Subsequent response definitions will only detail the expected value of the data field

List all items

Definition

GET /items

Response

  • 200 OK on success
[
    {
        "identifier": "first",
        "name": "First Item"
    },
    {
        "identifier": "second",
        "name": "Second Item"
    }
]

Adding a new item

Definition

POST /items

Arguments

  • "identifier":string a globally unique identifier for this item
  • "name":string a friendly name for this item

If an item with the given identifier already exists, the existing device will be overwritten.

Response

  • 201 Created on success
{
    "identifier": "third",
    "name": "Third Item"
}

Lookup item details

GET /item/<identifier>

Response

  • 404 Not Found if the device does not exist
  • 200 OK on success
{
    "identifier": "third",
    "name": "Third Item"
}

Delete an item

Definition

DELETE /item/<identifier>

Response

  • 204 No Content

About

A simple python rest api that uses flask and dynamodb

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published