# Filter analysis results by load case

Every result endpoint accepts a `LoadCases` query parameter to restrict
the response to a subset of analysed cases. The format is SG's list
syntax — comma-separated Ids and dash ranges in a single string:

| Filter | Meaning |
|---|---|
| `"1"` | Just case 1 |
| `"1,3,7"` | Cases 1, 3, and 7 |
| `"1,3-7,10"` | Case 1, 3 through 7 inclusive, and 10 |
| `""` or omit | All analysed cases |

The same format applies to `Nodes`, `Members`, `Modes`, and any other
list filter.

The snippet below opens the `Portal Frame.SG` sample, runs a linear
static analysis, then reads node reactions filtered to load case `1`.
Adjust the case Id to match a case that exists in your model.
`try / finally` closes the job at the end even if a step in the middle
throws.

<CodeTabs>
```csharp title="C#"
using SpaceGassApi;
using SpaceGassApi.Models;

var client = SpaceGassApiClient.CreateClient("http://localhost:34560");

try
{
    await client.Job.OpenSample.PostAsync(
        new OpenSampleRequest { FileName = "Portal Frame.SG" });

    var run = await client.Job.Analysis.Static.RunLinear.PostAsync(
        new StaticSettingsUpdate());

    while (true)
    {
        await Task.Delay(500);
        var s = await client.Job.Analysis.Runs[run!.RunId!.Value].GetAsync();
        if (s!.Status is AnalysisRunStatus.Completed
                      or AnalysisRunStatus.Failed
                      or AnalysisRunStatus.Cancelled) break;
    }

    var reactions = await client.Job.Query.Analysis.Static.NodeReactions.GetAsync(
        config => config.QueryParameters.LoadCases = "1");

    if (reactions!.Warnings?.LoadCasesNotAnalyzed is { Length: > 0 } missing)
    {
        throw new Exception($"Cases not analysed: {missing}. Run the analysis first.");
    }

    foreach (var r in reactions.Results!)
    {
        Console.WriteLine($"Node {r.Node}: Fx={r.Fx:F2}, Fy={r.Fy:F2}, Fz={r.Fz:F2}");
    }
}
finally
{
    await client.Job.Close.PostAsync();
}
```

```python title="Python"
import asyncio
from space_gass_api import SpaceGassApiClient
import space_gass_api.models as models

client = SpaceGassApiClient.create_client("http://localhost:34560")

try:
    await client.job.open_sample.post(
        models.OpenSampleRequest(file_name="Portal Frame.SG"))

    run = await client.job.analysis.static.run_linear.post(
        models.StaticSettingsUpdate())

    while True:
        await asyncio.sleep(0.5)
        s = await client.job.analysis.runs.by_run_id(str(run.run_id)).get()
        if s.status in (
            models.AnalysisRunStatus.Completed,
            models.AnalysisRunStatus.Failed,
            models.AnalysisRunStatus.Cancelled,
        ):
            break

    reactions = await client.job.query.analysis.static.node_reactions.get(
        load_cases="1")

    if reactions.warnings and reactions.warnings.load_cases_not_analyzed:
        raise RuntimeError(
            f"Cases not analysed: {reactions.warnings.load_cases_not_analyzed}. "
            "Run the analysis first.")

    for r in reactions.results:
        print(f"Node {r.node}: Fx={r.fx:.2f}, Fy={r.fy:.2f}, Fz={r.fz:.2f}")
finally:
    await client.job.close.post()
```

```bash title="curl"
# Single case
curl "http://localhost:34560/api/v1/job/query/analysis/static/node-reactions?loadCases=10"

# Multiple cases via SG list
curl "http://localhost:34560/api/v1/job/query/analysis/static/node-reactions?loadCases=1,3-7,10"
```
</CodeTabs>

### Always check `Warnings.LoadCasesNotAnalyzed`

If you ask for a case that hasn't been analysed (or, for a combination,
any of its primary cases), it appears in `Warnings.LoadCasesNotAnalyzed`
and silently returns no rows for that case. Check the warning before
reading `Results` so a missing run doesn't look like clean data.

## See also

- [Filtering & Querying](/guides/filtering-and-querying)
- [Concepts — Analysis Runs](/concepts#analysis-runs)
