# Enabling the REST API in WordPress

> Check that the WordPress REST API is working, fix common problems and use it to connect apps and services.

Source: https://helpcenter.ruachost.com/wordpress/guides/enabling-the-rest-api-in-wordpress/

The **WordPress REST API** allows developers to interact with WordPress data (posts, pages, users, etc.) using JSON endpoints. This makes it possible to build apps, integrate external services, or create headless WordPress sites. On **ruachost.com**, the REST API is enabled by default, but you may need to configure or troubleshoot it.

## Why Use the REST API?

- Provides programmatic access to WordPress content.
- Enables integration with mobile apps or external platforms.
- Useful for building headless WordPress sites.
- Allows developers to automate tasks and workflows.

## Steps to Enable or Verify REST API

### 1. Check if REST API is Enabled

- Visit the following endpoint in your browser:

  ```
  https://yourdomain.com/wp-json/
  ```
- If enabled, you will see a JSON response with site data.

### 2. Enable REST API via `functions.php` (if disabled)

If your theme or a plugin has disabled the REST API, you can re‑enable it:

```
// Re-enable WordPress REST API
add_filter('rest_enabled', '__return_true');
add_filter('rest_jsonp_enabled', '__return_true');
```

Add this snippet to your theme’s **functions.php** file.

### 3. Ensure Permalinks Are Configured

- Go to **Settings → Permalinks**.
- Select a structure other than “Plain” (e.g., Post name).
- Save changes → This ensures REST API endpoints work correctly.

### 4. Check for Plugin Conflicts

- Some security plugins disable the REST API.
- Temporarily deactivate plugins to identify conflicts.
- Re‑enable REST API in plugin settings if available.

## Important Notes

- REST API is enabled by default in WordPress 4.7 and later.
- If you disable it for security reasons, certain features (like Gutenberg editor) may break.
- Always test API endpoints after enabling.
- Use authentication (e.g., Application Passwords or OAuth) for secure access.
