Giter Site home page Giter Site logo

mapidoc's Introduction

Important Notice

The Materials Project API is changing. For the latest information, consult the Materials Project documentation at https://docs.materialsproject.org and this page specifically to read more about the differences between the new and legacy APIs.

This repository is archived and is no longer being updated.


Introduction

This is the public repo for the documentation of the Materials API. The Materials API is a simple, flexible and efficient interface to programmatically query and interact with the Materials Project database based on the REpresentational State Transfer (REST) pattern for the web. Since its creation in Aug 2012, the Materials API has been the Materials Project’s de facto platform for data access, supporting not only the Materials Project’s many collaborative efforts but also enabling new applications and analyses.

Example notebooks

We have added a few example ipython notebooks demonstrating the features of the Materials API. The NB Viewer version is at this link. Also, you can use the Binder service (in beta) to launch an interactive notebook right now! Click the button below to open our introductory notebook. To nagivate to other notebooks, go to "File->Open" within the page and click example_notebooks to open one of them.

Binder

Using this repo

The usage of this repo follows a REST format. The primary use of this repo is to explore the Materials Project's document format and use that info for much more powerful queries with the pymatgen (Python Materials Genomics) MPRester.query() method. For more standard queries, the Materials API already has a wiki page and pymatgen already provides useful high-level functions for them.

  1. Start from the materials directory in this repo. The nested directory structure follows the MongoDB json-like document schema for the Materials Project's materials collection.

  2. In each folder, there is a README.md that describes what that key is. For example, in materials/final_energy, the README.md informs you that the final_energy key refers final calculated energy of the material. Similarly, the materials/task_id informs you that the task_id key is in fact the materials id for the Materials Project.

  3. To use this in MPRester, one may use the following code:

    from pymatgen import MPRester
    m = MPRester()
    data = m.query(criteria={"task_id": "mp-1234"}, properties=["final_energy"])
    print(data)

    The data obtained is then [{u'final_energy': -26.94736193}]. Note that the data returned is always a list of dicts.

  4. For a more complicated example, you can try:

    data = m.query(criteria={"pretty_formula": "Li2O"}, properties=["spacegroup.symbol"])

    You can identify the appropriate key by going to the materials/spacegroup/symbol subfolder. This means that the desired information is in spacegroup.symbol (concantenate all subfolders with "." and drop the initial "materials" prefix).

  5. One more very complicated example. Let's say you would like to query for the tags and icsd_ids of all materials containing Fe and O, and perhaps other elements.

    data = m.query(criteria={"elements": {"$all": ["Fe", "O"]}}, properties=["exp.tags", "icsd_ids"])

    Note that the criteria and properties follows the format (and richness) of MongoDB queries. You can refer to the MongoDB documentation for more information on how to customize queries.

It should be noted that not all materials documents contains all keys, e.g., some properties may not have been computed for certain materials yet. If you request for a key that is not present in a doc, the query will return None. For the most part, the documents are relatively consistent, especially for many of the common keys like elements, formulas, etc.

Alternative usage of this documentation

While the easiest way to use the Materials API is to leverage pymatgen's high-level interface to it, you may also directly submit a http POST query to https://www.materialsproject.org/rest/v2/query. For instance, you may wish to write your own app or queries in another language.

The https://www.materialsproject.org/rest/v2/query API provides functionality for flexible queries against the Materials Project database using MongoDB syntax, enabling queries which would otherwise not be possible using the other simpler REST forms. For example, a POST to query with parameters

criteria = '{"elements":{"$in":["Li", "Na", "K"], "$all": ["O"]}, "nelements":2}'
properties ='["formula", "formation_energy_per_atom"]'

will return the formula and formation energy per atom of all Li, Na and K oxides.

Using the command-line tool curl:

curl -s --header "X-API-KEY: <YOUR-API-KEY>" \
    https://materialsproject.org/rest/v2/query \
    -F criteria='{"elements": {"$in": ["Li", "Na", "K"], "$all": ["O"]}, "nelements": 2}' \
    -F properties='["formula", "formation_energy_per_atom"]'

Using Python and the requests library:

import json
import requests

data = {
    'criteria': {
        'elements': {'$in': ['Li', 'Na', 'K'], '$all': ['O']},
        'nelements': 2,
    },
    'properties': [
        'formula',
        'formation_energy_per_atom',
    ]
}
r = requests.post('https://materialsproject.org/rest/v2/query',
                 headers={'X-API-KEY': '<YOUR-API-KEY>'},
                 data={k: json.dumps(v) for k,v in data.items()})
response_content = r.json() # a dict

Using another language, e.g. MATLAB? See this MP discussion forum thread for more guidance. In particular, you need to treat "criteria" and "properties" as fields whose data are JSON-serialized strings.

Tips for efficient querying

Try to minimize the scope of the properties you are requesting. For example, if you are only interested in the XRD pattern for Cu Kα, do not just use properties=["xrd"] which will fetch the computed XRD patterns for all wavelengths. This results in a larger data transfer and slow queries. Instead, use properties=["xrd.Cu"].

Searching for properties

You can use Github's built-in search box at the top to search this repository for text that matches your query. For example, you can try searching for the word "spacegroup" to see the that the "spacegroup" root key exists with sub-keys such as "number" and "symbol".

Beause this repository's folder structure mirrors a material document's structure, you can also use the quick finder (keyboard shortcut: t) to interactively explore the structure.

Contributing

The initial version of this documentation is brought to you by the Materials Project development team. But it is our hope that others can contribute as well, either by cloning and editing this documentation (and sending pull requests) or just by informing us of any errors or omissions in the doc (e.g., by using the "Issues" tab).

Citing the Materials API

If you use the Materials API extensively, you may wish to cite the following publication.

Ong, S. P.; Cholia, S.; Jain, A.; Brafman, M.; Gunter, D.; Ceder, G.; 
Persson, K. a. The Materials Application Programming Interface (API): A 
simple, flexible and efficient API for materials data based on
REpresentational State Transfer (REST) principles, Comput. Mater. Sci.,
2015, 97, 209–215. doi:10.1016/j.commatsci.2014.10.037.

mapidoc's People

Contributors

chenweis avatar computron avatar dwinston avatar jdagdelen avatar mkhorton avatar shyamd avatar shyuep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mapidoc's Issues

aliases

How can we document aliases in a graceful way within this repo? Current aliases accepted for materials queries:

energy = final_energy
energy_per_atom = final_energy_per_atom
formula = reduced_cell_formula
final_structure = structure
band_gap = band_gap.search_gap.band_gap
tags = exp.tags
crystal_system = spacegroup.crystal_system
material_id = task_id

Archive Repository

This repo appears like a reasonable place to post an API issue although it has nothing to do with the new MP API. I'm suggesting the README gets updated to point all issues and questions to new docs/matsci board and archive this repo so it people can't post here expecting a response.

Still need READMEs for many top-level keys

Check off when done.

  • band_structure
  • band_structure_uniform
  • created_at
  • decomposes_to
  • delta_volume
  • dos
  • efermi
  • elasticity
  • exp
  • final_energy_per_atom
  • formation_energy_per_atom
  • initial_structure
  • ionic_steps
  • is_compatible
  • is_ordered
  • magnetic_type
  • nelements
  • nkpts
  • original_task_id
  • oxide_type
  • pseudo_potential
  • run_stats
  • snl
  • snl_final
  • snlgroup_changed
  • snlgroup_id
  • snlgroup_id_final
  • static
  • total_magnetization
  • updated_at

experimental formation energy

Hi, I am wondering whether the experimental formation energy is public. For example, the Li2O has experimental formation energy on MP as -2.06 eV/atom. But I didn't find the corresponding property in the api.

Thanks in advance.

Manual specification of INCAR tags by user.

Can we have a cell in which the INCAR tags of the calculations are specified by the user.

I have recently come to find out that the fireworks which are getting cancelled (fizzled) are due to automatic consideration of the tetrahedron method (ISMEAR=-5) in the MP calculations. In order to avoid this, is there a way to manually specify the calculations and parameters for a particular submission?

Thanks!

Experimentally realized materials

Hi!

Is there any information in the database whether a particular material has been experimentally realized or not?

Best wishes,
Jonas

receiving no data for "input.parameters"

I am trying to check whether the data for the material is based on GW calculation. I found that it is under input.parameters.MODEL_GW. But when I request "input.parameters", there seems to be no data for all material.
data = m.query(criteria={ "input.parameters":{"$exists":True}, }, properties=["pretty_formula","input.parameters"])
Output: []

I am wondering whether I made some mistake or there is really no data for "input.parameters".
Besides, is there any other way to know whether the material's data is based on GW calculation?
Thanks!

accidental deletions?

Hey @jdagdelen it looks like you deleted e.g. the root README in your last commit. Please fix to still include whatever you wanted.

No module named 'pymatgen.phasedigram.pdmaker

I am trying to draw the phase diagram for a structure but it gives me an error in the importing the PhaseDigram. However the PDPlotter is working and no error has been showed. and the werried thing is that is drawing the phase diagram with the error !
any Help !

why are pymatgen examples in this repo?

I searched for "phonon" because I wanted to see if MAPI had a way for me to get the phonon information

I didn't find it, but the repo has a notebook about plotting phonon band structure that has nothing to do with materials API. There seem to be many pymatgen examples that don't involve MAPI at all that are in this repo. Not sure why? Pymatgen has its own page dedicated to pymatgen examples: https://matgenb.materialsvirtuallab.org

units on volume

Please add units to volume. It looks like Angstrom cubed.

Retrieving only entries that match experimentally-determined crystal structure.

Hello,

I'm trying to find in the documentation a way to query all entries that match experimentally-determined crystal structure. I'm interested in band gap and formation energy, and made a query like this:

with MPRester("api_key") as mpr:
    
    entries= mpr.query(criteria = {"band_gap" : {"$gt":0.5}}, properties = ["band_gap", "formation_energy_per_atom"])

Is it possible to add something in the above code to fulfil my request?

Many thanks

Plans to add topological classification to properties?

Topological classification from the Topological Materials Database is available on the MP website. However, it cannot be accessed through the API. Are there any plans to add this to the list of searchable properties?

Could not find docs to use reaction calculator in materials API

In the official docs for materials API only 'material' resource is explained, I wanted to use the reaction calculator as well. I am finding it difficult to find general URL format for reaction calculator. What will be the 'identifier' and 'Parameters' for 'reaction' request type in the following URL
https://www.materialsproject.org/rest/v2/{request_type}[/{identifier}][/{parameters}]
Any help will be appreciated @dwinston @shyuep

How can I obtain a mass of mp-id's property through ”MPRester()“or ”requsets()“ more quickly?

Dear
I have a list of mp_id which is named as mp_list and is about 40k entries. The code can be formulated as:

for i, mp_id in enumerate(tqdm(mp_list)):
  With open MPRester(API_KEY) as m:
    crystal_info = m.get_doc(mp_id) 

It did work and took about few hours, last month. But when I retried yesterday, it no longer worked, and would take me a about 300+ hours. Besides, when the progress bar reached about 2k/40k, the request was denied. So, I think whether any error ocurred when I need to obtain a large batch of mp_id's data using the code? This problem has been bothering me for days. I would be appreciated if you can give me some advice about it.

ICSD compounds returning 'icsd_id' : None

For example, see mp-30158 (Sr3Ga4O9), which appears to have an ICSD number of 51546 according to https://materialsproject.org/materials/mp-30158/. However, the result of a query using the API returns:
"{'icsd_id': None, 'material_id': 'mp-30158', 'pretty_formula': 'Sr3Ga4O9'}".

Another example is mp-1098 (Yb4As3) which shows ICSD IDs 153671 42685 611589 on the site but returns:
"{'icsd_id': None, 'material_id': 'mp-1098', 'pretty_formula': 'Yb4As3'}" when queried.

Unique icsd_id

Hello,
My question is if it is possible to query for a structure's specific ICSD number through pymatgen. I am aware that the "icds_id" property is no longer available, but is there any other way to get this?
For example:
-material id=mp-20305
-actual ICSD number is 24518
However, "icsd_ids" returns all of the following:
[610682 610687 610699 43974 43360 610683 610697 610694 190415 184924 185083 610689 44845 610686 610700 24518 610684 610698 181197 610685 165462 600849 610695 610701 41444]
Thank you very much for your help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.