# SBA Loan Portfolio Explorer API — 7(a) & 504 Rollups (`malonestar/sba-loan-portfolio-explorer`) Actor

SBA loan data API over the 7(a) and 504 FOIA loan-level files. Look up loans by state, NAICS industry, lender, fiscal year and amount; roll up by lender / industry / geography; and flag risk outliers (amount-per-job, charge-offs, lender concentration). Keyless.

- **URL**: https://apify.com/malonestar/sba-loan-portfolio-explorer.md
- **Developed by:** [Kyle Maloney](https://apify.com/malonestar) (community)
- **Categories:** Lead generation, Developer tools, Agents
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.40 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## SBA Loan Portfolio Explorer — 7(a) & 504 Loan Data API with Rollups

An **SBA loan data API** over the official **7(a) and 504 FOIA** loan-level
files. Do a **7(a) / 504 loan lookup** by state, NAICS industry, lender, fiscal
year, or amount — then **roll up by lender, industry, or geography** and get
**risk / outlier flags** (loan-amount-per-job outliers, charge-off/default
proxy, single-lender concentration). SBA ships this data only as multi-hundred-MB
bulk CSVs; this actor makes it queryable and adds the analytics layer.

### Who it's for

- **Fintech / small-business lenders & underwriters** benchmarking lender books.
- **KYB / due-diligence & fraud teams** screening SBA borrowers and lenders.
- **Economic-development & policy analysts** studying loans by industry/state.
- **Data & RevOps teams** enriching a CRM with SBA loan history.
- **AI agents** needing an "SBA loan lookup / portfolio rollup" tool.

### What it does

Queries the data.sba.gov CKAN DataStore for the selected program(s) and fiscal
year, **normalizes 7(a) and 504 loans into one snake\_case schema** (dates →
`YYYY-MM-DD`, amounts numeric), applies your state / NAICS / lender / amount /
date filters, and then either:

- returns **loan-level rows** with per-loan `risk_flags` + `risk_score`, or
- returns a **rollup** — one aggregate row per **lender**, **NAICS industry**, or
  **state** (loan count, total & average approved $, charge-off/default proxy
  rate, jobs supported).

### Example input

```json
{
  "program": "7a",
  "fiscalYear": 2023,
  "state": "CA",
  "naicsPrefix": "72",
  "mode": "rollup-by-lender",
  "maxResults": 5000
}
```

### Output (per loan)

`program`, `subprogram`, `borrower_name`, `borrower_city`, `borrower_state`,
`project_state`, `lender_name`, `lender_state`, `gross_approval`,
`sba_guaranteed_approval`, `approval_date`, `approval_fiscal_year`,
`initial_interest_rate`, `term_in_months`, `naics_code`, `naics_description`,
`business_type`, `jobs_supported`, `loan_status`, `charged_off`, `paid_in_full`,
`charge_off_date`, `gross_charge_off_amount`, `amount_per_job`, `risk_flags[]`,
`risk_score`, `source_system`.

### Output (rollup row)

`rollup_dimension`, group key (`lender_name` / `naics_code` / `state`),
`loan_count`, `total_approved`, `avg_approved`, `total_guaranteed`,
`charged_off_count`, `charge_off_rate`, `total_charged_off_amount`,
`jobs_supported`, `avg_amount_per_job`.

### Use as an MCP tool

Available to AI agents via `mcp.apify.com` as an "SBA loan portfolio explorer"
tool — filter in, normalized SBA loan records or lender/industry/geo rollups out.

### FAQ

**Where's the data from?** The SBA's official 7(a) & 504 FOIA loan-level files on
`data.sba.gov`, queried through the keyless CKAN DataStore API.
**Is it keyless?** Yes — no API key or login.
**Does it include PPP?** Not in v1. PPP is published only as a multi-GB bulk
file; 7(a) and 504 are the reliable, queryable targets. PPP may be added later.
**How do I find risky lenders?** Use `mode: rollup-by-lender` and sort by
`charge_off_rate`, or run `mode: loans` and filter on `risk_flags`.
**Why a max-results cap?** The FOIA files are large; `maxResults` bounds cost and
runtime. Narrow with `state` / `naicsPrefix` / `fiscalYear` / `query` for
targeted pulls.

### Source

SBA **data.sba.gov 7(a)/504 FOIA** files via the CKAN DataStore
(`data.sba.gov/api/3/action/datastore_search`). Official, keyless.

### Pricing (Pay Per Result)

Billed per result row returned — one loan record OR one rollup row. Empty
searches cost nothing.

# Actor input Schema

## `program` (type: `string`):

Which SBA loan program to query: '7a' (7(a) guaranteed loans), '504' (504/CDC loans), or 'all' for both. PPP is not included in v1 (PPP ships only as a multi-GB bulk file).

## `fiscalYear` (type: `integer`):

Restrict to loans approved in this SBA fiscal year (Oct 1-Sep 30). Also routes the query to only the FOIA file that covers this year. Leave empty for all years the selected files cover.

## `state` (type: `string`):

Filter to loans whose borrower OR project state equals this 2-letter code, e.g. 'CA', 'TX'. Empty = all states.

## `naicsPrefix` (type: `string`):

Keep only loans whose NAICS code starts with this prefix, e.g. '72' (accommodation & food services), '23' (construction). Empty = all industries.

## `lenderName` (type: `string`):

Substring match (case-insensitive) on the funding bank / lender name (7(a) BankName or 504 third-party lender). Empty = all lenders.

## `query` (type: `string`):

Optional CKAN full-text search sent to data.sba.gov to prefilter rows before client-side filtering (e.g. a borrower or bank name). Speeds up narrow lender/borrower lookups over the large files. Empty = scan all rows up to the max.

## `sinceDate` (type: `string`):

Only return loans with approval\_date on or after this date. Empty = no lower bound.

## `untilDate` (type: `string`):

Only return loans with approval\_date on or before this date. Empty = no upper bound.

## `minAmount` (type: `integer`):

Only return loans whose gross approval amount is at least this many dollars. Empty = no minimum.

## `mode` (type: `string`):

'loans' emits one normalized loan row per result (with risk flags). 'rollup-by-lender', 'rollup-by-naics', and 'rollup-by-state' instead emit one aggregate row per lender / NAICS industry / state (loan count, total & avg approved $, charge-off/default proxy rate, jobs supported).

## `flagRisk` (type: `boolean`):

In 'loans' mode, compute per-loan risk\_flags and risk\_score over the result set: high loan-amount-per-job outliers, charged-off/default loans, and single-lender concentration. Ignored in rollup modes.

## `maxResults` (type: `integer`):

Hard cap on the number of loan records fetched and scanned (the source files are large — this bounds cost and runtime). In rollup modes, rollups are computed over the loans fetched under this cap.

## `maxScanRows` (type: `integer`):

Upper bound on how many CSV rows are scanned per FOIA file before stopping. Raise for exhaustive rollups over the full loan history; lower for faster, cheaper sampling. Only matters when filters match few rows.

## Actor input object example

```json
{
  "program": "504",
  "state": "TX",
  "mode": "loans",
  "flagRisk": true,
  "maxResults": 50,
  "maxScanRows": 500000
}
```

# Actor output Schema

## `results` (type: `string`):

Normalized SBA loans or portfolio rollups in the default dataset.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "program": "504",
    "state": "TX",
    "mode": "loans",
    "maxResults": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("malonestar/sba-loan-portfolio-explorer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "program": "504",
    "state": "TX",
    "mode": "loans",
    "maxResults": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("malonestar/sba-loan-portfolio-explorer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "program": "504",
  "state": "TX",
  "mode": "loans",
  "maxResults": 50
}' |
apify call malonestar/sba-loan-portfolio-explorer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=malonestar/sba-loan-portfolio-explorer",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/wTEWC7paQXcZXvwA5/builds/6dUotSlsHm0Bh3pog/openapi.json
