Skill Tracer
Skills › Scientific Agent Skills › database-lookup › materials-project.md

materials-project.md

136 lines · skills/database-lookup/references/materials-project.md at 5f2bc03

Open on GitHub
1# Materials Project API
2

Materials Project API

Raw lines 1 to 2
3## Base URL
4
5```
6https://api.materialsproject.org
7```
8

Base URL

https://api.materialsproject.org
Raw lines 3 to 8
9## Authentication
11Requires a free API key. Register at https://materialsproject.org (free account).
13| Env Variable | Header |
14|---|---|
15| `MP_API_KEY` | `X-API-KEY: your_key_here` |
17Data endpoint requests must include the API key header. The client's
18`GET /heartbeat` service check is unauthenticated.

Authentication

Requires a free API key. Register at https://materialsproject.org (free account).

Env VariableHeader
MP_API_KEYX-API-KEY: your_key_here

Data endpoint requests must include the API key header. The client's GET /heartbeat service check is unauthenticated.

Raw lines 9 to 19
20## API Version
22Use the current API at `api.materialsproject.org` with the `mp-api` client. The legacy API used `/rest/v2/`; that path is not the version label for the current API. The authoritative endpoint schema is https://api.materialsproject.org/openapi.json.

API Version

Use the current API at api.materialsproject.org with the mp-api client. The legacy API used /rest/v2/; that path is not the version label for the current API. The authoritative endpoint schema is https://api.materialsproject.org/openapi.json.

Raw lines 20 to 23
24## Key Endpoints

Key Endpoints

Raw lines 24 to 25
26### Search materials by formula or elements
28```
29GET /materials/summary/?formula=Fe2O3&_fields=material_id,formula_pretty,band_gap,formation_energy_per_atom
30```
32```
33GET /materials/summary/?elements=Si,O&_fields=material_id,formula_pretty,band_gap
34```
36Query parameters:
37- `formula` — exact chemical formula (e.g., `Fe2O3`, `SiO2`)
38- `chemsys` — chemical system, dash-separated (e.g., `Fe-O`, `Li-Fe-P-O`)
39- `elements` — comma-separated elements that must be present
40- `band_gap_min` / `band_gap_max` — filter by band gap (eV)
41- `is_stable` — `true` to return only thermodynamically stable phases
42- `_fields` — comma-separated list of fields to return
43- `_limit` — max results (default 100, max 1000)
44- `_skip` — offset for pagination
45- `_page` / `_per_page` — alternative page-based pagination, which takes
46 precedence over `_limit` / `_skip`; `_per_page` defaults to 100 and is capped
47 at 1000. Use one pagination style consistently.

Search materials by formula or elements

GET /materials/summary/?formula=Fe2O3&_fields=material_id,formula_pretty,band_gap,formation_energy_per_atom
GET /materials/summary/?elements=Si,O&_fields=material_id,formula_pretty,band_gap

Query parameters:

  • formula — exact chemical formula (e.g., Fe2O3, SiO2)
  • chemsys — chemical system, dash-separated (e.g., Fe-O, Li-Fe-P-O)
  • elements — comma-separated elements that must be present
  • band_gap_min / band_gap_max — filter by band gap (eV)
  • is_stable — true to return only thermodynamically stable phases
  • _fields — comma-separated list of fields to return
  • _limit — max results (default 100, max 1000)
  • _skip — offset for pagination
  • _page / _per_page — alternative page-based pagination, which takes precedence over _limit / _skip; _per_page defaults to 100 and is capped at 1000. Use one pagination style consistently.
Raw lines 26 to 48
49### Get material by ID
51```
52GET /materials/summary/?material_ids=mp-149&_fields=material_id,formula_pretty,band_gap,formation_energy_per_atom,symmetry
53```
55Legacy material IDs such as `mp-149` remain accepted. The current schema also supports padded alphabetic AlphaIDs and `id_format=legacy|alpha`; preserve returned identifiers rather than validating only digits.

Get material by ID

GET /materials/summary/?material_ids=mp-149&_fields=material_id,formula_pretty,band_gap,formation_energy_per_atom,symmetry

Legacy material IDs such as mp-149 remain accepted. The current schema also supports padded alphabetic AlphaIDs and id_format=legacy|alpha; preserve returned identifiers rather than validating only digits.

Raw lines 49 to 56
57### Available fields (summary)
59`material_id`, `formula_pretty`, `formula_anonymous`, `chemsys`, `volume`, `density`, `density_atomic`, `symmetry`, `band_gap`, `cbm`, `vbm`, `is_gap_direct`, `is_metal`, `is_magnetic`, `ordering`, `total_magnetization`, `formation_energy_per_atom`, `energy_above_hull`, `is_stable`, `equilibrium_reaction_energy_per_atom`, `nsites`, `elements`, `nelements`, `composition`, `structure`

Available fields (summary)

material_id, formula_pretty, formula_anonymous, chemsys, volume, density, density_atomic, symmetry, band_gap, cbm, vbm, is_gap_direct, is_metal, is_magnetic, ordering, total_magnetization, formation_energy_per_atom, energy_above_hull, is_stable, equilibrium_reaction_energy_per_atom, nsites, elements, nelements, composition, structure

