📈 Crypto Price API

Historical + real-time BTC-USD prices. All timestamps are UNIX seconds (UTC).

Uptime: 13:29:34

GET /status

Returns API health, uptime, sync %, and remaining credits.

{
  "status": "ok",
  "uptime": "HH:MM:SS",
  "code": 200,
  "sync": "87.32%",
  "credits_remaining": 12345
}

GET /simplestatus

Lightweight health check.

{
  "status": "ok",
  "uptime": "HH:MM:SS",
  "sync": "87.32%",
  "code": 200
}

GET /latest

Returns the latest available timestamp in the database (midnight UTC). If the latest equals “yesterday 00:00 UTC”, it is normalized to “today 00:00 UTC”.

{
  "timestamp": 1368230400,
  "date": "2013-05-11 00:00:00+00:00"
}

GET /first

Returns the earliest available timestamp in the database (midnight UTC).

{
  "timestamp": 1264896000,
  "date": "2010-02-01 00:00:00+00:00"
}

GET /price Requires X-API-Key

Fetch a single price or a range.

Headers (choose one mode):

If X-Timestamp-End equals today 00:00 UTC, today’s in-memory mean is appended to the range response. If X-Timestamp equals today 00:00 UTC, the endpoint returns today’s running mean and includes the same timestamp (today’s midnight).

Responses:

Single timestamp (historical):

{
  "timestamp": 1368230400,
  "price": 124.56,
  "code": 200
}

Range:

{
  "data": [
    { "timestamp": 1368144000, "price": 120.10 },
    { "timestamp": 1368230400, "price": 124.56 }
  ],
  "code": 200
}

Errors:

{
  "error": "Unauthorized", "code": 401
}
{
  "error": "Timestamps must be integers", "code": 400
}
{
  "error": "Start timestamp cannot be after end timestamp", "code": 400
}
{
  "error": "Invalid timestamp", "code": 400
}
{
  "error": "No data found in the specified range", "code": 404
}
{
  "error": "No price found for timestamp", "code": 404
}
{
  "error": "Failed to fetch today's price", "code": 500
}

GET /currentprice Requires X-API-Key

Returns the current BTC-USD price from the live provider and updates today’s running mean.

{
  "timestamp": 1755046832,
  "price": 59321.42,
  "code": 200
}

Note: timestamp is “now” (UTC seconds). This endpoint mutates in-memory counters that feed todays_price_mean.

Made with ❤️ for BTC tracking