# /materialsproject/structures/search

`POST /api/materialsproject/structures/search`

Price: 20 credits

Search Materials Project crystal structures by composition. Filter by the elements a structure must, may or must not contain, by how many distinct elements and how many atomic sites it has, by exact reduced or anonymous formula, by a formula prefix or substring, or by a list of structure ids; order by id, site count, element count or last modification. Returns composition, all four chemical formulas, site and element counts, and formation energy and energy above hull per DFT functional. Atomic coordinates are not included — fetch materialsproject/structures for those.

## How to use it

This is a crystal-structure and composition index, not the Materials Project property database: it answers 'which materials are made of these elements, in this stoichiometry, in a cell this size' and nothing else. Band gap, metallicity, density, volume, symmetry and space group, magnetism, elastic and dielectric constants, phonons, electrodes, synthesis routes and ICSD cross-references are absent from this mirror and cannot be filtered on or returned by any endpoint here; `thermodynamics` (formation energy, energy above hull) is the only property carried. The corpus is a frozen snapshot whose newest record is from March 2023, so a material published since then is missing rather than unstable. Composition filters combine with AND, so elements_all plus element_count is how you ask for a binary silicon oxide rather than anything containing Si and O. Formulas must be written the source's way — formula_reduced is alphabetical and divided down (O2Si, not SiO2), formula_anonymous replaces elements by A, B, C in descending count (A2B). There is no free-text or material-name search: a name such as 'quartz' returns nothing, so start from elements or a formula. Feed a result id to materialsproject/structures when you need the atomic positions. Two distinct structures can share the same formula and site count (different polymorphs of the same composition), so `immutable_id` is the field that uniquely identifies a structure, not the combination of formula and site count.

## Parameters

- `access-token` (string, required)

## Request body

- `timeout` (integer) — Max scrapping execution timeout (in seconds) (default: 300; min: 20; max: 1500)
- `elements_all` (array, nullable) — Only structures containing every one of these elements (examples: ["Si","O"])
- `elements_any` (array, nullable) — Only structures containing at least one of these elements (examples: ["Ga","N"])
- `elements_none` (array, nullable) — Exclude structures containing any of these elements (examples: ["O"])
- `element_count` (integer, nullable) — Exact number of distinct elements in the structure (min: 1; max: 20)
- `element_count_min` (integer, nullable) — Minimum number of distinct elements (min: 1; max: 20)
- `element_count_max` (integer, nullable) — Maximum number of distinct elements (min: 1; max: 20)
- `site_count_min` (integer, nullable) — Minimum number of atomic sites in the cell (min: 1)
- `site_count_max` (integer, nullable) — Maximum number of atomic sites in the cell (min: 1)
- `formula_reduced` (string, nullable) — Exact reduced formula, elements in alphabetical order and the ratio divided down (examples: "O2Si")
- `formula_anonymous` (string, nullable) — Exact anonymous formula: the stoichiometry with the elements replaced by A, B, C (examples: "A2B")
- `formula_contains` (string, nullable) — Substring of the descriptive formula (examples: "Si")
- `formula_starts_with` (string, nullable) — Prefix of the reduced formula (examples: "O")
- `structure_ids` (array, nullable) — Return only these structure ids (examples: ["mp-149","mp-2"])
- `sort` (string, nullable) — Field the results are ordered by. Unset is the source order (one of: "id", "site_count", "element_count", "last_modified")
- `sort_desc` (boolean) — Order descending. Applies only when sort is set (default: false)
- `count` (integer, required) — Number of structures to return (min: 1; max: 5000)

## Response

### 200 — Successful Response

- `@type` (string) (default: "MaterialsprojectStructure")
- `id` (string, required)
- `source_url` (string) (default: "")
- `immutable_id` (string) (default: "")
- `last_modified_at` (integer, nullable)
- `formula_descriptive` (string) (default: "")
- `formula_reduced` (string) (default: "")
- `formula_hill` (string) (default: "")
- `formula_anonymous` (string) (default: "")
- `chemical_system` (string) (default: "")
- `elements` (array) (default: [])
- `element_ratios` (array) (default: [])
- `element_count` (integer, nullable)
- `site_count` (integer, nullable)
- `dimension_types` (array) (default: [])
- `periodic_dimension_count` (integer, nullable)
- `structure_features` (array) (default: [])
- `thermodynamics` (array) (default: [])
  - `@type` (string) (default: "MaterialsprojectThermo")
  - `functional` (string) (default: "")
  - `thermo_id` (string) (default: "")
  - `energy_above_hull` (number, nullable)
  - `formation_energy_per_atom` (number, nullable)
  - `last_updated_at` (integer, nullable)

## Errors

### 422 — Validation Error

The request body did not validate

What to do: Check the fields against this schema. A URN with the wrong prefix is the most common cause.

- `detail` (array)
  - `loc` (array, required)
  - `msg` (string, required)
  - `type` (string, required)
  - `input` (any)
  - `ctx` (object)

### 408

The request ran past its time limit

What to do: Raise `timeout` in the request body, up to the maximum this endpoint documents. Lowering `count` or turning off the `with_*` flags also helps, because less work finishes sooner.

### 412

The entity was not found, or a precondition failed

What to do: Retrying will not help: either the entity does not exist, or the input points at a different one.

### 429

Too many requests: a rate limit or a usage window is exhausted

What to do: When the response carries an X-Retry-After header, wait that many seconds and retry: the same number is in the body as `detail.retry_after`, and the limit clears once that window passes. The message in the body names the limit that was hit.

### 500

Something broke on our side

What to do: Retrying will not help. If it keeps happening, send us the X-Request-ID from the response headers.

### 529

Rate limit reached, or the endpoint is overloaded

What to do: Wait at least 30 seconds, then retry.

## Response envelope

Success: Array of objects (may be empty if no results)

Error: Error may coexist with partial results if it occurs mid-execution. Check X-Error header and status code.

Every response carries these headers:

- `X-Error` — Error message text (present only on error)
- `X-Request-ID` — Unique request identifier
- `X-Execution-Time` — Execution time in seconds
- `X-Result-Count` — How many records the body carries. 0 means an empty result, which is a normal answer and not by itself an error. A non-zero count can come back together with X-Error when the failure happened partway through — read this header and X-Error independently.
- `X-Total-Available-Results` — How many records exist for this query, when the endpoint can say. On a `dry_run` request this is the answer and the body is empty. It saturates: the endpoint's documented maximum means 'at least that many', any smaller number is exact.
- `X-Warning` — Present when the request body carried keys this endpoint does not document. They were ignored, so any filter you meant to apply through them did not apply. Check the spelling against this schema and retry.
- `X-Retry-After` — Seconds to wait before retrying. Present only on 429.

