Review a basic API Server and Client

Introduction

This page presents a basic “first cut” of a Patient Demographics API for you to review. This version is intended to give a first impression of how it is to work with a simple API design — this version only demonstrates a few API Designer features.

The API composed two parts: The API design in the Designer and the code for the API in the Iguana Translator. We suggest that you inspect the API design first and then look at the corresponding code.

We encourage you to experiment with changing the design and the code. Don’t worry about breaking things — you can always re-import the originals from this page.

For a comprehensive example that exercises most API Designer options — look at the “second cut” of the Patient Demographics API in Review a complex API Server and Client.

You can log into the API designer here: https://designer.interfaceware.com/ (click on create a new account if you don’t have an account yet).

Import the API [top]

Th quickest way to create the API Design and the Client and Server code is simply to import the completed examples.

  1. Import the JSON Grammar into Designer:
  2. Create a channel for the Server, with these properties:
    • Source: From HTTPS
    • Destination: To Channel
    • Channel Name: “Patient Demographics server V1”
    • URL Path: “patient-demographics-server-v1/”
  3. Import the API Server code into the new Server channel:
  4. Create a channel for the Client, with these properties:
    • Source: From HTTPS
    • Destination: To Channel
    • Channel Name: “Patient Demographics client V1”
    • URL Path: “patient-demographics-client-v1/”
  5. Import the API Client code into the new Client Iguana:

Review the API Design [top]

This is the structure of “first cut” of our API, as you can see it is intentionally very simple (and makes no attempt to be realistic).

  1. Log into the API designer.
  2. Go to My APIs.
  3. Open the Patient V1 API.
  4. View the interactions.
  5. There should be two Interactions Read and Rename, grouped under Patient:
  6. Try editing the Interactions, don’t worry about breaking things — you can always import the grammar again.
  7. View the Resources.
  8. Because we kept this design simple there are no Resources:
  9. For bonus points you can open the JSON Grammar file and see if you can spot the the Interactions:

Review the API Server Code [top]

  1. Look at the code for the Server channel Patient Demographics server V1.
  2. Open the Read GET handler function, and review the handler code:

    Note: This is simply “placeholder” code that does not perform any real purpose.
  3. You can also look at the Rename POST function which has no code added:
    Note: The second sample message calls this function.
  4. Feel free to modify the the handler code if you wish, you can always rollback to the initial commit.
  5. If you are interested you can also look at the code in the various other modules, but it is not necessary as the only code you ever need to change is the handler functions above.

Review the API Client Code [top]

  1. Look at the code for the Client channel Patient Demographics client V1.
  2. Open the main module and look at the main() function.
  3. At line 37 there are two API Server calls:
  4. Try commenting out the resource id assignment on line 38, you will get a helpful error:
  5. You can also try the following to see what errors you get:
    • Comment out the either of the required Name assignments on lines 44-45
    • Stop the Server
  6. Feel free to modify the the code however you wish, you can always rollback to the initial commit.
  7. If you are interested you can also look at the code in the iguana/client module, but it is not necessary as the only as you will never need to change it.

Please don't hesitate to take anonymous feedback survey or leave us a comment.

Leave A Comment?