Retrieve Formatted Workout Endpoint

Follow

This is available on Subscription Tiers: 

Engage, Grow, Promote, Free Unlimited, Essentials, Accelerate, & Ultimate.


The formatted workout endpoint returns a workout plus an HTML-formatted version you can place directly into a web page — perfect for embedding today’s WOD on a site, landing page, or digital signage.

 


Pre-requisite Pro-Tip

  • You need a Wodify API key (get it from Digital Presence → Web Integrations in Admin).

  • Know the exact location name and program name that the workout belongs to.

  • The endpoint expects a date in YYYY-MM-DD format (the example below uses today's date).

  • Security tip: do not embed your API key in public client-side code for production. For public sites, call the Wodify API from a server-side endpoint (or a server-side proxy) and return only the HTML needed to the browser.

  • Because FormattedWOD is returned as HTML, treat it as untrusted content unless you control the source — sanitize or escape if required by your environment. 

     


Step-By-Step How To

  1. Identify the workout you want by date, location, and program.

  2. Make a GET request to:

https://api.wodify.com/v1/workouts/formattedworkout

with query parameters:

  • date=YYYY-MM-DD

  • location=LocationName (URL-encoded)

  • program=ProgramName (URL-encoded)

and header:

  • x-api-key: <YourAPIKey>

  1. If the response is successful, the JSON will include APIWod.FormattedWOD (HTML). Insert that HTML into your page (or return it from your server endpoint).

  2. If the workout is not found, the API returns an APIError object — show a friendly message to the user and log the error details.


Example (client-side) — replace the variables at the bottom

Reminder: for production avoid exposing the API key in browser JS. Use server-side proxy as noted above.

<div id="wodcontainer"></div>
<script>
/**
 * Fetches the formatted workout for today and injects it into the page.
 * Params:
 *  - elementId: id of the container element
 *  - apiKey: your Wodify API key (server-side recommended)
 *  - location: exact location name in Wodify
 *  - program: exact program name in Wodify
 */
var getWodDetails = ({ elementId, apiKey, location, program }) => {
  // build date YYYY-MM-DD (today)
  var today = new Date();
  var date = `${today.getFullYear()}-${(today.getMonth() + 1).toString().padStart(2,'0')}-${today.getDate().toString().padStart(2,'0')}`;

  var fetchUrl = `https://api.wodify.com/v1/workouts/formattedworkout?date=${date}&location=${encodeURIComponent(location)}&program=${encodeURIComponent(program)}`;

  fetch(fetchUrl, {
    headers: { "x-api-key": apiKey }
  })
  .then(response => {
    // non-OK responses often contain APIError JSON
    if (!response.ok) {
      return response.json().then(err => {
        if (err && err.APIError && err.APIError.ErrorMessage) {
          throw new Error(err.APIError.ErrorMessage);
        } else if (err && err.MoreInfo) {
          throw new Error(err.MoreInfo);
        } else {
          throw new Error('Unknown API error.');
        }
      });
    }
    return response.json();
  })
  .then(data => {
    var container = document.getElementById(elementId);
    if (data && data.APIWod && data.APIWod.FormattedWOD) {
      // Insert returned HTML. Sanitize if necessary for your environment.
      container.innerHTML = data.APIWod.FormattedWOD;
    } else {
      container.innerHTML = 'No workout data found.';
    }
  })
  .catch(error => {
    console.error('Fetch error:', error);
    document.getElementById(elementId).innerHTML = `Error: ${error.message}`;
  });
};

// ---- Replace these values ----
getWodDetails({
  elementId: "wodcontainer",
  apiKey: "YourAPIKeyGoesHere",
  location: "LocationNameGoesHere",
  program: "ProgramNameGoesHere"
});
</script>

Response format (what to expect)

  • Successful response includes top-level APIWod object with:

    • WodHeader (metadata: Id, Date, Name, etc.)

    • Components (array of component objects with Description, Name, etc.)

    • FormattedWODHTML you can render directly

    • Optional objects: CoachNotes, Announcements, Location, Program, etc.

Note: the updated response is not wrapped in a record list — APIWod is returned directly.

Error example (workout not found):

{
  "APIError": {
    "ResponseCode":"400",
    "ErrorMessage":"No workout found matching those criteria. Please change your search parameters and try again."
  }
}

Troubleshooting & Tips

  • No workout found — confirm date, location, and program spellings exactly match Wodify (these are case-sensitive in some systems).

  • Empty FormattedWOD or missing fields — check APIWod.Components and WodHeader to validate that the workout exists and is published.

  • HTML safety — because FormattedWOD contains HTML, sanitize or validate it where appropriate (especially if rendering in a public website).

  • Protect the API key — do not commit the API key into public repositories or client-side code; prefer server-side calls that return only the necessary HTML.

  • Custom date — to request any date, replace the date query parameter with the desired YYYY-MM-DD.

 


FAQs

  1. Which query parameters are required? date, location, and program are required to locate the workout. Date should be YYYY-MM-DD. Location and program must match names in Wodify.
     

  2. The response contains HTML — is it safe to use innerHTML? The API returns HTML ready for display, but treat it as external content. If you cannot guarantee the source, sanitize it before inserting into the DOM to avoid XSS issues. For production, prefer returning the HTML via a server endpoint you control.
     

  3. I received an error JSON — how do I debug? Inspect the returned JSON. If the JSON contains APIError, use APIError.ErrorMessage to show a user-friendly message and log the full object for debugging (include the date/location/program you requested).

Comments

Check the current status of our products

View status