Understanding how to leverage 3rd party API's in Amtelco environments
Presented by Patrick Labbett
Explaining why you should care.
Application Programming Interface
The term API can be used pretty generically for hardware and software technologies - any specification for how two systems interact would be an API.
middleware, adapter, bus, controller, interface, intermediate layer, middle-layer, router, SDK, API, specification, blueprints, instructions, parameters, schema, protocol
Everything is cake...
An API is a lot like a T-Shirt because...
Despite all the different ways that T-shirts are made, there is a mutual understanding of what a T-shirt is: cloth or similar material to cover your chest, abdomen, arms, and/or back.
You can be reasonably sure that if you follow the size and material information, that you'll be able to wear the T-Shirt when it arrives. The same principle holds true for most APIs.
How to mail a letter:
These specifications are similar to how an API would be documented. The API provides information on who you are trying to reach. The Post Office knows what the format is that you wrote. They deliver your letter - and for the most part how they achieve that doesn't matter - as long as the letter gets where it's going on time.
Let's use the IS Web REST API and the Intelligent database as an example!
Problem: Clear old dispatch jobs
Intelligent Database
Delete the records from the dispatch table. They don't disappear until you restart IS service. Or do it manually by hand.
ISWeb REST API
Call the REST API to delete the jobs and remove them from the dispatch list.
Amtelco handles the logic of clearing the dispatch list cache when this method is called, something they can't do easily at the database level.
"This is my API.
There are many like it, but this one is mine."
web, rest, SOAP, XML, JSON, webhooks, hl7, HTTP, graphql, and many, many more.
Our focus (the most popular you will run across):
HTTP Web-based RESTful APIs using JSON/XML
Let's go learn what this all means.
https://github.com/public-apis/public-apis
https://apilist.fun/
https://rapidapi.com/blog/most-popular-api/
https://www.programmableweb.com/apis/directory
https://api.data.gov/list-of-apis/
https://any-api.com/
https://public-apis.xyz/
Always vet your sources.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
Web browsers implement the HTTP protocol (or, API) and requests web pages from servers across the internet.
https://zapier.com/learn/apis/chapter-2-protocols/
Your web browser sends a request for a website, like GET calltheory.com
The web server returns a response and status code to tell your browser the result.
Retrieve resource
Create resource
Replace resource
Delete resource
Update or create resource
Same as GET, without body
Get communications options
A message loop-back test (out of scope)
Responses to the browser's request
Status codes tell the browser if the request they sent was successful. In general, 2XX means things went okay, 4XX means you did something wrong, and 5XX means the server did something wrong.
Status Code | Status Text | Description |
---|---|---|
200 | OK | Everything is good |
404 | Not Found | Page doesn't exist |
500 | Internal Server Error | Usually the application or server is broken or misconfigured. |
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
Abstraction of HTTP methods that applies to resources
REST (or RESTful, REST-like, etc.) APIs have:
HTTP Verb | Operation |
---|---|
POST | Create |
GET | Read |
PUT/PATCH | Update |
DELETE | Delete |
CREATE
READ
UPDATE
DELETE
Endpoint | Description |
---|---|
/contacts | List of contacts |
/contacts/123 | Contact with ID 123 |
/contacts/123/notes | Notes for contact with ID 123 |
/contacts/123/notes/567 | Get note with ID 567 that belongs to contact 123 |
Endpoint | Description |
---|---|
POST /contacts | Create a new contact |
GET /contacts/123 | Read contact 123 |
PUT /contacts/123 | Update contact 123 |
DELETE /contacts/123 | Delete contact 123 |
Let's take a look at requests and responses more in depth.
Request URL: https://learn.calltheory.com/always/ok/test-request
Request Method: GET
Status Code: 200
Remote Address: 206.189.228.103:443
Referrer Policy: strict-origin-when-cross-origin
Request
access-control-allow-origin: *
cache-control: no-cache, private
content-encoding: gzip
content-type: application/json
date: Sun, 10 Jan 2021 21:36:14 GMT
server: nginx/1.15.8
vary: Accept-Encoding
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta Information -->
<meta charset="utf-8">
<meta name="csrf-token" content="ti3Bj2NzvpqyLYxechHKyot2uka9mEmNNPjUjkuO">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#8c52ff" />
<title>Call Theory</title>
</head>
<body>
<!-- Website goes here -->
</body>
</html>
cache-control: no-cache, private
content-encoding: gzip
content-type: text/html; charset=UTF-8
date: Sun, 10 Jan 2021 23:36:57 GMT
server: nginx/1.15.8
vary: Accept-Encoding
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protec
Response Header
Response Body
http://apps.lansa.com/LearnLANSARESTAPI/index.html#!Documents/urlanatomy.htm
http://localhost:1234/hrservices/v1/users?id=1
https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
<menu id="file" value="File">
<popup>
<menuitem value="New" onclick="CreateNewDoc()" />
<menuitem value="Open" onclick="OpenDoc()" />
<menuitem value="Close" onclick="CloseDoc()" />
</popup>
</menu>
JSON response
XML response
(Sorry, no cool mnemonic)
Popular APIs will great documentation.
https://code.visualstudio.com/
https://ngrok.com/
https://jsonpath.com/
https://jsonlint.com/
https://www.ssllabs.com/ssltest
Join
#workshop
and ask questions!