Skip to content

Retrieve glass formation data

GET https://sciglass.uni-jena.de/api/gf/{table_id}

API for retrieving glass formation data from a table.

Path parameters

table_id  string  Required

The ID of the table to retrieve.


Example request

import asyncio  # (1)!

import httpx
import plotly.graph_objects as go  # (2)!

# API endpoint
table_id = 42328
endpoint_url = f"https://sciglass.uni-jena.de/api/gf/{table_id}"

headers = {
    "Accept": "application/json",
    "Content-type": "application/json",
    "Authorization": "Bearer $SCIGLASS_NEXT_API_KEY"
}


async def example():
    async with httpx.AsyncClient(timeout=None) as client:
        r = await client.get(endpoint_url, headers=headers)
        if r.status_code == 200:
            data = r.json()
            print(data)

            # Extract component names
            comp_name = [item.split("|")[1] for item in data['varComp'].split("\\")[:3]]

            # Helper function to parse trace data
            def parse_trace(trace):
                values = trace['value'].split('')
                a = []  # vertex at top
                b = []  # vertex at left
                c = []  # vertex at right
                for value in values:
                    if value.strip() != "":
                        first_value, second_value = map(float, value.split())
                        c.append(first_value)
                        a.append(second_value)
                        b.append(100 - first_value - second_value)
                return a, b, c

            # Extract and prepare traces
            traces = []
            for trace in data['traces']:
                a, b, c = parse_trace(trace)
                traces.append({
                    'a': a,
                    'b': b,
                    'c': c,
                    'legend': trace['legend'],
                    'type': trace['type']
                })

            # Create Plotly figure
            fig = go.Figure()

            # Add traces to the figure
            for trace in traces:
                mode = 'lines'
                fill = 'none'
                dash_type = 'solid'
                legend_name = trace['legend']
                opacity = 1.0

                if trace['type'] == 'P':
                    mode = 'markers'
                elif trace['type'] == 'Z':
                    fill = 'toself'
                    legend_name = ''  # don't give the filled area name
                    opacity = 0.3
                elif trace['type'] == 'D':
                    fill = 'toself'
                    opacity = 0.3
                elif trace['type'] == 'N':
                    dash_type = 'dash'

                fig.add_trace(go.Scatterternary(
                    a=trace['a'],
                    b=trace['b'],
                    c=trace['c'],
                    mode=mode,
                    name=legend_name,
                    line=dict(dash=dash_type),
                    fill=fill,
                    opacity=opacity,
                    hovertemplate=f'{comp_name[1]}: %{{a}}<br>{comp_name[2]}: %{{b}}<br>{comp_name[0]}: %{{c}}<extra></extra>'
                ))

            # Update layout with axis titles
            fig.update_layout({
                'ternary': {
                    'sum': 100,
                    'aaxis': {'title': {'text': comp_name[1]}},
                    'baxis': {'title': {'text': comp_name[2]}},
                    'caxis': {'title': {'text': comp_name[0]}},
                },
                'title': 'Ternary Plot'
            })

            # Show figure
            fig.show()
        else:
            print(f"Request failed with status code: {r.status_code}")
            print("Response text:", r.text)


asyncio.run(example())
  1. AsyncIO is Python's built-in library for writing concurrent code with the async/await syntax.
  2. This is optional and is imported in this example to show how to visualize the result using Plotly.
1
2
3
4
curl https://sciglass.uni-jena.de/api/gf/42328 \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $SCIGLASS_NEXT_API_KEY"

plotly-gf-42328.png plotly-gf-42328-dark.png


