My computer talks with your computers
Overview
APIs are how computers talk with each other, without user intervention or command.
APIs are being used by many web and mobile apps to communicate with servers.
APIs are also called “microservices”.
The less coupling, the less predefined semantics, the greater means to evolve.
Fundamental shift
To me, APIs are a big deal because they enable a fundamental shift from people (humans) initiating actions by clicking on User Interfaces (UIs) to computers initiating actions.
With Internet of Things (IoT), there will be so many devices that it is impractical for someone to log into each device.
Permissions for computers to act are given not by passwords entered, but by long-lived “service accounts”.
QUESTION: Who are the vendors helping end-consumers manage the rapidly proliferating bots working on their behalf.
Programming Languages
MS Azure API generates code for several languages:
- Curl for interactive exploration on command lines
- C#
- Java
- JavaScript
- ObjC (Objective-C for iOS)
- PHP
- Python
- Ruby
Apps in various programming languages for APIs
- desktop client web apps
- mobile web app (Sencha, etc. using Cordova)
- mobile native app for iPhone (Objective-C and Swift)
-
mobile native app for Android (Java and Scala)
- functional testing of clients
-
performance testing of clients
- mock servers during development
-
servers
- functional testing of servers
-
performance testing of servers
- API Management servers API publishers use to create and maintain API consumer accounts and establish a gateway to obtain API usage metrics needed to enforce API usage plans.
Styles of Implementation
Can apps call Assembly style (composite) requests such as customerOrder?
-
This provides a simpler structure but more complex steps for developers to code.
-
But the Assembly style can create a more complex implementation for API developers.
Issues
I am intrigued by this article on ProgrammableWeb by Jeff Cogswell:
“Note that there’s a potential bug in this code that I need to discuss as it applies to API programming in general, especially in an asynchronous context.
Although node.js is single-threaded, it is asynchronous. Look at the code following the request line; any code that follows the call to request will execute immediately after the call to request, probably before request finishes. That means you can’t put a send function right after the call to request. If you do, the data won’t be there. Instead, you have to put the send call inside request’s callback.
But because of this, if the call to request() takes a while, a second browser request in this server code could come in. Since the first call to request() hasn’t come back yet, this second browser request will indeed start stepping into the app.get handler. Yes, node.js is single threaded, but it is asynchronous, and the first browser request will pause as it awaits the return of the request() call, allowing other browser requests to come in. (That’s the whole idea behind the asynchronous nature.) While the code would still function, the end result would be more API calls than necessary, which is an issue in the code as it currently stands. As such, for your production code, you’ll want to add necessary functionality to this example to handle that situation.
Perhaps an alternative would be to do an initial API call when the program starts (and wait before the program starts accepting browser requests until that call returns), and then set a timer to do periodic calls separate to that. The browser request would simply retrieve whatever data is currently in the radar object. (These are the things you need to pay careful mind to when making asynchronous API calls; otherwise you’ll encounter strange behavior and bugs that can be extremely difficult to track down.)”
MVC :
These steps are based on Create MVC 6 via ASP.NET 5 Preview in VS 2015
- Open VS 2015.
- Create MVC project.
- ASP.NET 5 Preview.
- Change the
project.json
to be like this:
5. Modify Startup.cs
to add configurations:
Azure Logic Apps
Azure Logic Apps allow developers to design workflows that start from a trigger and then execute a series of steps, each invoking an App Service API App whilst securely taking care of authentication and best practices like checkpointing and durable execution.
See https://azure.microsoft.com/en-us/documentation/services/app-service/logic/
Create a sample Ping logic app on a temporary (24 hour account) to ping a website on a recurring schedule, then extend it to take an action depending on the result of the ping.
More on API Microservices
This is one of a series:
- API Portals
- GraphQL API
- GitHub API
- GitHub GraphQL API
- API Swagger
- API Design Tools
- API Design
- API Programming
- REST API Responses
- API Management Evaluation
- API Management by Microsoft Azure
- API Management by Amazon
- PowerShell GitHub API Programming
- PowerShell API Programming
- PowerShell Desired State Configuration
- PowerShell on Mac