Back to Strategies API Documentation
Latest Forecast Endpoint
GET
.../api/v0/forecasts/latest/
This endpoint retrieves the latest forecast file from S3 for the authenticated
customer. The forecast is looked up in
<bucket>/<customer_name>/forecasts/YYYY/MM/DD/ — from
today going back, the most recently uploaded file in the first day that has
files is returned.
Authentication
This endpoint requires authentication using a Bearer token:
Authorization: Bearer <your_customer_token>
Parameters
| Parameter |
Type |
Location |
Required |
Description |
| format |
String |
Query String |
No |
json (default) — return parsed CSV as JSON array of
objects; csv — download the file as CSV with
Content-Disposition: attachment
|
Request Format
The request is a simple GET request. Include the Bearer token in the
Authorization header:
GET /api/v0/forecasts/latest/
Authorization: Bearer <your_token>
Or with CSV format:
GET /api/v0/forecasts/latest/?format=csv
Authorization: Bearer <your_token>
Response Format
Success Response (200 OK) — format=json (default)
Returns the CSV parsed as a JSON array of objects (one per row, with column
headers as keys):
[
{ "column1": "value1", "column2": "value2", ... },
...
]
Success Response (200 OK) — format=csv
Returns the raw CSV file with Content-Type: text/csv and
Content-Disposition: attachment; filename="forecast.csv"
Error Responses
Authentication Error (401 Unauthorized)
{ "detail": "Authentication credentials were not provided." }
Customer Name Missing (400 Bad Request)
{ "error": "Customer name not available." }
No Forecast Found (404 Not Found)
{ "error": "No forecast found for customer: <customer_name>" }
Server Error (500 Internal Server Error)
{ "error": "Failed to retrieve forecast." }
Example Usage
Here's an example of how to use this endpoint with curl:
curl -X GET \
"https://api.ravenwits.com/api/v0/forecasts/latest/" \
-H "Authorization: Bearer your_token_here"
For CSV download:
curl -X GET \
"https://api.ravenwits.com/api/v0/forecasts/latest/?format=csv" \
-H "Authorization: Bearer your_token_here" \
-o forecast.csv