Skip to content

codingfrog/demo-hiring-sr-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Python Coding Test: Orders API

🎯 Goal

Build a simple Python API that:

  1. Loads data from two JSON files: order_lines.json and products.json.
  2. Joins them to enrich each order line with product details.
  3. Returns filtered order lines via an API endpoint based on a product_id query parameter.
  4. Secures the endpoint with a basic API key check.

📋 Requirements

  • Use Flask or FastAPI.
  • Store JSON files in the data/ directory.
  • Secure the API using a static API key: test123
  • Run locally with python main.py or equivalent.
  • Handle edge cases appropriately (missing product_id, invalid API key, etc.).

📁 Project Structure

python-coding-test/
├── data/
│   ├── order_lines.json
│   └── products.json
├── README.md
└── main.py  (you will implement this)

🔧 Example Request

curl "http://localhost:8000/orders?product_id=555"

Note: The API requires authentication with API key test123. You'll need to determine how to implement the API key validation.

📤 Example Response

[
  {
    "order_id": 101,
    "product_id": 555,
    "quantity": 2,
    "product_name": "Blue T-Shirt",
    "price": 25.00
  },
  {
    "order_id": 103,
    "product_id": 555,
    "quantity": 3,
    "product_name": "Blue T-Shirt",
    "price": 25.00
  },
  {
    "order_id": 106,
    "product_id": 555,
    "quantity": 1,
    "product_name": "Blue T-Shirt",
    "price": 25.00
  }
]

🚀 Getting Started

  1. Review the data files in the data/ directory to understand the structure.
  2. Implement main.py according to the requirements above.
  3. Test your implementation using the example request.
  4. Ensure your code handles edge cases gracefully.

💡 Additional Considerations

  • What happens when product_id is not provided?
  • What happens when product_id doesn't match any orders?
  • What happens when the API key is missing or incorrect?
  • How will you implement API key authentication?
  • Consider error handling and appropriate HTTP status codes.
  • Think about code organization and readability.

🤖 AI Assistance Option

You have two options for completing this test:

Option 1: Complete Independently

Work on this test without AI assistance. This allows us to evaluate your direct coding skills, problem-solving approach, and Python expertise.

Option 2: Use AI Assistance

You may use AI tools (ChatGPT, GitHub Copilot, Cursor, etc.) to help you complete this test. This is completely acceptable and encouraged if it reflects how you would work in a real development environment.

If you choose Option 2:

  • Use AI assistance in whatever way feels natural to your workflow
  • We'll discuss your process and approach during the review
  • Please indicate in your submission which option you chose and, if using AI assistance, briefly describe how you used it

📝 Submission

Once complete, please share:

  • Your main.py file
  • Any additional files you created (requirements.txt, etc.)
  • A brief note on your approach and any assumptions you made
  • Whether you used AI assistance and how (if applicable)

⏱️ Time Estimate

This test is designed to take approximately 1-2 hours, depending on your approach and whether you use AI assistance.

Good luck!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages