How to Use SoftwareRoad Knowledge Base with the WordPress REST API

How to Use SoftwareRoad Knowledge Base with the WordPress REST API

SoftwareRoad Knowledge Base makes its articles and categories available through the standard WordPress REST API.

This is mainly useful for developers who want to connect a WordPress knowledge base to another website, application or internal tool.

Possible uses include:

  • Displaying documentation inside a software application
  • Building a custom knowledge base search
  • Creating a separate documentation front end
  • Synchronising articles with another service
  • Retrieving article data for an internal dashboard
  • Building advanced WordPress integrations

Most website owners will not need to use the REST API during normal knowledge base setup.

REST API requirements

SoftwareRoad Knowledge Base REST routes are available while:

  • The plugin is installed
  • The plugin is activated
  • The SoftwareRoad Knowledge Base licence is active
  • WordPress REST API requests are not blocked
  • The requested article or category is publicly available

An active Monthly or Yearly licence is required.

If the licence becomes inactive, requests to the SoftwareRoad Knowledge Base REST routes return an error instead of the requested content.

Knowledge base article endpoint

Published knowledge base articles are available from:

https://example.com/wp-json/wp/v2/srkb_article

Replace example.com with your own website address.

For example:

https://softwareroad.com/wp-json/wp/v2/srkb_article

A successful request returns a JSON response containing published SoftwareRoad Knowledge Base articles.

Retrieve one article

To retrieve a particular article, add its WordPress post ID to the endpoint:

https://example.com/wp-json/wp/v2/srkb_article/123

Replace 123 with the article ID.

The response can contain standard WordPress fields such as:

  • Article ID
  • Publication date
  • Modified date
  • Slug
  • Status
  • Public URL
  • Title
  • Article content
  • Excerpt
  • Featured media ID
  • Parent article ID
  • Assigned knowledge base categories

The exact fields available can depend on the request context and the permissions of the user making it.

Knowledge base category endpoint

SoftwareRoad Knowledge Base categories are available from:

https://example.com/wp-json/wp/v2/srkb_category

This returns the registered knowledge base categories as JSON.

A category response can include information such as:

  • Category ID
  • Number of assigned articles
  • Description
  • Category URL
  • Category name
  • Category slug
  • Parent category ID

Retrieve one category

Add the category term ID to the endpoint:

https://example.com/wp-json/wp/v2/srkb_category/12

Replace 12 with the category ID.

This returns the information for that particular knowledge base category.

Find article and category IDs

You can find an article ID from the WordPress dashboard.

Open:

Knowledge Base > All Articles

Move your pointer over the article title and check the edit link shown by the browser. The article ID appears in the URL as a number following post=.

You can also retrieve the article collection through the REST API and read the id value in the response.

Category IDs can be found through:

Knowledge Base > Categories

They are also included in the category REST API response.

Test the REST API in a browser

Public GET requests can be tested by opening the endpoint directly in a browser:

https://example.com/wp-json/wp/v2/srkb_article

If the route is working, the browser should display a JSON response.

Depending on your browser, the JSON may appear as plain text or formatted data.

You can test categories using:

https://example.com/wp-json/wp/v2/srkb_category

Example article request using JavaScript

A website or application can request published articles using JavaScript:

fetch('https://example.com/wp-json/wp/v2/srkb_article')

The response can then be converted into JSON and used by your application.

A basic example would be:

fetch('https://example.com/wp-json/wp/v2/srkb_article')
.then(response => response.json())
.then(articles => console.log(articles))
.catch(error => console.error(error));

Replace the example domain with the website hosting SoftwareRoad Knowledge Base.

Example request using PHP

A PHP integration can use the WordPress HTTP API:

$response = wp_remote_get('https://example.com/wp-json/wp/v2/srkb_article');

You should then check for errors before reading the response body.

For example:

if (!is_wp_error($response)) {
$articles = json_decode(wp_remote_retrieve_body($response), true);
}

When the integration runs on the same WordPress website, you may also be able to query the srkb_article post type directly instead of making an external HTTP request.

Request a limited number of articles

The standard WordPress REST API supports pagination parameters.

For example, to request five articles:

https://example.com/wp-json/wp/v2/srkb_article?per_page=5

To request the second page:

https://example.com/wp-json/wp/v2/srkb_article?per_page=5&page=2

This is useful when your WordPress knowledge base contains a large number of articles.

Do not request every article on every page load when only a few are needed.

Search knowledge base articles

You can use the standard REST API search parameter:

https://example.com/wp-json/wp/v2/srkb_article?search=licence

