---
# System prepended metadata

title: Simple price feeder task

---

# Simple price feeder task

## Simple solution for this interview
- Write a service/script to get price data from data source service and use that price for update on destination price feed service. (Price feed means price data should be up to date 24/7)
- If endpoint is not respond, try ping them first and it should work.

### Source
1. You can send **POST** request to send a request to get price from data source.
    -    Endpoint: https://interview-requester-source.herokuapp.com/request
    -    Example body (Please make sure it include header `Content-Type: application/json`)
    ```json
    {
        "symbols": ["BTC","ETH"]
    }
    ```
    -    Example response
    ```json
    {
        "id": 3
    }
    ```
2. Price data will available after request 3-5 seconds (need time to process similar to nature of blockchain), then you can query the price by sending **GET** request with your request id.
    -    Endpoint: `https://interview-requester-source.herokuapp.com/request/<id>`
    -    Example response
    ```json
    {
        "price_results": [
            {
                "multiplier": "1000000000",
                "px": "29905000000000",
                "request_id": "8519992",
                "resolve_time": "1653029738",
                "symbol": "BTC"
            },
            {
                "multiplier": "1000000000",
                "px": "2005290000000",
                "request_id": "8519992",
                "resolve_time": "1653029738",
                "symbol": "ETH"
            }
        ]
    }
    ```
### Destination
- You should send **POST** request to update price (Beware mulitplier of price)
    - Endpoint https://band-interview-destination.herokuapp.com/update
    - Example body (json)
    ```json
    {
        "symbols": ["BTC", "ETH"],
        "prices": [62753.28, 2438.03],
        "timestamp": 1618492842
    }
    ```
- If everything correct, you should able to query latest price by using this endpoint https://band-interview-destination.herokuapp.com/get_price?symbol=BTC

### Relay condition
- Your program need to update price to destination server with 2 condition
    1. If the latest price is delay more than 1 hour from current time, you need to update price.
    2. If the price difference between latest price and current price is more that 10% `(|(current price - latest price)/ latest price| > 0.1)`, you need to update price immediately. (Should be update in 1 minute or less)
