Guide

How to find medical practices by specialty with NPI taxonomy codes

How taxonomy codes work in the NPPES NPI file, why matching only the primary code misses up to 48% of practices in a specialty, and a query that finds them.

Every record in the National Plan and Provider Enumeration System (NPPES) file, the federal registry of National Provider Identifiers (NPIs), lists between 1 and 15 specialty codes, called taxonomy codes, and flags one of them as primary. The way a list matches on these codes determines which practices it includes. For some specialties, matching on the primary code alone finds about half of the organizations that list the specialty.

This guide is for founders, sales and revenue leaders, and go-to-market (GTM) engineers who build lists of medical practices by specialty for lead generation, lead research, market segmentation or total addressable market (TAM) calculations. It covers how taxonomy codes work, how many organizations each matching method finds, how to exclude organizations that are not practices, and a working query.

Rather skip the codes? In Narwhalim you search medical practices by specialty name and state. Start browsing free: any specialty, any state, the top 25 practices. No card.

All counts are from the June 2026 NPPES file and refer to organization records (Type 2 NPIs).

What are NPI taxonomy codes

Taxonomy codes come from the Health Care Provider Taxonomy code set, maintained by the National Uniform Claim Committee (NUCC). The code set has more than 800 codes. Each code is 10 characters, for example 207W00000X (Ophthalmology) or 261QI0500X (Infusion Therapy clinic). The NUCC publishes the full code set with names and definitions as a free download at nucc.org.

In the NPPES file, each record lists its codes in the columns Healthcare Provider Taxonomy Code_1 through _15, and marks one as primary in Healthcare Provider Primary Taxonomy Switch_1 through _15. The file contains codes only. Specialty names come from the NUCC code set.

Loading the taxonomy codes

The query below loads organization records with all of their taxonomy codes into a list column, plus the code flagged as primary. It uses DuckDB in Python (pip install duckdb) and reads the main NPPES file (npidata_pfile_…csv) directly.

import duckdb

SRC = "npidata_pfile_20050523-20260607.csv"  # the date range in the name changes every month

slots = range(1, 16)
codes = ", ".join(f'"Healthcare Provider Taxonomy Code_{i}"' for i in slots)
primary = ", ".join(
    f"""CASE WHEN "Healthcare Provider Primary Taxonomy Switch_{i}" = 'Y'
             THEN "Healthcare Provider Taxonomy Code_{i}" END"""
    for i in slots
)

con = duckdb.connect("registry.duckdb")
con.execute(f"""
CREATE OR REPLACE TABLE orgs AS
SELECT
    "NPI"                                                          AS npi,
    "Provider Organization Name (Legal Business Name)"             AS org_name,
    "Provider Business Practice Location Address City Name"        AS city,
    "Provider Business Practice Location Address State Name"       AS state,
    "Provider Business Practice Location Address Telephone Number" AS phone,
    list_filter([{codes}], x -> x IS NOT NULL)                     AS taxonomy_codes,
    coalesce({primary}, "Healthcare Provider Taxonomy Code_1")     AS primary_taxonomy
FROM read_csv('{SRC}', header = true, all_varchar = true)
WHERE "Entity Type Code" = '2'
""")

I wrote about downloading the NPPES file and the rest of its columns here: How to download the NPPES NPI file and build a list of medical practices.

How many taxonomy codes organizations list

1,556,994 organizations (80.4%) list one taxonomy code. 380,368 (19.6%) list more than one, and 47,101 list five or more.

Primary taxonomy code vs. all taxonomy codes

A specialty can be matched three ways:

  1. The first code column (Healthcare Provider Taxonomy Code_1)
  2. The primary code, flagged by the switch column
  3. Any of the 15 codes

Organization counts for each method:

Specialty (taxonomy code) First column Primary Any code Missed by primary
Infusion therapy clinic (261QI0500X) 1,152 1,025 1,969 48%
Cardiovascular disease (207RC0000X) 8,864 9,697 12,923 25%
Endoscopy center (261QE0800X) 530 493 605 19%
Urgent care (261QU0200X) 9,668 11,358 13,809 18%
Dermatology (207N00000X) 5,904 6,634 8,000 17%
Ophthalmology (207W00000X) 8,845 10,300 11,886 13%
Sleep disorder diagnostic center (261QS1200X) 2,875 2,969 3,421 13%
Optometry (152W00000X) 34,212 33,826 36,919 8%
Ambulatory surgery center (261QA1903X) 13,453 13,746 14,574 6%

