SNUMAT API

Documents

play_arrow Overview

Introduction

Getting started

play_arrow Concepts

Authentication

Limitation

play_arrow Apis

Search materials

Get material

Mat RESTful API

Material data center provides data and scientific analysis based on the open-source pakage. MAT API (Application Programming Interface) can make for users access database easily, and it's powerful because of intuitiveness. API is based on RESTful(REpresentational State Transfer) architecture that is suitable for analyze and get the materials. For more details on Mat RESTful API, please touch in our web site.

Overview

Introduction

SNUMAT provides our material data based on computational methods for free. In terms of usage, we block indiscriminate requests by anonymous users and collect statistics of requests. So, we provide our data only identifiable users who signed in to our services. But, users' privacy data are all encrypted safely and protected from malicious servers. If you want to know our service's terms of usage or privacy policy, please click this link

Getting started

Using snumat apis needs some accessable parameters such as, public key and private key. So, you should sign up our service and request api keys.

After sign in, you can request api keys which can issued api tokens.

Concepts

Authentication

SNUMAT's REST API provides a authentication method by private API token. The API token authentication method is available to all SNUMAT users who want to get material data and use in their researching. Get user identification parameters such as public key and secret key from account page and request temporary API token to access data.

                [POST] https://api.snumat.com/user/auth/token

                {
                	"public": "{Your public key}",
                	"secret": "{Your secret key}",
                	"region": "SNUMAT-KR-1",
                	"auth_uri": "https://account.snumat.com/o/oauth2/auth",
                	"token_uri": "https://api.snumat.com/auth/token/verify",
                	"version": "v0.3"
                }
              

Returns

- Private API token (string)
- expired time (timestamp)
- authorization type (bearer)

Limitation

After issuing a private API token, you can access all snumat restful APIs using the token. But, validation of token will be expired at 15 min after being issued. So, If you want to extend the token's lifetime, you should request issuing a new API token by the method above.

Apis

Search materials

Snumat api provides properties of materials using filter option. You can choose elements shoud be included or excluded.

                Bearer : { API token }

Endpoints

                [POST] https://api.snumat.com/material/search/query

Body

                {
                    "fields" : {
                        "include" : {
                            "or" : ["Cr","Hg"],
                            "and" : ["O","Si"]
                        },
                        "exclude" : ["F"],
                        "nelement" : 3
                    },
                    "properties" : [],
                    "offset" : 0,
                    "number" : 1000
                }

Get material

Get materials' properties by SNUMAT ID or ICSD numbers.

Get material by SNUMAT ID

                Bearer : { API token }

Endpoints

                [GET] https://api.snumat.com/material/search/id/{SNUMAT ID}

Get material by ICSD number

Endpoints

                [GET] https://api.snumat.com/material/search/icsd/{icsd number}

Python code sample

                import requests
                import json

                AUTH_URL = "https://api.snumat.com/user/auth/token"
                QUERY_URL = "https://api.snumat.com/material/search/query"
                ID_URL = "https://api.snumat.com/material/search/id"

                param_data = {
                	"public": "", # your public key
                	"secret": "", # your secret key
                	"region": "SNUMAT-KR-1",
                	"auth_uri": "https://account.snumat.com/o/oauth2/auth",
                	"token_uri": "https://api.snumat.com/auth/token/verify",
                	"version": "v0.3"
                }

                # get private request token
                def request_token():
                    global AUTH_URL, param_data
                    response = requests.post(AUTH_URL, json=param_data)
                    result = response.json()

                    #
                    # result
                    # 1. code : status code
                    # 2. access_token :  access_token
                    # 3. type : authentication type ( Bearer )
                    # 4. expired_at : expired time
                    #
                    return result

                def getMaterials(token, query={
                                    "fields" : {
                                        "include" : {
                                            "or" : ["Cr","Hg"],
                                            "and" : ["O","Si"]
                                        },
                                        "exclude" : ["F"],
                                        "nelement" : 3
                                    },
                                    "properties" : [],
                                    "offset" : 0,
                                    "number" : 1000
                                }):
                    global QUERY_URL
                    headers = {"Authorization": f"Bearer {token}", 'Content-type': 'application/json'}
                    response = requests.post(QUERY_URL, json=query, headers=headers)

                    return response.json()


                def getMaterialBySNUMAT(token, id=490):
                    global ID_URL
                    headers = {"Authorization": f"Bearer {token}", 'Content-type': 'application/json'}
                    response = requests.get(f"{ID_URL}/{id}", headers=headers)

                    return response.json()

                token_result = request_token()
                if token_result["code"] == 200:
                    token = token_result["access_token"]

                    # get material list
                    material_list = getMaterials(token)

                    #
                    # result
                    # code : status code
                    # list : material's list
                    #

                    # get material data by snumat id
                    material_data = getMaterialBySNUMAT(token)