Keyword Reference

Version 23.0.9145


Keyword Reference


Statements in APIScript are defined using keywords, XML elements prefixed with api:. Keywords include the usual features of a programming or scripting language, such as conditionals, loops, and flow control. However, APIScript also includes special keywords tailored specifically for feed manipulation and generation: for example, api:call, api:enum, and api:set.

Most keywords take parameters that define or affect their behavior. Parameters are specified as XML attributes of the keyword element. The mandatory and optional parameters for each keyword, with code examples, are explained in this section.

Keyword Scope

In APIScript, some keywords introduce scope. This means that some keywords can be nested inside the bodies of other keywords, and how they are nested is meaningful to the language.

  • You can define instructions for an iteration in a keyword’s scope. For example, the body of an api:call keyword is executed for each item in the feed produced by the operation invoked by api:call. Because of this, keywords nested inside api:call are executed for each iteration to produce each item in the feed.
  • Scope associates matching pairs of keywords. For example, the api:else keyword defines an alternate execution path for a conditional keyword like api:equals or api:check. In APIScript, an api:else keyword is associated with a conditional statement when it is nested as a direct child of the conditional statement. This means the api:else keyword must not be defined outside of the scope introduced by a conditional keyword.
  • Keywords can introduce new items (variables) in their scope. For example, the api:call keyword introduces a default output item representing the item being iterated over in the feed being generated.
  • Keywords can inject additional attributes into the default item that provide more information in their scope. These attributes are called control attributes in this document. They start with an underscore _. For example, _attr, _index, and _value are control attributes.