Skip to content
This page View Markdown Open in ChatGPT Open in Claude

Global shared

The code in every language

Each example is the inside of main, written in every language API Maker runs : pick yours in the tabs, and every page shows it from then on. The types a call takes (GetAll, DeepItem…) are those of am : from am import GetAll in Python, use am::GetAll; in Rust, import am.GetAll; in Java and Kotlin ; PHP and C# have them without an import, Go names them am.GetAll.

Shared data globally

g.shared is used to share data between post-hooks, pre-hooks, code, and APIs.

  • If the user set a shared variable from the one API response.
g.shared.lastOutput = g.res.output;
g.shared['lastOutput'] = g.res.output
$g->shared->lastOutput = $g->res->output;
g.Shared["lastOutput"] = g.Res.Output?.DeepClone();
g.Shared.Set("lastOutput", g.Res.Output())
g.shared.set("lastOutput", g.res.output().clone());
g.shared.put("lastOutput", g.res.getOutput());
g.shared["lastOutput"] = g.res.output
  • User can get that shared variables value in another API.
const lastOutput = g.shared.lastOutput;
last_output = g.shared.get('lastOutput')
$lastOutput = $g->shared->lastOutput;
var lastOutput = g.Shared.GetValueOrDefault("lastOutput");
lastOutput := g.Shared.Get("lastOutput")
let last_output = g.shared.get("lastOutput");
Object lastOutput = g.shared.get("lastOutput");
val lastOutput = g.shared["lastOutput"]