API Scripting

Version 23.0.8844


API Scripting

Version 23.0.8844


CData has its own configuration language called API Script that you can use to mark up schemas for the resources of your API. API Script hides the complexity of interacting with the underlying data source through REST APIs. You can use the wizard in the administration console to generate schemas for connecting to databases through REST APIs.

However, API Script is also a high-level programming language that enables you to control almost every aspect of data access and processing. Your schema is a script interpreted by the API Script engine.

You use keywords, attributes, items, operations, and feeds to write scripts:

  • Attribute: The name part of a name-value pair, as in attribute=”address”, value=”123 Pleasant Lane”.
  • Item: A related group of attribute-value pairs that describe an input or output. For example:

    Attribute="name" value="Bob"
    Attribute="address" value="123 Pleasant Lane"
    Attribute="phone" value="123-4567"
    
  • Feed: A list of items: for example, a list of customers with their addresses and phone numbers.
  • Operation: A generic name for methods that accept items as input and produce feeds as output.
  • Keyword: An API Script statement, like api:set.

API Script includes many keywords that allow you to do the following:

  • Describe and validate the behavior of the resources of your API.
  • Use high-level programming constructs such as if/else statements and case statements to control execution flow.
  • Call operations and define your own.
  • Create and modify items, the inputs to an operation, and feeds, the operation’s result.
  • Process the feed resulting from an operation call by iterating through its items.