Skip to main content

🧩 Script Endpoints

Each script on Fuyu has its own API endpoint, allowing you to programmatically fetch the latest results.

This is useful when you want to treat a script like a microservice β€” trigger it on a schedule or fetch its output on demand.


πŸ“₯ Getting Results for a Script​

Each script has a unique ID. You can retrieve its latest result with:

GET /api/scripts/:id/results

Example:

curl "https://fuyu.gg/api/scripts/abc123/results?includeStats=true" \
-H "x-api-key: api_abc123.xyz456"

πŸ“„ Response Example​

{
"data": [
{
"title": "German and U.K. Leaders Sign Mutual Defense Pact as U.S. Steps Back",
"content": "The new treaty includes a pledge by both countries to regard a threat against one as a threat against the other..."
},
{
"title": "The U.K. Plans to Lower the Voting Age to 16. Here’s What to Know.",
"content": "The plan has been described as the largest expansion of voting rights in Britain in decades."
}
],
"execution": {
"started_at": "2025-07-18T02:02:12.708Z",
"finished_at": "2025-07-18T02:02:32.976Z",
"duration": 20,
"cost": 38,
"status": "success"
}
}

βš™οΈ Optional Query Parameters​

  • ?includeFailed=true
    Returns the latest job results even if the job failed. This may include partial data.

  • ?includeStats=true
    Appends basic run statistics to the response:

    {
    "total_runs": 48,
    "successful_runs": 36,
    "failed_runs": 12
    }

πŸ“Œ Use Cases​

  • Trigger a script via internal automation and fetch output from the endpoint
  • Periodically pull the latest scrape value for a product
  • Integrate results directly into dashboards or spreadsheets

πŸ” Access Control​

Only the script’s owner (or authorized team members) can use this endpoint. Make sure your API key has access to the script.