What Is An API?: P1 Examine The Relationship Between An API and A Software Development Kit (SDK)
What Is An API?: P1 Examine The Relationship Between An API and A Software Development Kit (SDK)
What is an API?
Broadly speaking, an Application Programming Interface (API) is a set of
subroutine definitions, communication protocols, and tools for building software. In
general terms, it is a set of clearly defined methods of communication among various
components.
There are two main types of APIs, server-to-server or client-to-server, and component-
to-component. Server-to-server and client-to-server APIs are commonly a stateless
interface to a remote server to set or get data. Typically, these types of APIs use
a “RESTful” (representational state) protocol which requires them to
be “stateless”. Stateless protocols require that any call to the API be completely
independent from any past or future calls to the API. The API defines a
communication protocol and “expected behavior” that allows a client to make requests
and receive responses to and from a server. It is the developer's responsibility to
integrate an API into their solution and use the API correctly. Component-to-
component APIs can act a bit differently. These APIs allow different software
packages to communicate on the same device and are not communicating with an
external server or device. A good example of this would be Android’s set of APIs.
APIs work on all operating systems and are commonly used on IoT devices and for
device tracking & management platforms. This makes them a great solution for
customers that use proprietary operating systems and protocols as well as end-to-end
vertical solution providers.
Skyhook offers an API as one of four flexible integration options to access its
Precision Location software. When utilizing this location API, the developer is
required to source the Wi-Fi, GPS, and cellular data, and then implement the API
request according the the specifications outlined.
What is an SDK?
A Software Development Kit (SDK) is commonly defined as a set of tools that can be
used to create and develop applications. In general, an SDK refers to a full-suite
software module that includes everything developers need for a specific module within
an app. They are often compared to a code library, which is a collection of non-
volatile resources, used by computer programs, often for software development. They
often “wrap” (fully or partially implement) an API and utilize the API’s
communication protocols in the appropriate and intended manner. They include
examples, documentation and, the methodology necessary to perform specific
functions.
For example, Skyhook’s Precision Location SDK provides all the tools and
documentation needed to perform highly accurate geo-positioning on a mobile device
using the Android operating system. The app developer simply needs to load, or
dynamically pull, the SDK library into their development environment and use the
available interfaces to utilize all the capabilities Skyhook provides. No extra code is
needed to source the Wi-Fi, GPS, or cellular data to calculate an accurate position -
this is all handled by the SDK.
Additional benefits of Skyhook’s SDK include location smoothing, a fast time-to-fix,
MAC address collapsing, stationary detection, offline location, and power
optimization. See how each of these features can add value to connected devices:
Location Smoothing – Algorithms that use historic location data and patterns to
inform device locations in the future.
MAC Address Collapsing – Intelligent filtering to detect multiple MAC
addresses associated with one router. This helps evenly weight all access points
used for location, without creating a bias towards a particular access point.
Stationary Detection – Patented method for determining if a connected device
is stationary, through measuring the Doppler frequency of received satellite
signals.
Offline Location – Determine device location, even when offline, by collecting
a token that gets replayed once devices are back online.
Power Optimization – Technology to minimize the number of access points that
need to be scanned to yield accurate location results and reducing the time it
takes to complete scans for access points.
https://www.skyhook.com/blog/what-is-an-sdk-and-an-api
A simplified example would be when you sign into Facebook from your phone you are telling
the Facebook application that you would like to access your account. The mobile application
makes a call to an API to retrieve your Facebook account and credentials. Facebook would
then access this information from one of its servers and return the data to the mobile
application.
These type of APIs called web APIs are the most common but limited just to the web. There
are APIs for virtually every machine or system that expects to interact with other machines or
systems.
APIs have been around for a long time but only recently have gained in popularity. Companies
use this technology to gain an edge over others by finding more efficient ways to retrieve
As I mentioned earlier web APIs are the not only ones that exist. We will dive into a few of
Types of APIs
Web APIs are what gets utilized the most but there are others that exist that you should know
about. These are just as reliable and efficient as the web API but not well known.
REST (RESTful) API — stands for representational state transfer and delivers data using the
lightweight JSON format. Most public APIs use this because of its fast performance,
dependability and ability to scale by reusing modular components without affecting the system
as a whole.
This API gives access to data by using a uniform and predefined set of operations. REST APIs
are based on URLs and the HTTP protocol and are based on these 6 architectural constraints:
1. Client-server based — the client handles the front end process while the server handles the
2. Uniform interface — defines the interface between client and server and simplifies the
3. Stateless — each request from client to server must be independent and contain all of the
necessary information so that the server can understand and process it accordingly.
4. Cacheable — maintains cached responses between client and server avoiding any
additional processing
5. Layered system — layers are arranged hierarchically so that each one can only ‘see’ the
executing code in the form of applets and scripts. This simplifies clients by reducing the
Once you follow these defined constraints the API you create is said the be RESTful.
SOAP — Simple Object Access Protocol is a little more complex then REST because it
requires more upfront about how it sends its messages. This API has been around since the
late 1990s and uses XML to transfer data. It requires strict rules and advanced security that
This protocol does not have the ability to cache, has strict communication and needs every
piece of information about an interaction before any calls are even thought of to be processed.
client performs a RPC by sending an HTTP request to a server that implements XML-RPC
JSON-RPC — is very similar to XML-RPC in that they work the same way except that this
protocol uses JSON instead of XML format. The client is typically software that calls on a
Important
When you ship or deploy your solution, you should use a managed solution and we
recommend that you always set the Is Customizable managed property to these
components to false. This will prevent people using your managed solution from
modifying or deleting these components of your solution. Such changes could break
code written for the original definition of the Custom API. More
information Managed properties
See the following topics for detailed information about the columns/attributes you
can set for these tables/entities. You should review this as you plan the behavior for
your Custom API.
For late-bound code, or for a Custom API that you have marked as private, create
an OrganizationRequest with the unique name of your custom API and add
parameters with names matching the unique names of the request properties.
You can access response properties from the parameters of the returned response.
C#Copy
var req = new OrganizationRequest("myapi_EscalateCase")
{
["Target"] = new EntityReference("incident", guid),
["Priority"] = new OptionSetValue(1)
};
HTTPCopy
POST [Organization URI]/api/data/v9.1/myapi_CustomUnboundAPI
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
{
"InputParameter": "Value"
}
This is an example invoking a Custom API Function bound to the account entity
named myapi_CustomBoundAPI:
HTTPCopy
GET [Organization URI]/api/v9.1/accounts(ed5d4e42-850c-45b7-8b38-
2677545107cc)/Microsoft.Dynamics.CRM.myapi_CustomBoundAPI()
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
This is an example invoking a Custom API Function bound to the account entity
collection named myapi_CustomEntityCollectionBoundAPI:
HTTPCopy
GET [Organization
URI]/api/v9.1/accounts/Microsoft.Dynamics.CRM.myapi_CustomEntityCollectionBoundAPI
()
OData-MaxVersion: 4.0
OData-Version: 4.0
Content-Type: application/json; charset=utf-8
More information:
You need to set the values for the Response Properties in the OutputParameters.
C#Copy
using System;
using System.Linq;
using System.ServiceModel;
using Microsoft.Xrm.Sdk;
namespace CustomAPIExamples
{
public class Sample_CustomAPIExample : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
// Obtain the tracing service
ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));
if (context.MessageName.Equals("sample_CustomAPIExample") &&
context.Stage.Equals(30)) {
try
{
string input =
(string)context.InputParameters["StringParameter"];
if (!string.IsNullOrEmpty(input)) {
//Simply reversing the characters of the string
context.OutputParameters["StringProperty"] = new
string(input.Reverse().ToArray());
}
}
catch (Exception ex)
{
tracingService.Trace("Sample_CustomAPIExample: {0}",
ex.ToString());
throw new InvalidPluginExecutionException("An error occurred
in Sample_CustomAPIExample.", ex);
}
}
else
{
tracingService.Trace("Sample_CustomAPIExample plug-in is not
associated with the expected message or is not registered for the main
operation.");
}
}
}
}
P4 Design and complete a ‘white box’ test of the application, recording the results.
The goal of WhiteBox testing in software engineering is to verify all the decision
branches, loops, statements in the code.
To exercise the statements in the above white box testing example, WhiteBox test
cases would be
A = 1, B = 1
A = -1, B = -3
There are automated tools available to perform Code coverage analysis. Below are
a few coverage analysis techniques a box tester can use:
Statement Coverage:- This technique requires every possible statement in the
code to be tested at least once during the testing process of software engineering.
Branch Coverage - This technique checks every possible path (if-else and other
conditional loops) of a software application.
Apart from above, there are numerous coverage types such as Condition Coverage,
Multiple Condition Coverage, Path Coverage, Function Coverage etc. Each
technique has its own merits and attempts to test (cover) all parts of software
code. Using Statement and Branch coverage you generally attain 80-90% code
coverage which is sufficient.
Statement Coverage
Decision Coverage
Branch Coverage
Condition Coverage
Multiple Condition Coverage
Finite State Machine Coverage
Path Coverage
Control flow testing
Data flow testing
https://www.guru99.com/white-box-testing.html