api_solr_indexer
No security coverage
Does your Drupal site need to make external data searchable alongside your content? API Solr Indexer bridges the gap between any REST API and your Search API Solr indexes. Define one or more API sources through a simple admin form, map the response fields to your index fields, and run indexing on demand or via Drush — all without writing a single line of PHP.
Each API source is a configuration entity, meaning your setup is exportable via config:export and fully deployable through your CI/CD pipeline.
Features
- Multiple API sources — configure any number of external REST endpoints, each targeting a different (or the same) Solr index.
- Flexible field mapping — map API response keys to Solr field names using a simple YAML textarea. Supports dot-notation for nested JSON, multiple aliases per field, pass-through, and explicit exclusion.
- Auto field discovery — the included Search API datasource plugin (
api_data) automatically exposes your mapped fields in the Search API "Add fields" UI. No manual TypedData definitions needed. - Multiple authentication methods:
- No auth
- Bearer token (static)
- HTTP Basic
- OAuth2 Client Credentials (with automatic token refresh and State API caching)
- API Key header
- Multiple pagination strategies: none, offset/limit, page/per_page, cursor, and link (next URL in response).
- Batch processing — indexing runs through the Drupal Batch API, displaying a progress bar and preventing timeouts even for tens of thousands of items.
- Run from the UI — each source has a "Run now" button (CSRF-protected) and there is a global "Run all active sources" action on the admin list.
- Drush commands —
drush api:solr:index-all,drush api:solr:index [source_id],drush api:solr:list. - Last-run status — the admin list shows the timestamp and item count of the last successful run for each source.
- Date and multivalued fields — automatic ISO 8601 conversion for date fields; split-by-separator support for multivalued fields.
- Config entity — all source configuration is exportable via Drupal's Configuration Management (CMI).
Post-Installation
- Enable the module:
drush en api_solr_indexer - Go to Administration → Configuration → Search and metadata → API Solr Indexer (
/admin/config/search/api-solr-indexer). - Click "+ Add API source" and fill in:
- The REST endpoint URL.
- The JSON path to the items array (e.g.
data.results). - The field(s) that uniquely identify each item.
- The field map (YAML):
solr_field: api_key. - Authentication and pagination settings if needed.
- The target Search API index.
- Create (or edit) a Search API index and select "Datos de API externa (API Solr Indexer)" as the datasource. The index will automatically pick up the fields from your source's field map.
- Add the fields you want to the index and configure processors as usual.
- Run indexing from the API Solr Indexer admin list or with
drush api:solr:index-all.
Additional Requirements
- Search API (required)
- Search API Solr (required) — a configured and working Solr server is needed.
- Drupal 10 or 11 (core_version_requirement: ^10 || ^11).
- PHP 8.1 or higher (uses named arguments and
str_starts_with()). - An external REST API that returns JSON.
Recommended modules/libraries
- Search API Solr Autocomplete — add autocomplete to search fields powered by your indexed API data.
- Search API Views integration — build Views-based search results pages from the indexed data.
- Key module — store API tokens and secrets securely instead of plain text in config.
- Ultimate Cron or Scheduler — schedule automatic re-indexing runs.
Similar projects
- Feeds — imports external data as Drupal nodes/entities, which are then indexed normally by Search API. API Solr Indexer skips the entity creation step and pushes directly into Solr, making it significantly faster for read-only search data and avoiding database bloat.
- Migrate Plus + Search API — the Migrate API can import external data into Drupal entities, which Search API then indexes. More powerful for complex transformations, but requires writing migration YAML/PHP and storing data in Drupal's database first. API Solr Indexer is lighter and faster when you only need searchability.
- Custom Search API datasource plugins — writing a datasource plugin from scratch gives maximum flexibility but requires PHP development. API Solr Indexer provides the same outcome through configuration alone.
Supporting this Module
This module was developed and open-sourced by whereiam. If you find it useful, the best way to support it is to:
- Report bugs and suggest features via the issue queue.
- Submit patches or merge requests.
- Write and share documentation, blog posts, or screencasts.
Community Documentation
- See the
MANUAL.mdfile included in the module for a full step-by-step user guide with examples for common API types (REST with OAuth2, paginated APIs, nested JSON responses). - Issue queue: https://www.drupal.org/project/issues/api_solr_indexer