The first column returns more organizations than the primary code for some specialties (infusion therapy) and fewer for others (urgent care). It is not a consistent approximation of the primary code.

Matching on the primary code alone misses 48% of the organizations that list infusion therapy and 25% of those that list cardiovascular disease.

Why specialties appear as secondary taxonomy codes

Organizations with more than one service line flag one code as primary and list the others as secondary. 944 organizations list infusion therapy without flagging it as primary. Their most common primary codes:

Primary taxonomy code Organizations
Clinic/Center, Multi-Specialty (261QM1300X) 127
Home Infusion Therapy Pharmacy (3336H0001X) 123
Clinic/Center (261Q00000X) 56
Clinic/Center, Primary Care (261QP2300X) 44
Home Health (251E00000X) 41
Home Infusion (251F00000X) 37

The group includes clinics that offer infusion as one service and also pharmacies and agencies that provide infusion in patients' homes. Matching on any code includes both.

Excluding pharmacies, home health agencies and suppliers

The first two or three characters of a taxonomy code identify its family. Organization counts by the family of the primary code:

Taxonomy family Organizations
Physicians (20…) 346,612
Clinics and centers (26…) 280,841
Agencies: home health, in-home care, community behavioral health (25…) 268,562
Suppliers: pharmacies, medical equipment (33…) 211,858
Behavioral health and social service providers (10…) 158,654
Dental (12…) 110,059
Nursing and custodial care facilities (31…) 78,227
Transportation (34…) 53,746

Agencies and suppliers account for 24.8% of organization records.

To build a specialty list, match the specialty on any code, then exclude families by primary code:

CREATE OR REPLACE TABLE infusion_targets AS
SELECT npi, org_name, city, state, phone, primary_taxonomy,
       primary_taxonomy = '261QI0500X' AS matched_on_primary
FROM orgs
WHERE list_contains(taxonomy_codes, '261QI0500X')
  AND primary_taxonomy NOT LIKE '33%'   -- suppliers, including pharmacies
  AND primary_taxonomy NOT LIKE '251%'  -- agencies, including home health and home infusion
ORDER BY matched_on_primary DESC, state, org_name;

The query returns 1,694 organizations: 1,025 with infusion therapy as the primary code and 669 that list it in another slot. It excludes 275 records: 176 pharmacies, 91 agencies and 8 equipment suppliers. The matched_on_primary column can be used to sort or segment the list.

Taxonomy code prefixes do not define a specialty

Below the family level, codes that share a prefix can be unrelated:

  • 207RC0000X is Cardiovascular Disease and 207RC0001X is Clinical Cardiac Electrophysiology. 207RC0200X is Critical Care Medicine.
  • Interventional Cardiology is 207RI0011X. Pediatric Cardiology is 2080P0202X, in the pediatrics family.

A specialty definition should be an explicit list of codes taken from the NUCC code set, not a prefix match such as LIKE '207RC%'.

Generic taxonomy codes

Some organizations use a primary code that does not identify a specialty:

Primary taxonomy code Organizations
Specialist (174400000X) 28,456
Clinic/Center (261Q00000X) 27,221
Clinic/Center, Multi-Specialty (261QM1300X) 10,978

These total 66,655 organizations. 8,864 of them list at least one other code. For the rest, the specialty can be inferred from the taxonomy codes of the individual providers who bill through the organization, which requires a separate dataset.

Ophthalmology and optometry taxonomy codes

2,200 organizations list both an ophthalmology code (207W…) and an optometry code (152W…). 379 organizations that list ophthalmology have optometry as their primary code. Whether combined eye care practices belong in an ophthalmology list depends on the use case. Define the inclusion rule before building the list.


Skip the build

Narwhalim is a database of U.S. medical practices for sales teams. You pick specialties by name, and each practice comes with its locations, phone numbers, the people who run it, its size and activity, which electronic health record (EHR) system it uses, and whether it's affiliated with a health system.

Start browsing free: search any specialty and state and see the top 25 practices. No card.

Just need one list? Build it here and pay per practice.