Brackets and the REST API

Last week, I went through the players endpoint in the WP REST API and how you can get, add, update and delete teams. Today, I’m going to do the same for brackets.

Getting brackets

The teams endpoint is /sportsbench/brackets. And in order to tell you how to get teams, I first need to tell you the available fields that will appear when you make a GET request. They are:

  • bracket_id
  • num_teams
  • bracket_format
  • bracket_title
  • bracket_season

From here, you can search for teams using any of these fields.

Adding, updating and deleting brackets

In terms of adding, updating and deleting brackets, it’s also pretty simple once you know what you’re doing.

When you’re adding a bracket, you don’t need to specify a bracket id. That will get assigned automatically. Also, you don’t need to specify every field for a bracket, similar to the normal add playoff bracket page in the WordPress backend.

Obviously, you will need the bracket id for updating and deleting teams.

Other than that, there’s not too much more to this.

What can you do with this?

Realistically, you can do just about anything you want with this and the REST API. You can create separate web applications or create a mobile application for your league and call in data from the website.

The possibilities are endless, and that’s the best part of the REST API. You can do really cool things and not have to write thousands of lines of code. So have fun with it!

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept the Privacy Policy

This site uses Akismet to reduce spam. Learn how your comment data is processed.