Raw lines 57 to 60
61### Crystal structure
63```
64GET /materials/summary/?material_ids=mp-149&_fields=structure
65```
67Returns the structure as a pymatgen-compatible JSON dict with lattice parameters and atomic sites.

Crystal structure

GET /materials/summary/?material_ids=mp-149&_fields=structure

Returns the structure as a pymatgen-compatible JSON dict with lattice parameters and atomic sites.

Raw lines 61 to 68
69### Elastic properties
71```
72GET /materials/elasticity/?material_ids=mp-149&_fields=material_id,bulk_modulus,shear_modulus,elastic_tensor
73```

Elastic properties

GET /materials/elasticity/?material_ids=mp-149&_fields=material_id,bulk_modulus,shear_modulus,elastic_tensor
Raw lines 69 to 74
75### Electronic structure (band structure / DOS)
77The current schema has collection routes `/materials/electronic_structure/`,
78`/materials/electronic_structure/bandstructure/` and `/materials/electronic_structure/dos/`,
79not a material ID appended to those paths. Retrieve full band structures/DOS
80through `MPRester.get_bandstructure_by_material_id()` or
81`MPRester.get_dos_by_material_id()` with the current `mp-api` client. Version
820.46.5 resolves metadata and retrieves electronic-structure data from Delta
83tables; do not reconstruct obsolete task/blob download URLs. These authenticated
84examples are illustrative.

Electronic structure (band structure / DOS)

The current schema has collection routes /materials/electronic_structure/, /materials/electronic_structure/bandstructure/ and /materials/electronic_structure/dos/, not a material ID appended to those paths. Retrieve full band structures/DOS through MPRester.get_bandstructure_by_material_id() or MPRester.get_dos_by_material_id() with the current mp-api client. Version 0.46.5 resolves metadata and retrieves electronic-structure data from Delta tables; do not reconstruct obsolete task/blob download URLs. These authenticated examples are illustrative.

Raw lines 75 to 85
86### Thermodynamic properties
88```
89GET /materials/thermo/?formula=Fe2O3&_fields=material_id,formation_energy_per_atom,energy_above_hull
90```

Thermodynamic properties

GET /materials/thermo/?formula=Fe2O3&_fields=material_id,formation_energy_per_atom,energy_above_hull
Raw lines 86 to 91
92### Example: Find stable oxides with band gap > 2 eV
94```
95GET /materials/summary/?elements=O&band_gap_min=2&is_stable=true&_fields=material_id,formula_pretty,band_gap,formation_energy_per_atom&_limit=10
96```

Example: Find stable oxides with band gap > 2 eV

GET /materials/summary/?elements=O&band_gap_min=2&is_stable=true&_fields=material_id,formula_pretty,band_gap,formation_energy_per_atom&_limit=10
Raw lines 92 to 97
98## Response Format
100```json
102 "data": [
103 {
104 "material_id": "mp-149",
105 "formula_pretty": "Si",
106 "band_gap": 0.6105,
107 "formation_energy_per_atom": 0.0
108 }
109 ],
110 "meta": {
111 "total_doc": 1
112 }
114```

Response Format

{
  "data": [
    {
      "material_id": "mp-149",
      "formula_pretty": "Si",
      "band_gap": 0.6105,
      "formation_energy_per_atom": 0.0
    }
  ],
  "meta": {
    "total_doc": 1
  }
}
Raw lines 98 to 115
116## Rate Limits
118- Official guidance describes limits starting at 25 requests/second, not a guaranteed account quota; honor HTTP 429 and returned retry guidance. See https://docs.materialsproject.org/downloading-data/using-the-api/tips-for-large-downloads.
119- Batch requests preferred over many individual calls
120- Use `_fields` to reduce payload size and improve performance
121- The Python client `mp-api` handles pagination and retries automatically

Rate Limits

  • Official guidance describes limits starting at 25 requests/second, not a guaranteed account quota; honor HTTP 429 and returned retry guidance. See https://docs.materialsproject.org/downloading-data/using-the-api/tips-for-large-downloads.
  • Batch requests preferred over many individual calls
  • Use _fields to reduce payload size and improve performance
  • The Python client mp-api handles pagination and retries automatically
Raw lines 116 to 122
123## Error Format
125```json
127 "detail": "Not authenticated"
129```
131HTTP 401 indicates an authentication failure; HTTP 429 indicates rate limiting.
132A collection search with no matching materials can return HTTP 200 with
133`data: []`; do not require HTTP 404 to detect an empty result. The structure
134convenience helper can return `None`, while band-structure/DOS helpers raise
135`MPRestError` when required metadata or calculation data is absent. A 404 alone
136does not distinguish an unknown route from missing data.

Error Format

{
  "detail": "Not authenticated"
}

HTTP 401 indicates an authentication failure; HTTP 429 indicates rate limiting. A collection search with no matching materials can return HTTP 200 with data: []; do not require HTTP 404 to detect an empty result. The structure convenience helper can return None, while band-structure/DOS helpers raise MPRestError when required metadata or calculation data is absent. A 404 alone does not distinguish an unknown route from missing data.

Raw lines 123 to 136