# Snelstart publieke API > Vertaling van de [oorspronkelijke Engelse pagina](https://github.com/lmonteirotech/OmsiLaunch/blob/v0.1.0-beta.3/docs/getting-started/api-quick-start.md) voor OmsiLaunch 0.1.0-beta3. De Engelse pagina is normatief: bij verschillen gelden de Engelse pagina en de code. Op deze pagina start je één OmsiLaunch-sessie vanuit je eigen .NET-programma, lees je die uit en beëindig je die. Er wordt van uitgegaan dat het pakket in de OMSI 2-map is geïnstalleerd (zie [installatie](https://omsilaunch.omsimods.com.br/nl/docs/getting-started/installation/index.md)) en dat `OmsiLaunch.exe /plan` daar werkt (zie [eerste sessie](https://omsilaunch.omsimods.com.br/nl/docs/getting-started/first-session/index.md)). Het volledige contract staat in de [referentie van de publieke API](https://omsilaunch.omsimods.com.br/nl/docs/reference/public-api/index.md). Tijdelijke aanduidingen: `` is de OMSI 2-installatie die `Omsi.exe` en het OmsiLaunch-pakket bevat (bijvoorbeeld `C:\OMSI 2`). ## 1. Project De API wordt geleverd als de pakketassembly's in ``; er is geen NuGet-pakket. Verwijs ernaar vanuit een x64-consoleproject voor `net6.0-windows`. `OmsiLaunch.Api`, `OmsiLaunch.Core` en `OmsiLaunch.Process` vormen het publieke oppervlak; de andere assembly's zijn hun afhankelijkheden en moeten naast je programma worden gekopieerd. ```xml Exe net6.0-windows x64 enable enable <OMSI_PATH> ``` Vervang `` in `OmsiPath` door het echte pad. ## 2. Programma ```csharp using OmsiLaunch.Api; using OmsiLaunch.Core; using OmsiLaunch.Process; var root = args.Length > 0 ? args[0] : @"C:\OMSI 2"; // var plugins = Path.Combine(root, "plugins"); var manifest = Path.Combine(root, "release-manifest.json"); IOmsiLaunch launch = new OmsiLaunchService( new CurrentWindowsX64Platform(), new OmsiLaunchRuntimePaths(plugins, Path.Combine(plugins, "OmsiLaunch.Native.x86.dll"), File.Exists(manifest) ? manifest : null)); // NEW_MAP on Grundorf, first presented entry point. Everything else stays as OMSI has it. var none = new Dictionary>(); var spec = new LaunchSpec( Installation: new InstallationSpec(root), World: new WorldSpec(WorldMode.NewMap, OptionalValue.Set(@"maps\Grundorf\global.cfg"), OptionalValue.Unset, OptionalValue.Set(1)), Date: new DateSpec(DateTimeMode.Unset, OptionalValue.Unset), Time: new TimeSpec(DateTimeMode.Unset, OptionalValue.Unset), PlayerVehicle: OptionalValue.Unset, Environment: new EnvironmentSpec(none, none, none, none, none, none, none, none), Behavior: new LaunchBehaviorSpec()); var plan = await launch.PlanSessionAsync(spec); if (!plan.IsRunnable) { foreach (var diagnostic in plan.Diagnostics.Where(d => d.Code.StartsWith("OL_E_", StringComparison.Ordinal))) Console.WriteLine($"{diagnostic.Code}: {diagnostic.Message}"); return 1; } var session = await launch.StartSessionAsync(plan); try { var status = await launch.WaitForAsync(session, SessionState.Running, TimeSpan.FromSeconds(plan.Spec.Behavior.StartupTimeoutSeconds + 5)); if (status.State != SessionState.Running) { Console.WriteLine($"Did not reach gameplay: {status.State} {status.Diagnostics.LastOrDefault()?.Code}"); return 1; } var time = await launch.ExecuteRuntimeAsync(session, new RuntimeCommand(session.SessionId, 1, "time.read"), TimeSpan.FromSeconds(5)); Console.WriteLine(time.Succeeded ? $"OMSI time {time.Values!["hour"]}:{time.Values["minute"]}" : $"time.read failed: {time.ErrorCode}"); await launch.StopAsync(session); // terminate OMSI and restore every file var final = await launch.WaitForAsync(session, SessionState.Completed, TimeSpan.FromMinutes(2)); Console.WriteLine($"Session ended: {final.State}"); return final.State == SessionState.Completed ? 0 : 1; } finally { await launch.CloseAsync(session); // always, on every path } ``` Voer het uit met de installatie als enige argument: ```powershell dotnet run -- "" ``` Wat er gebeurt: het plan wordt gecontroleerd (er wordt niets gestart als het niet uitvoerbaar is), OMSI start en laadt Grundorf, het programma leest de klok één keer uit en beëindigt daarna de sessie. OMSI wordt beëindigd en elk bestand dat OmsiLaunch heeft gewijzigd, wordt hersteld. Er is maar één eigenaar per installatie toegestaan: stop eerst een eventuele `OmsiLaunch.exe`-sessie voor dezelfde installatie, anders meldt `StartSessionAsync` de fout `OL_E_INSTALLATION_BUSY`. ## 3. Volgende stappen - Meer runtime-operaties (voertuigen, dienstregeling, scripts, D3D): [runtimebesturing](https://omsilaunch.omsimods.com.br/nl/docs/reference/runtime-control/index.md) en [capabilities](https://omsilaunch.omsimods.com.br/nl/docs/reference/capabilities/index.md). - Instellingen, opstartscherm en internettextures in de spec: [LaunchSpec](https://omsilaunch.omsimods.com.br/nl/docs/reference/launchspec/index.md). - Een sessieprofiel vanuit code starten: [publieke API, sessieprofielen](https://omsilaunch.omsimods.com.br/nl/docs/reference/public-api/index.md#session-profiles-omsilaunchcore). - Een sessie besturen waarvan een ander proces eigenaar is (bijvoorbeeld `OmsiLaunch.exe`): [local control](https://omsilaunch.omsimods.com.br/nl/docs/reference/local-control/index.md). - Fouten: [fouten](https://omsilaunch.omsimods.com.br/nl/docs/reference/errors/index.md); levenscyclus: [sessielevenscyclus](https://omsilaunch.omsimods.com.br/nl/docs/concepts/session-lifecycle/index.md).