Skip to main content

API Designer

API Design

source: https://apiacademy.co/category/api-tutorials/api-design/





1. Introduction

What is an API

Application Programming Interface
  • A software interface, a building block that works behind the scenes to connect different applications and 
  • systems so they can share information.
  • Entry points into your organization's capabilities that can be accessed through different channels such as browsers, mobile apps, social networks, and IoT devices.
  • Are digital enablers

Digital feedback loop

Business Goals -> Digital Reach -> Business Results -> Data-driven Insigths

Benefits and Value of APIs

  • New revenew - monetized access to data and services
  • Reach and retention - reach captive audiences where they spend their time
  • Faster partnerships - partners can onboard in record time
  • Mobile ad omnichannel - consistent digital experience across all channels
  • Interaction analytics - digital feed loop allows real-tims analysis of user behaviour
  • Outsourced innovation - leads to unanticipated innovation from third party developers
  • Self-service integration - rapid integration of disparate business capabilities and assembly of new products
  • Organizational agility - Adoption of an "API First" engineering philosophy along with a microservices achitecture maximizes delivery speed, system stability and scalability

2. The API360 Model

Key components

  • Alignment and usefulness
    • strategy
      • business goals
      • funded projects
      • future value
      • unmet needs
      • disruptors
      • business value
    • deliverables
      • API roadmap and project cross reference
      • Organizational model
      • API Business model and business cases
  • Engagement and usability
    • stategy
      • consumers
      • developers
      • attract and retain
      • consumer needs
      • developer experience
      • tools
    • deliverables
      • developer program
      • API and DX design principles
      • API consumer toolkits
      • Hands-on education programs
  • Scalability and evolvability
    • strategy
      • factors
      • runtime
      • version
      • tecnhology trends
      • constraints
      • leverage
    • deliverables
      • API architecture guidelines
      • full API lifecycle methodology
      • technology roadmaps
      • intensive skills training
  • Manageability and security
    • strategy
      • operational metrics
      • business metrics
      • increase business agility
      • control access
      • protect privacy
      • threats
    • deliverables
      • API analytics and monitoring
      • API identity and security model
      • API infrastructure and operations
      • API management platform

3. API Styles

Standards are usually formal documents that establish uniform engineering or technical criteria, methods, processes, and practices.

Styles refer to abstract plans or conventions for the construction of an object or a system, such as architectural blueprints, engineering drawings or business processes.

Tunel Style (SOAP - Simple Object Access Protocol)

  • Exposes an RPC-like interface and provides an interface descriptor binding
  • Uses an XML-centric message format
  • Uses HTTP as a transport protocol for a higher application-level protocol
Advantages
  • RPC
  • tooling
  • governace model
Limitations
  • stack dependencies
  • XML-centric
  • Ingores HTTP features

URI Style (CRUD)

  • Exposes an object or resource-centric API
  • URIs and query parameters are used to identify and filter objects
  • CRUD (Create Read Update Delete) operations are mapped to HTTP methods
Advantages
  • HTTP path & query is "well known"
  • Object "tooling" is good
  • "hacking" is relatively easy
Limitations
  • URI modeling is not a standard
  • HTTP method set is very small
  • May became "chatty"

Hypermedia Style (REST - Representational State Transfer)

  • Exposes a task-based interface, often incorporating a workflow or state machine
  • Uses media to describe link semantics, template-based input and message structures
  • Provides its own URIs
Advantages
  • Media Types can be customized
  • Growing body of guidance
  • Favors services that will last many years
Limitations
  • Poor "tooling" (MSFT WebAPI)
  • Assumed to be "too hard"
  • Limited use in publics APIs (AWS AppStream API)

Event-driven/Reactive Style

  • Emphasis on event notifications
  • Asynchronous communication, "Reactive"
  • Emerging style
    • HTTP-based technologies: WebHooks, WebSockets
    • Non-HTTP technologies: Apache Kafka, AMQP
  • Popular with Domain-Drive Design (DDD), Command Query Responsability Segregation (CQRS), Microservices

GraphQL

  • Query language for APIs
  • Originated at Facebook
  • Intended for flexibility of arguments

gRPC

  • HTTP2-based protocol
  • Originated at Google
  • Intended for high scale communication

4. Designing APIs for Developers

Design: Funcionality, Usability, Experience

Functionality

  • Will the PI aloow me to access the data I need
  • Will it be running when I need it
  • Will I be able to connect to the system I want

Usability

  • How long will it take for me to get started
  • How difficult will it be for me to understand what is happening
  • How easily will I be able to fix mistakes

Experience

  • How does the API make me feel (DX)
    • The sum of interactions between the developer and the API designer
    • The emotive impact of API usage on the developer

