Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Wall Street Raider Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Modding
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Calling the API from a frontend mod == <code>js/api.js</code> is the '''wrapper layer''' for the REST API: each endpoint has a named async function with semantic parameters, plus the live <code>gameStore</code>, plus exported '''ID constants''' (entity IDs, industry indices, special asset IDs, <code>UI_*</code> report IDs). '''Frontend mods should call <code>api.js</code> functions, not raw HTTP.''' <pre> import * as api from '../api.js'; await api.buyStock(companyId); // /buy_stock await api.setDividend(actingAsId); // /set_dividend await api.merger(targetId, actingAsId); // /merger await api.cheatAddCash(); // /cheat_add_cash const state = await api.getGameState(); // GET /gamestate </pre> For endpoints that don't have a named wrapper yet, four request shapes are also exported: {| class="wikitable" ! Helper !! Body shape !! Use |- | <code>postNoArg(path)</code> || <code>{}</code> || actions with no parameter |- | <code>postIdArg(path, id)</code> || <code>{ id }</code> || actions on a specific entity / slot |- | <code>postIdArgWithActingAs(path, id, actingAsId)</code> || <code>{ id, intParam2 }</code> || most corporate / trade actions |- | <code>postOptionsTradeWithActingAs(path, id, actingAsId, underlyingId)</code> || <code>{ id, intParam2, underlyingId }</code> || options trades |- | <code>postStringArg(path, str)</code> || <code>{ str }</code> || actions taking a string (e.g. save-as filename) |- | <code>getJSON(path)</code> || - || GET endpoints |} For wire-level details (the underlying routes, the JSON body the bridge actually receives, what each generic field means per endpoint), see [[#REST API reference|§REST API reference]].
Summary:
Please note that all contributions to Wall Street Raider Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Wall Street Raider Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Modding
(section)
Add topic