This returns published articles matching the requested wording.

Another example would be:

https://example.com/wp-json/wp/v2/srkb_article?search=product%20key

Spaces should be URL encoded when building the address manually.

REST API search is separate from the live SoftwareRoad Knowledge Base search interface and its Search Analytics.

Retrieve articles from a category

Articles can be filtered using the knowledge base category ID.

For example:

https://example.com/wp-json/wp/v2/srkb_article?srkb_category=12

Replace 12 with the required category ID.

This can be useful when building:

  • A custom category page
  • Product-specific documentation
  • An in-application help panel
  • A filtered list of setup guides

Test the request carefully because available query parameters can depend on the standard WordPress REST controller.

Order the results

Standard WordPress REST API parameters can be used to control article ordering.

For example:

https://example.com/wp-json/wp/v2/srkb_article?orderby=modified&order=desc

This requests recently modified articles first.

Other possible ordering values depend on what the WordPress REST API allows for that request.

Validate all user-supplied parameters before passing them into an application request.

Request articles by slug

A particular article can be requested using its slug:

https://example.com/wp-json/wp/v2/srkb_article?slug=how-to-install-softwareroad-knowledge-base

This can be useful when the application knows the article slug but not its numeric ID.

A slug request returns an array, even when only one article matches.

Check that the array contains a result before trying to use the article data.

Rendered article content

The article content is normally returned inside the content object.

The rendered HTML can be found in:

content.rendered

The article title can be found in:

title.rendered

The excerpt can normally be found in:

excerpt.rendered

Treat this content as HTML rather than plain text.

If you display it in another application, make sure your chosen platform handles and sanitises HTML appropriately.

The standard article response can include a featured_media value.

This is the WordPress attachment ID rather than necessarily providing the full image address.

You can request the media item separately through:

https://example.com/wp-json/wp/v2/media/456

Replace 456 with the featured media ID.

You can also use the _embed parameter:

https://example.com/wp-json/wp/v2/srkb_article?_embed

This can include related information such as featured media in the response when WordPress supports it.

Embedded responses are larger, so only request them when needed.

Parent and child articles

SoftwareRoad Knowledge Base articles are registered as a hierarchical WordPress post type.

The REST response can therefore include a parent value.

A parent value of:

0

means the article does not have a parent article.

A different number identifies the WordPress post ID of the parent.

Do not confuse article hierarchy with knowledge base category hierarchy. They are separate structures.

Parent and child categories

Knowledge base categories are hierarchical.

A category response includes its parent value.

For example:

  • Getting Started may have a parent value of 0
  • Installation may contain the ID of Getting Started as its parent

This allows an advanced integration to recreate the knowledge base category structure outside WordPress.

Unlisted articles and the REST API

Unlisted articles are excluded from normal public REST API article collections.

This matches their behaviour elsewhere in SoftwareRoad Knowledge Base.

An unlisted article is also normally excluded from:

  • Knowledge base search
  • Category listings
  • Popular Articles
  • Related Articles
  • Recommended Articles
  • XML sitemaps

Marking an article as unlisted does not make it a secure or private document.

Anyone who already has its direct public URL may still be able to open it.

Do not use unlisted articles for confidential information.

Draft articles

Normal unauthenticated REST API requests only return publicly available content.

Draft, private and pending articles require suitable WordPress authentication and permissions.

A public application should not assume it can retrieve unpublished documentation.

Keep draft articles unpublished until they are ready to be shown.

Reading public content

Published article and category endpoints can usually be read without WordPress authentication while the SoftwareRoad Knowledge Base licence is active.

This is suitable for a public documentation integration.

Do not expose private WordPress authentication details in website JavaScript or a desktop application.

Public GET requests should only retrieve content that is already publicly available.

Creating and editing articles through the REST API

WordPress can accept authenticated REST API requests for creating and editing content.

For SoftwareRoad Knowledge Base articles, the route uses the srkb_article post type.

Creating or changing articles requires:

  • A valid WordPress user
  • Suitable WordPress permissions
  • A supported authentication method
  • A valid request nonce or application credential where appropriate
  • An active SoftwareRoad Knowledge Base licence

Do not allow an unauthenticated application to create or edit articles.

Example authenticated article creation endpoint

An authenticated POST request can be sent to:

https://example.com/wp-json/wp/v2/srkb_article

A request body could include standard WordPress fields such as:

  • title
  • content
  • excerpt
  • status
  • srkb_category

For example, a development integration might send data similar to:

{
"title": "How to Configure the Plugin",
"content": "Article content goes here.",
"status": "draft"
}

Create articles as drafts first when content needs to be reviewed before publication.

Updating an article

To update an existing article, send an authenticated request to:

https://example.com/wp-json/wp/v2/srkb_article/123

Replace 123 with the article ID.

Only users with permission to edit that article should be authorised to make the request.

Always handle failed requests and permission errors rather than assuming the update succeeded.

Deleting an article

Authenticated users with the correct permissions can use the standard REST API method for deleting a knowledge base article.

Deleting content through an integration can be difficult to reverse.

Consider moving articles to Trash instead of permanently deleting them.

Check whether the article has:

  • Search engine traffic
  • External links
  • Automatic Article Links pointing to it
  • Support emails containing its URL
  • Related documentation

A redirect may be required when removing published content.

Custom SoftwareRoad fields

Some SoftwareRoad Knowledge Base features use custom WordPress metadata, including settings for article icons and unlisted visibility.

These custom values are not necessarily exposed as editable REST API fields by default.

A standard response may therefore include the core article content but not every SoftwareRoad-specific setting shown in the WordPress editor.

Developers who need additional custom fields should register and expose them carefully using WordPress development methods.

Do not modify the SoftwareRoad Knowledge Base plugin files directly because plugin updates can replace those changes.

Category icons through the REST API

Category icon and custom image information is stored separately from the standard category name and description.

It may not appear in the default srkb_category REST response.

An integration that needs category artwork may require additional custom development to expose the relevant term metadata.

The standard category route remains useful for:

  • Names
  • Descriptions
  • Slugs
  • Parent relationships
  • Article counts
  • Public links

Article icons through the REST API

SoftwareRoad Knowledge Base article icons and uploaded article icon images are custom article information.

They may not be included in the default WordPress REST response.

The normal WordPress featured image remains available through the standard featured_media field.

Use a featured image when an external integration needs standard WordPress media support without additional custom development.

Licence protection on REST routes

SoftwareRoad Knowledge Base protects these REST routes:

/wp/v2/srkb_article

/wp/v2/srkb_category

When the licence is active, requests can continue normally.

When the licence is inactive, the plugin returns a REST API error with HTTP status:

403

The error code is:

srkb_license_required

The message explains that SoftwareRoad Knowledge Base requires an active licence.

Example inactive-licence response

An inactive licence can return information similar to:

{
"code": "srkb_license_required",
"message": "SoftwareRoad Knowledge Base requires an active licence.",
"data": {
"status": 403
}
}

Your integration should handle this response gracefully.

Do not repeatedly send requests when the licence is known to be inactive.

Handle API errors

A reliable integration should check:

  • HTTP response status
  • WordPress error code
  • Response body
  • JSON parsing errors
  • Connection timeouts
  • Empty results
  • Permission errors
  • Licence errors

Do not assume every response contains an array of articles.

For example, a failed request may contain an error object instead.

Common REST response codes

Possible responses include:

  • 200 for a successful request
  • 201 after successfully creating content
  • 400 for an invalid request
  • 401 when authentication is missing or invalid
  • 403 when access is not permitted or the licence is inactive
  • 404 when the route or requested item cannot be found

The exact result depends on the request and WordPress configuration.

The REST API route returns 404

If the endpoint returns a route not found error, check that:

  • SoftwareRoad Knowledge Base is installed
  • The plugin is activated
  • WordPress REST API is available
  • The route spelling is correct
  • WordPress permalinks have been refreshed
  • A security feature is not blocking the route

Use the exact post type route:

/wp-json/wp/v2/srkb_article

and category route:

/wp-json/wp/v2/srkb_category

Changing the public article URL base does not change these REST route names.

Public URL bases do not change the REST routes

The article URL base can be changed under the Advanced settings.

For example, public articles may use:

example.com/docs/article-name/

The REST API route remains:

example.com/wp-json/wp/v2/srkb_article

The same applies to knowledge base categories.

Removing or changing the public category URL base does not change:

/wp-json/wp/v2/srkb_category

The API returns a 403 licence error

Open:

Knowledge Base > Licence

Check that:

  • The purchase email is correct
  • The product key is correct
  • The Monthly or Yearly subscription is active
  • The website can contact SoftwareRoad
  • The licence has been activated on the current website

After restoring the licence, test the REST API route again.

The API returns an empty article list

Check that:

  • Knowledge base articles have been published
  • Articles are not marked as unlisted
  • The request filters are correct
  • The requested page number exists
  • The search wording matches published content
  • The licence is active

Remove optional query parameters and test the basic collection route first:

