Webhook icon
Download icon
Query icon
If icon
Log icon

Search OpenAlex for Related Scholarly Works

Search OpenAlex from a Kestra webhook or manual input, inspect matches with DuckDB, and export up to 25 scholarly works to CSV.

Categories
Data

Find related papers with the public OpenAlex Works API and turn the results into a small, reusable research dataset. Run the flow manually with a search query, or POST a query to its keyed webhook. Kestra downloads the API response, DuckDB checks the total match count, flattens the returned works, and writes a spreadsheet-ready CSV artifact.

How it works

  1. search_webhook (io.kestra.plugin.core.trigger.Webhook) accepts a JSON request body with a query string. The key comes from the OPENALEX_WEBHOOK_KEY Kestra secret.
  2. download_works (io.kestra.plugin.core.http.Download) calls https://api.openalex.org/works with OpenAlex's search, per_page, and select parameters. The response is limited to 25 works and five useful fields; this basic API request does not need an OpenAlex API key.
  3. count_matches (io.kestra.plugin.jdbc.duckdb.Query) reads meta.count from the downloaded JSON. check_for_results (io.kestra.plugin.core.flow.If) logs either the total match count or that the search was empty.
  4. shape_results uses DuckDB's JSON table function to flatten the first page into one row per work, ordered by citation count and publication date, and writes the results directly to the openalex-results.csv artifact. DuckDB includes the column header even when a search returns no rows.

What you get

  • A spreadsheet-ready CSV artifact containing up to 25 works, ordered by citation count and publication date, with the columns openalex_id, title, doi, publication_date, and cited_by_count.
  • The {{ outputs.csv_uri }} flow output and {{ outputs.shape_results.outputFiles['openalex-results.csv'] }} task artifact path for downloading the CSV.
  • A log with OpenAlex's total match count. A search with zero matches still produces a CSV with its header row and no data rows.

Who it's for

  • Researchers looking for related papers on a topic.
  • Teams that want a small, reusable scholarly search flow that can be started manually or from another application.

Why orchestrate this with Kestra

Use the same observable flow from the Kestra UI or a keyed webhook. Kestra connects the API request, result-count check, and DuckDB transformation, then keeps the task logs and CSV artifact with the execution.

Prerequisites

  • A running Kestra instance with the HTTP and DuckDB JDBC plugins available.
  • Outbound HTTPS access from the Kestra worker to api.openalex.org.

Secrets

  • OPENALEX_WEBHOOK_KEY: a caller-chosen secret value used in the webhook URL. It is required for webhook calls; manual UI executions only need the search_query input.
  • No OpenAlex API key or other API credential is required.

Quick start

  1. Import this flow into your Kestra instance.
  2. Run it manually with the search_query input (STRING, default workflow orchestration), or add OPENALEX_WEBHOOK_KEY to your Kestra secrets and use the webhook trigger.
  3. For a webhook run, copy the trigger URL shown by Kestra and send a POST request with a JSON body such as {"query": "workflow orchestration"}. A non-empty query value overrides the manual input; an empty or whitespace-only value uses search_query.
  4. Open the shape_results task artifact or the flow output csv_uri to download the CSV.

How to extend

  • Add fields to the OpenAlex select parameter and the DuckDB query to include more work metadata in the CSV.
  • Adjust per_page to export a different number of works, or add OpenAlex filters for a narrower search.
  • Add a schedule or a downstream task to save, share, or analyze each generated CSV.

Links

Orchestrate with Kestra
Orchestrate DuckDB with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.