{
    'traces': [
        {
            'type': 'Z',  # (1)!
            'legend': 'Glassforming border',  # (2)!
            'value': '0.00 100.00\x7f0.65 98.08\x7f0.77 96.39\x7f0.79 95.12\x7f1.07 93.37\x7f1.35 91.61\x7f1.63 89.86\x7f1.91 88.10\x7f2.24 86.33\x7f2.56 84.56\x7f2.95 82.77\x7f3.48 80.94\x7f3.95 79.12\x7f4.55 77.28\x7f5.42 75.39\x7f6.29 73.51\x7f7.15 71.62\x7f8.02 69.74\x7f7.51 70.77\x7f6.60 72.66\x7f7.44 70.93\x7f8.35 69.04\x7f9.40 67.16\x7f10.46 65.28\x7f11.51 63.40\x7f12.56 61.52\x7f13.83 59.68\x7f15.17 57.87\x7f16.54 56.07\x7f18.23 54.52\x7f19.95 53.04\x7f21.75 51.75\x7f23.61 50.82\x7f25.43 50.17\x7f27.17 49.86\x7f28.64 49.96\x7f30.13 50.16\x7f30.76 51.37\x7f31.18 52.75\x7f31.63 54.10\x7f32.10 55.44\x7f32.15 57.04\x7f32.21 58.64\x7f32.44 59.78\x7f32.73 61.18\x7f32.82 62.74\x7f32.32 64.39\x7f31.79 66.23\x7f31.25 68.06\x7f30.00 70.00\x7f'
        },
        {
            'type': 'P',
            'legend': 'Glass',
            'value': '5.70 79.80\x7f10.44 70.00\x7f5.44 84.70\x7f10.48 74.70\x7f15.61 64.90\x7f5.65 89.90\x7f15.24 70.10\x7f10.50 79.90\x7f20.28 60.00\x7f15.47 74.80\x7f10.52 85.10\x7f20.52 64.80\x7f15.49 80.00\x7f20.53 70.00\x7f20.47 75.00\x7f'
        },
        {
            'type': 'P',
            'legend': 'Crysrtal',
            'value': '5.45 69.80\x7f10.49 59.80\x7f5.46 75.00\x7f20.33 49.90\x7f30.40 44.70\x7f35.54 55.00\x7f'
        },
        {
            'type': 'S',
            'legend': 'Glassforming border',
            'value': '0.00 100.00\x7f0.65 98.08\x7f0.77 96.39\x7f0.79 95.12\x7f1.07 93.37\x7f1.35 91.61\x7f1.63 89.86\x7f1.91 88.10\x7f2.24 86.33\x7f2.56 84.56\x7f2.95 82.77\x7f3.48 80.94\x7f3.95 79.12\x7f4.55 77.28\x7f5.42 75.39\x7f6.29 73.51\x7f7.15 71.62\x7f8.02 69.74\x7f7.51 70.77\x7f6.60 72.66\x7f7.44 70.93\x7f8.35 69.04\x7f9.40 67.16\x7f10.46 65.28\x7f11.51 63.40\x7f12.56 61.52\x7f13.83 59.68\x7f15.17 57.87\x7f16.54 56.07\x7f18.23 54.52\x7f19.95 53.04\x7f21.75 51.75\x7f23.61 50.82\x7f25.43 50.17\x7f27.17 49.86\x7f28.64 49.96\x7f30.13 50.16\x7f30.76 51.37\x7f31.18 52.75\x7f31.63 54.10\x7f32.10 55.44\x7f32.15 57.04\x7f32.21 58.64\x7f32.44 59.78\x7f32.73 61.18\x7f32.82 62.74\x7f32.32 64.39\x7f31.79 66.23\x7f31.25 68.06\x7f30.00 70.00\x7f'
        }
    ],
    'comp': 'na|Na2O|NaâO|61.97894\\b|B2O3|BâOã|69.6202\\al|Al2O3|AlâOã|101.9613\\'  # (3)!
}
  1. This type determines the style of the trace
  2. The legend name
  3. The component names

Note

The ternary plot direction cannot be changed in Plotly and differs from the SciGlass convention. See the Python example code for details on how to parse the data points.

Note

Data points are stored in the value key,separated by a special delimiter \x7f.

The first value means the value of vertex at right (C).

The second value means the value of vertex at top (A).

The value of (100 - A - C) means the value of vertex at left (B).