Developer experience DX 

Troubleshooting
  • Clear error messages
  • Defect tracking
  • Documentation
  • Time to fix
Change management
  • API versioning
  • Release history
  • Backward compatibility
  • Upgrade or migration process
Education
  • Documentation
  • Annotations, sample code, scripts and SKDs
  • Demonstrations
  • Developer community engagement
Visibility
  • Log and usage access
  • Transaction tracing
  • Intuitive search funtion
Trust
  • Application stability
  • Honest communication
  • Security

5. Overcoming API Design Obstacles

API challenges
  • Cost
  • Scalability
  • Security
Design Obstacles
  • The perspective obstacle
  • Bias
  • Assumptions
  • Resourses

6. Architecturing your API

API architecture: The process of developing a software interace that exposes backend data and application functionality for use in new applications.

Qualities
  • Security
  • Usability
  • Reliability
  • Testability
  • Scalability
Layers
  • Client Application
  • Security
  • Caching
  • Representation
  • Orchestration
  • API/Resource
Design approach
  • Determine goals
  • Identify users
  • Design interface
  • Evaluate
  • Implement
Interface design feedback loop
  • Use sketching and prototyping to find the best design
  • Difficult to change API after it is released
  • Get feedback early in design process
  • Continue with user testing
  • Always refer back to design while in implementation

7. API Change Management

Change management
  • Versioning APIs and communicating what is new and what the risks and considerations ar for upgrading
  • Providing a clear release history, to easily track new and deprecated features and bugs, no matter which version a user is running
  • Supporting backword compatibility
  • When choosing to deprecate, making the upgrade or migration process as painless as possible
Postel's Law: Be conservative in what you send, be liberal in what you accept.

Extending the interface
  • Never take anything away
  • Never change the meaning of existing things
  • Make all new changes optional
Fork
  • Create a new version
  • Be clear about the new version so there is no confusion
  • Make forks very easy to identify
  • Make it easy to build
  • Make it easy to test
  • Support both versions in parallel
  • Make it as hard as possible for the user to mix the versions up

Comments

Popular posts from this blog

API Security

API Security source:  https://www.apisecuniversity.com/ Tools Kali Linux https://www.kali.org/ $ sudo apt update -y $ sudo apt upgrade -y $ sudo apt dist-upgrade -y $ sudo apt autoremove -y Passive API Reconnaissance Google Dorking Finds all publicly available WordPress API user directories. inurl:"/wp-json/wp/v2/users" Finds publicly available API key files. intitle:"index.of" intext:"api.txt" Finds potentially interesting API directories. inurl:"/api/v1" intext:"index of /" Finds all sites with a XenAPI SQL injection vulnerability. (This query was posted in 2016; four years later, there are currently 141,000 results.) ext:php inurl:"api.php?action=" This is one of my favorite queries. It lists potentially exposed API keys. intitle:"index of" api_key OR "api key" OR apiKey -pool GitDorking filename:swagger.json extension: .json TruffleHog $ sudo docker run -it -v "$PWD:/pwd" trufflesecurity/truf

XML Webservice (ASMX) - SOAP Request and Response Invocation logging

You are an integration developer. Eventualy you came into the state where there is nothing else you can debug, and you have to check which SOAP request it is built on the request, and which SOAP response you are getting from the server. C# XML Webservice (ASMX) - SOAP Request and Response Invocation logging In the legaccy .NET framework System.Web.Services , this means using soapExtensions to help you intersept the interaction with the webservice. This is done like so:  public class TraceExtension : SoapExtension     {         Stream oldStream;         Stream newStream;         string filename;         // Save the Stream representing the SOAP request or SOAP response into          // a local memory buffer.          public override Stream ChainStream(Stream stream)         {             oldStream = stream;             newStream = new MemoryStream();             return newStream;         }         // When the SOAP extension is accessed for the first time, the XML Web

Agile Leadership

Agile LeaderShip Reference: IPMA Reference Guide ICB4 in an Agile World https://www.ipma.world/news/ipma-reference-guide-icb4-agile-world/ 1. Perspective 1.1 Strategy Description: Change Blurred vision Agile strategy Emergent Create and adapt Giving meaning to work Key Competence Indicators Align agile teams with the organisational mission and vision Identify and exploit opportunities to influence organisational strategy Develop and ensure the ongoing validity of the business/organisational justification Determine, assess, and review critical success factors Determine, assess, and review key performance indicators Examples of Measures Reflects the mission and vision of the organisation Identifies new opportunities and threats which could alter the strategy Uses the CSFs for managing stakeholders Uses information systems for strategic performance 1.2 Governance, structures, and processes Description: Challenges Lean organisation Customer value Agile working Different structures Key Comp