exerciseapi.dev

How do I build a swap exercise feature from exercise variations?

To build a swap button with exerciseapi.dev, look up each variation name. Show exact matches that fit the person’s equipment, then fill any gaps.

Start with the open exercise’s variations

Someone taps Swap because the bench is taken. If your app already has Barbell Bench Press - Medium Grip open, it has five ideas for what to do next. Every exercise record includes a field called variations. It holds up to five names of related exercises or progressions. Reading those names takes no extra request.

We looked up the five bench press variations on the live API on December 2, 2026. Each name came back first in its search. Standing Cable Chest Press uses a cable, while Incline Push-Up Wide lists its equipment as “body only”.

Check which exercise the name opens

A variation gives you a name. To open it, you need its record. Skip the name of the exercise being replaced. When the person taps Swap, search once for each remaining name before you show the choices. Here’s the request for one of the variations on Pullups.

GET https://api.exerciseapi.dev/v1/exercises?q=Wide%20Grip%20Pull-Up&limit=5

Encode the name for the URL so spaces become %20 and a slash becomes %2F. Search also returns close names. Our first result was Wide Grip Pull Up. The variation we asked for, Wide Grip Pull-Up, came second.

Keep the record that matches

Check the names in the reply’s data list. Ignore upper and lower case, but keep spaces and punctuation. When a name matches, use the ID from that record to open it. Never build an ID from the name.

Hide a name as missing only after a successful reply (status 200) with no exact match. A 429 means you’ve sent too many requests. Wait for the time given in the Retry-After header, then try again.

Each lookup uses one request. Checking five names takes five requests if all five succeed on the first try.

Save the list only after every lookup succeeds. Keep each name with its matching record before you filter by equipment. The person may have different equipment next time. Fetch a fresh copy once the saved one is 24 hours old. Remove older copies at 30 days, even for exercises nobody swaps again. Fetch a fresh copy before showing those choices again.

Find another choice when too few names match

Check each matched record’s equipment against what the person has. An empty equipment field (null) means the equipment is unknown. Count a choice only if you can tell the person has what it needs.

We checked all five variations on Single Arm Dumbbell Chest Press. None returned an exact match in the first five results. If the person has a cable, one request finds strength exercises for the same primary muscles. Repeating muscle in the URL matches either muscle.

GET https://api.exerciseapi.dev/v1/exercises?muscle=pectoralis%20major%20sternal%20head&muscle=pectoralis%20major%20clavicular%20head&equipment=cable&category=strength&limit=20

We got 13 matches, including Cable Chest Press. Keep the open exercise’s category in the request and leave out the exercise being replaced. Two exercises can work the same muscle and still feel different. Show the equipment and level beside each choice.

Try it with a free key

Get a free key from exerciseapi.dev and run the request above with your key in the X-API-Key header. For a web app, send it from your server so the key stays there. The free tier includes 100 requests a day and up to 20 results per request. No card required.