https://example.com/wp-json/wp/v2/srkb_article

A published article is missing

Open the article in WordPress and check:

  • Status is Published
  • Unlisted Article is disabled
  • The article has not been moved to Trash
  • The REST request is not filtering by another category
  • The requested slug is correct
  • The page of results includes the article

Use the article’s numeric ID to test it directly.

The category route is empty

Check that:

  • Knowledge base categories exist
  • The taxonomy route is spelled correctly
  • The licence is active
  • Security rules are not blocking REST requests

The correct endpoint is:

https://example.com/wp-json/wp/v2/srkb_category

Categories can appear even when they currently contain no published articles, depending on the REST query used.

Authentication fails

When making authenticated requests, check:

  • The WordPress username
  • The authentication method
  • The application password or credential
  • HTTPS is enabled
  • The user has permission to edit knowledge base articles
  • A security plugin is not blocking REST authentication
  • The request headers are correct

Never place administrator credentials in public frontend JavaScript.

Cross-origin requests

An application hosted on another domain may be affected by browser cross-origin restrictions.

For example:

  • Knowledge base: docs.example.com
  • Application: app.example.net

The browser may block the request unless the server allows the relevant origin.

Configure cross-origin access narrowly and securely.

Do not allow every website to make authenticated requests to your WordPress installation.

Cache REST API responses carefully

Caching can reduce the number of requests made to WordPress.

This may be useful when displaying documentation inside a busy application.

However, caching means updates may not appear immediately.

Choose a cache period that balances:

  • Performance
  • Freshness
  • Server load
  • How often articles change

Clear or refresh the cache after publishing important updates.

Do not expose licence details through an integration

The article and category REST routes do not require you to send your SoftwareRoad purchase email or product key with every public request.

The licence is managed through the WordPress administration area.

Never include the full product key in:

  • Public JavaScript
  • Mobile application code
  • Desktop application source
  • GitHub repositories
  • Public documentation
  • Browser URLs

Keep licence details private.

Secure write integrations

An integration that creates or edits knowledge base content should follow good security practices.

Use:

  • HTTPS
  • A dedicated WordPress user with only the permissions needed
  • Secure credential storage
  • Server-side requests where possible
  • Input validation
  • Output sanitisation
  • Request logging without sensitive credentials
  • Error handling
  • Regular credential rotation

Avoid using the main website administrator account for an automated integration.

Test on a staging website

Before connecting an external system to a live WordPress knowledge base, test it on a staging website.

Check:

  • Article retrieval
  • Category retrieval
  • Pagination
  • Search filters
  • Parent and child categories
  • Featured images
  • Authentication
  • Draft creation
  • Updating existing articles
  • Licence error handling

Do not test deletion or bulk updates against live documentation unless you have a current backup.

Back up before bulk changes

REST API integrations can update many articles quickly.

Before running a bulk import or synchronisation:

  • Back up the WordPress database
  • Test with one draft article
  • Confirm category assignments
  • Check HTML formatting
  • Check article slugs
  • Review duplicate handling
  • Confirm how deletions are managed

A small error in an automated request can affect a large amount of documentation.

Suitable uses for the REST API

The SoftwareRoad Knowledge Base REST API support is useful for advanced projects such as:

  • Showing help articles inside desktop software
  • Building a customer documentation portal
  • Displaying selected guides on another WordPress website
  • Creating a product-specific help panel
  • Sending article data to an internal search service
  • Building a custom frontend using WordPress as the content system
  • Synchronising reviewed documentation with another platform

Use the normal SoftwareRoad Knowledge Base pages when you do not need a custom integration.

REST API checklist

Before finishing your integration, check that:

  • SoftwareRoad Knowledge Base is active
  • The Monthly or Yearly licence is active
  • The article endpoint responds
  • The category endpoint responds
  • Only published and suitable content is exposed
  • Unlisted articles are excluded from normal collections
  • Pagination is handled
  • Empty responses are handled
  • HTTP errors are handled
  • The 403 licence response is handled
  • Authentication credentials are stored securely
  • Public JavaScript does not contain private credentials
  • Cross-origin access is restricted
  • REST responses are cached appropriately
  • Bulk changes have been tested on staging
  • A current WordPress backup exists

SoftwareRoad Knowledge Base articles and categories are now ready to be used in advanced WordPress REST API integrations.

Continue reading

SoftwareRoad Knowledge Base Shortcode Reference SoftwareRoad Knowledge Base Shortcode Reference SoftwareRoad Knowledge Base uses a simple WordPress shortcode to display the main knowledge base homepage. The shortcode…