Basic Authentication

Need help setting up basic authentication? Follow this guide to get started with the SportsPress REST API by creating a fully functional testing environment using the  Postman app and the Application Passwords plugin.

Before starting, ensure that both WordPress and SportsPress are installed on your site.

1. Download and install the Postman app

Visit https://www.postman.com/downloads/ and click Download the App.

You can create an account if you want to save your API settings, but it's not required for this tutorial. Once Postman is installed, you should see a window like this:

If you want to skip creating an account for now, click Skip and go to the app.

You should now see a new request page. If not, click the [+] tab to add a new request. Don't worry about filling out any of the fields here just yet, we'll do that in a later step.

2. Install and activate the Application Passwords plugin

Before we continue, we're going to need to authenticate your API requests with your WordPress installation. There are a number of solutions for this, but we're going to use a plugin called Application Passwords.

From your WordPress dashboard, go to Plugins > Add New and type "application passwords" into the search box. Click Install Now to install Application Passwords, then follow the steps to activate the plugin.

Note: If you're uploading via FTP instead, you can download the plugin files directly via https://wordpress.org/plugins/application-passwords/

3. Generate a new application password

Once Application Passwords is activated, go to Users from your WordPress dashboard. Then, click on your username and scroll down until you see the Application Passwords section.

Enter a name for your new application password. It can be anything, so we'll enter "Postman Password" for now. Click Add New, and you should see a modal popup with your new password. Copy this and save it in a safe location. You'll also need it for the next step.

4. Add your username and password to Postman

To begin authorizing requests, open up Postman again. From your API request screen, click on the Authorization tab.

Choose Basic Auth as the Type, and enter your WordPress username into the Username field. Now, copy the application password from the previous step and paste that into the Password field.

5. Configure headers in Postman

Before we send our first request, we'll need to let our application know that we're sending and expecting JSON objects. To do this, go to the Headers tab and add a new entry to the table with "Content-Type" as the key, and "application/json" as the value.

KEY VALUE DESCRIPTION
Content-Type application/json

Now you're ready to start sending API requests.

6. Send your first API request

Now we're ready to send our first API request to the REST API. To see a list of endpoints, visit the introduction article. We're going to test using the Teams endpoint, which is /wp-json/sportspress/v2/teams

Your endpoint should being with the full URL of your WordPress site followed by the endpoint, for example https://example.com/wp-json/sportspress/v2/teams

Click Send, and if configured correctly you should see a response body containing your events!

What's next? Check out additional REST API documentation for more details on specific usage.

Still need help? Submit a Support Ticket Submit a Support Ticket