Skip to content

carlota-moh/store-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Store API

Small practice project for a store API, created using Flask. Done following the "Flask REST API" section of the "REST APIs with Flask and Python in 2025 " course on Udemy.

The API allows users to:

  • Create, retrieve, and delete stores (each store has a unique ID and name)
  • Create, retrieve, update, and delete items (each item has a unique ID, name, price, and associated store_id)
  • List all stores or all items
  • Retrieve individual stores or items by ID

Installation

Running the app locally

Prerequisites

  • Python 3.10 or higher
  • pip (Python package manager)
  1. Create a virtual environment (optional, recommended)

    python -m venv venv
    source venv/bin/activate  # On Windows use: venv\Scripts\activate
  2. Install dependencies

    pip install -r requirements.txt
  3. Configure environment variables

    Copy the example environment file and update if needed:

    cp .flaskenv.example .flaskenv
  4. Run the Flask application

    flask run

The API will be available at http://127.0.0.1:5000

Running using Docker

Prerequisites

  • Docker installed on your machine
  1. Build the Docker image

    docker build -t store-api .
  2. Run the container

    docker run -dp 5000:5000 --name store-api-app store-api

The API will be available at http://localhost:5000

![NOTE] To run the container with autoload and debugging enabled, use the following command instead:

docker run -dp 5000:5000 -v "$(pwd):/app" --name store-api

API Endpoints

Stores

  • GET /stores - Get all stores
  • GET /stores/<store_id> - Get a specific store by ID
  • POST /stores - Create a new store
  • DELETE /stores/<store_id> - Delete a store

Items

  • GET /items - Get all items
  • GET /items/<item_id> - Get a specific item by ID
  • POST /items - Create a new item
  • PUT /items/<item_id> - Update an item
  • DELETE /items/<item_id> - Delete an item

Other

  • GET / - Home endpoint

Example Usage

Create a new store:

curl -X POST http://localhost:5000/stores -H "Content-Type: application/json" -d '{"name": "My Store"}'

Get all stores:

curl http://localhost:5000/stores

Create an item:

curl -X POST http://localhost:5000/items -H "Content-Type: application/json" -d '{"name": "Chair", "price": 19.99, "store_id": "<store_id>"}'

Get all items:

curl http://localhost:5000/items

Update an item:

curl -X PUT http://localhost:5000/items/<item_id> -H "Content-Type: application/json" -d '{"name": "Updated Chair", "price": 24.99}'

Delete an item:

curl -X DELETE http://localhost:5000/items/<item_id>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors