Getting started overview

To begin utilizing the Materials Platform for Data Science (MPDS) API, the initial steps involve account creation, obtaining API credentials, and executing a test request. The platform is designed for programmatic access to a database of materials properties and structures, supporting various materials science applications from academic research to industrial R&D. The primary method of interaction is through a RESTful API, with a dedicated Python SDK available to streamline development MPDS API reference. Users can start with a free tier that offers limited functionality, or opt for a paid plan for expanded access MPDS pricing page.

The process typically includes:

  1. Registering for an MPDS account.
  2. Generating an API key from the user dashboard.
  3. Installing the Python SDK (if preferred).
  4. Making an authenticated API call to retrieve materials data.

This guide focuses on these core steps to ensure a rapid onboarding experience, enabling users to fetch data and integrate it into their workflows quickly. Understanding the fundamental principles of REST APIs, such as HTTP methods and request/response structures, can be beneficial for advanced usage Mozilla's REST API explanation.

Quick reference table

Step What to do Where
1. Sign up Create a new user account MPDS homepage
2. Get API Key Generate an API key from your profile MPDS user dashboard (after login)
3. Install SDK (Optional) Install the Python SDK via pip Command line (pip install mpds-api)
4. Make Request Execute a simple data query Python script or curl command
5. Explore Docs Review API endpoints and parameters MPDS API documentation

Create an account and get keys

Access to the Materials Platform for Data Science API requires an authenticated account and an associated API key. This key serves as your credential for all API interactions, ensuring that requests are authorized and usage can be tracked against your account's plan limits.

Account registration

  1. Visit the MPDS homepage: Navigate to the official MPDS website.
  2. Initiate signup: Look for a 'Sign Up' or 'Register' button, typically located in the top right corner of the page.
  3. Complete registration form: Provide the required information, which usually includes your email address, a password, and potentially your affiliation or intended use case. Agree to the terms of service and privacy policy.
  4. Verify email: An email verification link will be sent to the address provided. Click this link to activate your account. Without verification, you may not be able to log in or access all features.

Upon successful registration and email verification, you can log in to your MPDS user dashboard.

Generating an API key

Once logged into your MPDS account, you will need to generate an API key. This key is a unique string that authenticates your API requests.

  1. Access dashboard: Log in to your MPDS account.
  2. Navigate to API settings: Within your user dashboard, locate a section related to 'API Keys', 'Developer Settings', or 'Profile'. The exact location may vary but is usually clearly labeled.
  3. Generate new key: There will typically be an option to 'Generate New Key' or 'Create API Key'. Click this button.
  4. Copy and store key: The newly generated API key will be displayed. It is critical to copy this key immediately and store it securely. Treat your API key like a password; do not expose it in public repositories or client-side code. If you lose the key, you may need to generate a new one, invalidating the old one.

The API key is a long alphanumeric string. You will include this key in the header or parameters of your API requests to authenticate them. For example, the MPDS Python SDK often expects the key to be set as an environment variable or passed directly to the client constructor MPDS data access documentation.

Your first request

With an account created and an API key secured, you can now make your first request to the Materials Platform for Data Science API. This example will use the Python SDK, as it is the primary language supported and recommended for MPDS interactions MPDS API examples. Alternatively, a basic curl command is provided for direct HTTP requests.

Using the Python SDK

First, ensure you have the MPDS Python SDK installed. If not, open your terminal or command prompt and run:

pip install mpds-api

Next, create a Python script (e.g., first_mpds_request.py) and add the following code. Replace YOUR_API_KEY with the key you generated.

from mpds_client import MPDSDataRetrieval

# Replace with your actual API key
api_key = "YOUR_API_KEY"

# Initialize the MPDS client
client = MPDSDataRetrieval(api_key=api_key)

# Define a simple query for materials containing 'Fe' and 'O'
# This query searches for materials with specified chemical elements.
query = {
    "elements": ["Fe", "O"],
    "props": "atomic structure" # Requesting atomic structure data
}

# Execute the query and retrieve data
print("Sending query...")
data = client.get_data(query, fields={'formula', 'phase_name', 'sample_id'})

# Print the retrieved data (first 5 entries for brevity)
if data:
    print(f"Retrieved {len(data)} entries. Displaying first 5:")
    for i, entry in enumerate(data[:5]):
        print(f"  Entry {i+1}: {entry}")
else:
    print("No data found for the specified query.")

# Example of querying a specific property, e.g., 'elasticity'
print("\nQuerying for elasticity data...")
elasticity_query = {
    "elements": ["Cu"],
    "props": "elasticity"
}
elasticity_data = client.get_data(elasticity_query, fields={'formula', 'elasticity.bulk_modulus'})

if elasticity_data:
    print(f"Retrieved {len(elasticity_data)} elasticity entries. Displaying first 3:")
    for i, entry in enumerate(elasticity_data[:3]):
        print(f"  Entry {i+1}: {entry}")
else:
    print("No elasticity data found for the specified query.")

Run the script from your terminal:

python first_mpds_request.py

This script initializes the MPDS client with your API key, constructs a query for materials containing iron and oxygen, and then fetches and prints a subset of the results. A second example demonstrates querying for a specific physical property like elasticity for copper-containing materials.

Using curl for a direct HTTP request

For users who prefer direct HTTP requests or want to test without the SDK, curl can be used. This example fetches basic information for materials containing 'H' and 'O'. Remember to replace YOUR_API_KEY.

curl -X POST \ 
  https://api.mpds.io/v2/client/get_data \ 
  -H "Content-Type: application/json" \ 
  -H "X-API-KEY: YOUR_API_KEY" \ 
  -d '{ 
    "query": {"elements": ["H", "O"]},
    "fields": ["formula", "phase_name"],
    "limit": 5
  }'

This command sends a POST request to the get_data endpoint, including your API key in the X-API-KEY header and the query parameters in the JSON body. The response will be a JSON array of materials matching the criteria.

Common next steps

After successfully making your first request, consider these common next steps to further integrate the Materials Platform for Data Science into your workflow:

  1. Explore full API documentation: The MPDS API reference details all available endpoints, query parameters, and data fields. Understanding these options will enable more complex and specific data retrieval.
  2. Advanced querying: Experiment with more sophisticated queries, including filters for specific properties (e.g., crystal system, temperature ranges), data sources, or material classifications. The platform supports a wide range of query parameters to refine your search MPDS data models.
  3. Data parsing and integration: The data returned by the API is typically in JSON format. Learn how to parse this data effectively in your chosen programming language and integrate it into your data analysis scripts, databases, or visualization tools.
  4. Error handling: Implement robust error handling in your code to manage API rate limits, invalid queries, or network issues gracefully. The API typically returns standard HTTP status codes and detailed error messages.
  5. Monitor usage: Keep track of your API call usage through your MPDS dashboard to stay within your plan's limits, especially if you are on the free tier or a limited paid plan.
  6. Contribute to the community: Engage with the MPDS community or support channels if you encounter complex issues or have suggestions for new features.

Troubleshooting the first call

Encountering issues during your first API call is common. Here are some troubleshooting tips for the Materials Platform for Data Science API:

  • Invalid API Key:
    • Symptom: HTTP 401 Unauthorized error or similar authentication failure message.
    • Solution: Double-check that your API key is correctly copied and pasted. Ensure there are no leading or trailing spaces. If uncertain, generate a new key from your MPDS dashboard and try again. Confirm the key is passed in the correct header (X-API-KEY for curl) or parameter (api_key for Python SDK).
  • Network Issues:
    • Symptom: Connection timeout, host unreachable errors.
    • Solution: Verify your internet connection. Check if there are any firewalls or proxy settings that might be blocking outbound requests to api.mpds.io.
  • Incorrect Query Parameters:
    • Symptom: HTTP 400 Bad Request error, or an empty result set when you expect data.
    • Solution: Review the MPDS API documentation for query parameters. Ensure that the fields, elements, and other parameters are correctly formatted and valid. Pay attention to case sensitivity and expected data types (e.g., lists vs. single strings).
  • Rate Limiting:
    • Symptom: HTTP 429 Too Many Requests error.
    • Solution: You may have exceeded the number of allowed requests for your current plan. Wait for the rate limit period to reset, or consider upgrading your plan if frequent, high-volume access is needed MPDS pricing tiers.
  • SDK Specific Errors (Python):
    • Symptom: ImportError or AttributeError when using the Python SDK.
    • Solution: Ensure the mpds-api package is correctly installed (pip install mpds-api). Verify that your Python environment is active and the package is installed within it. If using a virtual environment, activate it before running your script.
  • Empty Data Response:
    • Symptom: The API returns a successful status (e.g., 200 OK) but the data array is empty.
    • Solution: This often means no materials match your specific query criteria. Try broadening your query (e.g., fewer elements, fewer specific properties) to see if data is returned. Review the MPDS data coverage to understand what types of materials and properties are available MPDS data overview.