The Materials API

From Wiki
Revision as of 10:08, 30 August 2012 by Shyuep (talk | contribs) (materials (calculated information))

Jump to: navigation, search

The Materials API (MAPI) is an open API for accessing Materials Project data based on REpresentational State Transfer (REST) principles. In a RESTful system, information is organized into resources, each of which is uniquely identified via a uniform resource identifier (URI).


In the Materials Project, resources are generally packages of information about a material or an analysis (e.g., a reaction). Currently supported information types (v1 of the REST API) include the following:

  1. Materials - Standard calculated or experimental information about a material.
  2. Battery - Battery application specific information
  3. Reaction - Information about a reaction.


SSL Encryption

All requests to the Materials API must be done over HTTPS. Non-secure http requests are not allowed and will result in a HTTP 403 (Forbidden) response.

API keys

To access the Materials API, you will need your API key. You can obtain your API key by logging into the Materials Project website, and going to Your API key and a button to regenerate the key is provided at the top of the page.

Note that the API key effectively allows access to Materials Project data via your account. You should therefore make all efforts to keep it secret and under no circumstances should you share your API key with anyone. You will be held responsible for any violations conducted using your API key. Should anyone else require access to the MAPI, they should register for an account on the Materials Project and generate their own API keys.

All MP https requests must supply API key as:

  • A x-api-key header, e.g., {‘X-API-KEY’: ‘YOUR_API_KEY’} (recommended method) or
  • As a GET (e.g., ?API_KEY=YOUR_API_KEY) or POST variable, e.g., {‘API_KEY’: ‘YOUR_API_KEY’}

The following is an example of a full url requesting for information of the material with material id 1234 with the API key supplied as a GET variable.


Write something about caps and daily limits.

API documentation

General URI Format

All URIs in the MAPI are of the general form{request_type}[/{identifier}][/{parameters}]
  1. The initial part of the URI ( is a preamble, specifying a https REST request. The v1 denotes version 1 of the MAPI, to provide flexibility to support multiple versions of the API in future.
  2. {request_type} specifies the kind of information or operation being requested. Currently supported request types include "materials", "battery", "reaction", "mpquery" and "api_check".
  3. {identifier} is an identifier for the specific information requested. Depending on the {request_type}, an identifier may or may not be necessary.
  4. {parameters} - Some requests require additional parameters to be provided.

General Response Format

All responses from the Materials API are in the JavaScript Object Notation (JSON). XML is not supported currently. The responses generally are of the following form:

    valid_response: true,
    version: {
        pymatgen: "2.2.0",
        db: "2012.07.09",
        rest: "1.0"
    created_at: "2012-08-29T05:21:51.232084",
    copyright: "Copyright 2012, The Materials Project",
    response: {response_content}


materials (calculated information)

GET{material id, formula, or chemical system}/vasp/{property}

Obtain material information based on an identifier. The response is always a list of associative arrays, i.e., [ {key:value, ... }, {... }, ...]. The identifier can be a Materials Project material id (e.g., 1234), a formula, e.g. (Fe2O3), or a chemical system ("-" separated list of elemments, e.g., Li-Fe-O). Specifying a formula or chemical system will return information for all materials with that formula or in that chemical system respectively. Note that a chemical system includes all sub-systems, i.e., the Li-Fe-O chemical system will include all Li, Fe, O, FexOy, LixOy, LixFey, LixFeyOz compounds.

A property may be specified to request a specific subset of information. If no property is specified, a set of typically useful properties is returned. The materials id is always returned as part of the response. Currently supported properties and their definitions are as follows:

A nice formula where the element amounts are normalized
The full explicit formula for the unit cell
Calculated vasp energy for structure
Calculated vasp energy normalized to per atom in the unit cell
Calculated formation energy from the elements normalized to per atom in the unit cell
Final relaxed volume of structure
Number of sites in the unit cell
A boolean indicating whether the structure was calculated using the Hubbard U extension to DFT
An array of Hubbard U values, where applicable.
The elements in the structure
The number of elements in the structure
      "e_above_hull", "hubbards",
                       "is_compatible", "spacegroup",
                       "band_gap", "density", "icsd_id")

supported_objects = ("structure", "initial_structure", "final_structure",

                    "entry", "dos", "bandstructure")

Example responses:

  1. File:24972.txt
  2. File:Fe2O3.txt
  3. File:Li-Fe-O.txt
  4. File:TiO2 energy.txt
  5. File:C structure.txt




Checks if supplied API key (via GET, POST or x-api-key header) is a valid API key.

Example response:

    valid_response: true,
    api_key_valid: true