Technical Documentation

What is an API?

API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other. APIs are implemented by applications, libraries and operating systems to determine the vocabulary and calling conventions the programmer should employ to use their services. It may include specifications for routines, data structures, object classes and protocols used to communicate between the consumer and implementer of the API.

The Modern API

Modern APIs adhere to standards (typically HTTP and REST), that are developer-friendly, easily accessible and understood broadly

  • They are treated more like products than code. They are designed for consumption for specific audiences (e.g., mobile developers), they are documented, and they are versioned in a way that users can have certain expectations of its maintenance and lifecycle.
  • Because they are much more standardized, they have a much stronger discipline for security and governance, as well as monitored and managed for performance and scale

 

Concept

An API is an abstraction that defines and describes an interface for the interaction with a set of functions used by components of a software system. The software that provides the functions described by an API is said to be an implementation of the API.

    An API can be:
  • Generic - the full set of API that are bundled in the libraries of a programming language (e.g. the standard Template Library in C++ or the Java API)
  • Specific - meant to address a specific problem, like the Google MAPs API or the Java API for XML Web Services.
  • Language-dependent - available only in a given programming language. It is only available by using the syntax and elements of that language to make the API convenient to use in this context.
  • Language-independent - written in a way that means it can be called from several programming languages. This is a desired feature for a service-oriented API that is not bound to a specific process or system and may be provided as remote procedure calls or web services.

 

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

JSON is built on two structures
A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array. An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangeable with programming languages also be based on these structures.

In JSON, they take on these forms:
An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).

An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).

How to use

Implementation:

A GET request to the hello echo endpoint that echo's back the name provided as a query parameter as shown below:
You can view the response at the bottom end.

The source code can be viewed by clicking on the query tab and selecting the required type of language and the corresponding code will be displayed on the left hand side.