SDK v. REST API

Summary

An API (Application Programming Interface) is software that lets you connect one system to another. Vendors typically extend their products so you can add that capability to your brand or product.

Wirewheel has two APIs: a REST API and an SDK.

What You'll Learn

In this article, you'll learn about the differences between:

  • REST API

  • SDK

REST API—REST works over the regular HTTP/HTTPS internet. It is easy to get started and works everywhere. You can use any programming language with a REST API. That is the whole idea, to provide a plain vanilla interface that any program can use. REST APIs are also called just APIs.

SDK—is a Software Development Kit. You must use the same programming language as the SDK. So, a JavaScript program must use a JavaScript SDK (or TypeScript, which is just an extensions of JavaScript.). The reason is that the SDK code is imported, i.e., included right inside the code you write. So they must be the same. The Wirewheel SDK is written in TypeScript.

👍

Programming Interface

Why are we using a programmatic interface at all? The goal is to let the customer process consents in their system. So, it adds on that capability, while branding so that it still reflects the customer's logo, etc.

📘

Why an API?

An API or SDK lets the customer add functions provided by a 3rd-party system to their own app.

The API is the most common way to extend one application to another. It is designed to work server-to-server, without any manual input.

API

Some software developers use the terms SDK and API interchangeably. This causes confusion when precision is required. For our purposes, when we say API we mean REST API. We define SDK below.

The difference is an SDK is language-bound. For example, the Wirewheel SDK only works with JavaScript and TypeScript languages since it is written in TypeScript. If Wirewheel wants to support another language, like Python, they would have to release a Python SDK.

An API, on the other hand, works with almost every language. This is because sending parameters over the public internet using HTTP and JSON to an endpoint (URL) is a basic function common to most languages.

You might wonder why would you use a language-bound SDK when an API can be used in any language? One answer is the API only supports primitives. It does not support objects, since they cannot be transmitted over the HTTP protocol. Also, in some cases you have to use several APIs endpoint whereas with an SDK you might need only one.

When you use an API, there is no need to add any external packages or files in your code. Instead, you just put the API endpoint (URL), parameters, content-type, and operation into the header, body, or URL parameters.

For example, you can access an API from the command line on most operating systems by just running curl. See the example below.

In this example, the operation is POST, which means write data (as opposed to GET which means read it). This is Content-Type: application/x-www-form-urlencoded which means that the parameters are given in the URL. So they must be URL encoded which is why you see a %20 (space) in scope=consent-insert-api%20consent-get-api%20subject-profile-manage.

curl -X POST "http://foo.com?grant_type=client_credentials&scope=consent-insert-api%20consent-get-api%20subject-profile-manage" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --header "Authorization: Basic ${base64IdSecret}"

SDK

Like the API, the Wirewheel SDK works from both NodeJS (i.e., server-side) code and front-end code.

An SDK is language-bound. That means you must have it installed on the same computer as the code you write. So it's a package. The Wirewheel SDK is delivered as an npm (Node Package Manager) package.

You'll install the Wirewheel npm package like this:

npm install @wirewheelio/cmp-javascript-sdk

Then you add it to your code like this:

import { WireWheelSDK, Subject, CreateConsentPayloadBuilder, Scopes} from '@wirewheelio/cmp-javascript-sdk'

📘

Where to Go From Here


Didn’t find what you were looking for?

Email our team: [email protected]?subject=UPCP