WordPress Plugin: WP JSON API Plugin Documentation

Introduction


Welcome to the documentation for WP JSON API for WordPress!
Here you'll be able to learn how it works and explore the features available.
If you have any questions please feel free to contact us

Full Postman collection available here Postman API collection

Requirements


To quickly get set up, you'll need to ensure that you have the below requirements.

  • WordPress 4.0+

    Woocommerce Store 3.0+ (Optional)

Installing the Plugin


Follow the below steps to install the plugin on your WordPress site:

  • Login into your WooSignal account (or create an account if you are new).

  • Once you reach the Dashboard, on the left nav bar look for "Plugins" and click the link.

  • After downloading the plugin, visit your WordPress site and login to get to your admin dashboard. On your nav bar, look for "Plugins" like the below image.

    Select "Add New" and proceed to the next step below.

  • Then select "Upload plugin" like the below image

    This will open a box below where you can upload a .zip file.

  • Click "Choose file" can look for the WooSignal plugin you downloaded and select the .zip file to install. After you select "Install Now". You should then be able to activate the plugin from your WordPress admin to start using it.

  • If you followed all the steps above you should now be ready to start using the plugin.

API Requests: WordPress


Get Nonce

Returns a nonce token from WordPress, use the response token for logging in and registering new users.

[GET]

Path /wp-json/wpapp/auth/v1/nonce

Parameters: {}

Response:

{
    "data": {
        "nonce": "002bac1c4e", // use this for future requests
        "root": "https://mysite.com/wp-json/",
        "expiry": 1586639327
    },
    "message": "",
    "status": 200
}

Verify Nonce

Returns the bool value if a nonce is still valid to use.

[POST]

Path /wp-json/wpapp/auth/v1/verify

Body Parameters

{
    "nonce": "203cff6ff4"
}

Response:

{
    "data": {
        "is_valid": true
    },
    "message": "",
    "status": 200
}

Login

Login a user on WordPress

[POST]

Path to login using a email and password /wp-json/wpapp/api/v1/user/login?auth=email

Body Parameters

{
  "nonce":"002bac1c4e",
  "email":"sam@aol.com",
  "password":"thepassword1"
}
[POST]

Path to login using a username and password /wp-json/wpapp/api/v1/user/login?auth=username

Body Parameters

{
  "nonce":"002bac1c4e",
  "username":"samcook",
  "password":"thepassword1"
}

Response:

{
    "data": {
        "user_token": "9dfade62d610dbf601c2sodfefcc344eac507861d7a75778", // token to use for future requests
        "expiry": 0
    },
    "message": "",
    "status": 200
}

Register a user

Register a user on WordPress

[POST]

Path /wp-json/wpapp/api/v1/user/register

Body Parameters

{
  "nonce":"002bac1c4e",
  "username":"samcook",
  "email":"sam@aol.com",
  "password":"thepassword1"
}

Response:

{
    "data": {
        "user_token": "9dfade62d610dbf601c2sodfefcc344eac507861d7a75778", // token to use for future requests
        "expiry": 0
    },
    "message": "",
    "status": 200
}


WordPress Users Info

Returns a users info from WordPress

[POST]

Path /wp-json/wpapp/api/v1/user/info

Body Parameters

{ "token": "USER TOKEN FROM REGISTER/LOGIN" }

Response:

{
    "data": {
        "id": 2,
        "first_name": "Sam",
        "last_name": "Cool",
        "username": "samcook",
        "email": "samcook@aol.com",
        "avatar": "https://secure.gravatar.com/avatar/b7ebd909f128794ca00ce488ef880421?s=250&d=mm&r=g",
        "created_at": "2020-04-05 23:34:32"
    },
    "message": "",
    "status": 200
}


Update Users Password

Update an authenticated users password

[POST]

Path /wp-json/wpapp/api/v1/update/user/password

Body Parameters

{
  "token": "USER TOKEN FROM REGISTER/LOGIN", "password": "secretPassword2"
}

Response:

{
    "data": [],
    "message": "Updated",
    "status": 200
}

Update Users Info

Update an authenticated users info

[POST]

Path /wp-json/wpapp/api/v1/update/user/info

Body Parameters

{
  "token": "USER TOKEN FROM REGISTER/LOGIN",
  "first_name": "Kelly", 
  "last_name": "Coleman"
}

Response:

{
    "data": {
        "ID": 7,
        "first_name": "Kelly",
        "last_name": "Coleman"
    },
    "message": "Updated",
    "status": 200
}

API Requests: WooCommerce

WooCommerce Get Users Info

Returns a customers info from WooCommerce, we include the billing and shipping

[POST]

Path /wp-json/wpapp/wc/v1/user/info

Body Parameters

{ "token": "USER TOKEN FROM REGISTER/LOGIN" }

Response:

{
    "data": {
        "first_name": "Sam",
        "last_name": "Cook",
        "display_name": "sam cook",
        "avatar": "https://secure.gravatar.com/avatar/b7ebd909f128794ca00ce488ef880421?s=96&d=mm&r=g",
        "shipping": {
            "first_name": "sam",
            "last_name": "cook",
            "company": "a company",
            "address_1": "499 Home Road",
            "address_2": "30 oak road",
            "city": "London",
            "state": "London",
            "postcode": "B3 1JJ",
            "country": "GB"
        },
        "billing": {
            "first_name": "sam",
            "last_name": "cook",
            "company": "WooSignal",
            "address_1": "33 West Lane",
            "address_2": "30 oak road",
            "city": "london",
            "state": "London",
            "postcode": "B3 1JJ",
            "country": "GB",
            "email": "sam@aol.com",
            "phone": "0292922"
        }
    },
    "message": "",
    "status": 200
}
WooCommerce Update Users Info

Send the fields you want to update and the plugin will handle the rest

[POST]

Path /wp-json/wpapp/wc/v1/update/user/info

Body Parameters (All can be optionally added) but you must include the user token

{
    "token": "USER TOKEN FROM REGISTER/LOGIN",
    "first_name": "Sam",
    "last_name": "Cook",
    "display_name": "sam cook",
    "shipping": {
        "first_name": "sam",
        "last_name": "cook",
        "company": "a company",
        "address_1": "499 Home Road",
        "address_2": "30 oak road",
        "city": "London",
        "state": "London",
        "postcode": "B3 1JJ",
        "country": "GB"
    },
    "billing": {
        "first_name": "sam",
        "last_name": "cook",
        "company": "WooSignal",
        "address_1": "33 West Lane",
        "address_2": "30 oak road",
        "city": "london",
        "state": "London",
        "postcode": "B3 1JJ",
        "country": "GB",
        "email": "sam@aol.com",
        "phone": "0292922"
    }
}

Response:

{
    "data": {
        "first_name": "Sam",
        "last_name": "Cook",
        "display_name": "sam cook",
        "avatar": "https://secure.gravatar.com/avatar/b7ebd909f128794ca00ce488ef880421?s=96&d=mm&r=g",
        "shipping": {
            "first_name": "sam",
            "last_name": "cook",
            "company": "a company",
            "address_1": "499 Home Road",
            "address_2": "30 oak road",
            "city": "London",
            "state": "London",
            "postcode": "B3 1JJ",
            "country": "GB"
        },
        "billing": {
            "first_name": "sam",
            "last_name": "cook",
            "company": "WooSignal",
            "address_1": "33 West Lane",
            "address_2": "30 oak road",
            "city": "london",
            "state": "London",
            "postcode": "B3 1JJ",
            "country": "GB",
            "email": "sam@aol.com",
            "phone": "0292922"
        }
    },
    "message": "",
    "status": 200
}