ApiRequest

Family: Studio · 2 forms

What it does

Sends a request to a third-party service through an API connection declared for the project on aukimi.com. Returns a task id.

Syntax

1
ApiRequest(connexion string, methode string, chemin string) → integer
2
ApiRequest(connexion string, methode string, chemin string, corps string) → integer

Parameters

NameTypeIn formsMeaning
connexionstringallThe name of the API connection, as declared on aukimi.com.
methodestringallThe HTTP method: GET, POST, PUT or DELETE, in any case.
cheminstringallThe path to call on the service, such as /scores. It may carry a query string: /search?q=x.
corpsstring2Optional request body. Text that reads as JSON is sent as JSON, anything else as plain text.

Every form returns

Good to know

  • The service's secret key stays on Aukimi's server: the game only knows the connection name.
  • The player must be signed in first (PlayerGuestAsync() is enough). Otherwise the task fails at once with not logged in.
  • Free the task with ApiFree() once you have read it.
  • Editor and HTML5 exports only: native (Bevy) builds stop with an unsupported-command error.

Example · generated

Form 1, the short one

DO  Print(ApiRequest("value", "value", "value"))  Sync()LOOP

Form 2, with every argument

DO  Print(ApiRequest("value", "value", "value", "value"))  Sync()LOOP

ApiRequest is called and its answer is printed every frame. The DO … LOOP is not decoration: a classic BASIC program ends the moment it runs out of lines, and Sync() is what draws the frame.

Related commands

133 commands in Studio