liveBook · Manning

Contract

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

An application programming interface is a defined interface through which software can programmatically interact with a service or system.

An application programming interface (API) is the defined way software interacts with a service. In AWS, API requests let you use and control services without operating the hardware and software behind them. An application can call a NoSQL database or store files while AWS manages the underlying service. section 1.6 section 4.0

Choose how to make those requests:

  • Use the Management Console for a web interface or the command-line interface (CLI) from a terminal. section 1.7
  • Use an SDK to call the API from application code. It handles authentication, retries, HTTPS communication, and XML or JSON conversion. section 4.3
  • Use CloudFormation templates to describe infrastructure; CloudFormation translates them into API calls. section 4.0

A web request that needs data

A user sends an HTTP request to a web application on a virtual machine. To answer it, the application can call AWS APIs to query a NoSQL database, store a static file, or send email. The user talks to the web application; the application talks to the services. section 1.6

Listing 12.5 nodetodo: Adding a user (index.js)
if (input['user-add'] === true) {
  const params = {
    Item: {                                           #1
      uid: {S: input['<uid>']},                       #2
      email: {S: input['<email>']},                   #3
      phone: {S: input['<phone>']}                    #4
    },
    TableName: 'todo-user',                           #5
    ConditionExpression: 'attribute_not_exists(uid)'  #6
  };
  db.putItem(params, (err) => {                       #7
    if (err) {
      console.error('error', err);
    } else {
      console.log('user added');
    }
  });
}

The DynamoDB user-add example shows a practical SDK call: assemble parameters, call putItem, then check for an error before reporting success. section 12.3.1

Calling the HTTP API directly requires repetitive work such as authentication and data conversion, so an SDK is usually simpler for application code. Every AWS API request is checked by Identity and Access Management (IAM); grant users and roles only the permissions they need. section 4.0 section 5.6

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Explains API access paths and an SDK call pattern, while leaving direct HTTP authentication and serialization to higher-level tools.
Examples
Shows a web application calling AWS services and a DynamoDB putItem call that adds a user.
What it assumes
Introduces the API from a plain-language interface analogy and provides Node.js installation steps before the JavaScript SDK example.
What you can do after
Apply it via an AWS SDK by supplying parameters, invoking an operation, and checking for errors.
How it connects
Connects APIs to SDKs, CloudFormation, IAM, and HTTP requests.

Also explained in

Compare how 44 books explain contract →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.