SlideShare a Scribd company logo
1 of 62
API-Entwicklung
       bei XING

      Mark Schmidt
XING?

Bestehende APIs

Schritte zu einer guten API
?
Technologie-Department
rdware
Ha
Software
Bestehende APIs
Interne APIs:
YAML HTTP API / Perl Backend
Gearman
gemeinsam genutzte Datenbanken
SSH
FTP
AMQP / RabbitMQ
REST-APIs
Externe APIs:
XWS 1
XWS+
SOAP-Schnittstelle für Payment
(+ kleine Insellösungen)
das (externe) API-Team
Schritte zu einer guten API
                       Schritte zu einer
                          guten API
Warum ist API-Design wichtig?
Gute API?




→ J.Bloch, How to Design a Good API and Why it Matters, 2006
Einfach zu erlernen




→ J.Bloch, How to Design a Good API and Why it Matters, 2006
Einfach zu benutzen, auch
    ohne Dokumentation


→ J.Bloch, How to Design a Good API and Why it Matters, 2006
Lässt sich nur schwer falsch
             benutzen




→ J.Bloch, How to Design a Good API and Why it Matters, 2006
Client-Code ist gut les- und
              wartbar




→ J.Bloch, How to Design a Good API and Why it Matters, 2006
Ausreichend mächtig




→ J.Bloch, How to Design a Good API and Why it Matters, 2006
Einfach zu erweitern




→ J.Bloch, How to Design a Good API and Why it Matters, 2006
Geeignet für die Zielgruppe




→ J.Bloch, How to Design a Good API and Why it Matters, 2006
Probleme... Fragen... Lösungen?
REST!
REpresentationalStateTransfer!




→ R. Fielding, Architectural Styles and the Design of Network-based Software Architectures , 2000
Response-Format
GET https://api.xing.com/v1/users/123456_abcdef/contacts/upcoming_birthdays?limit=3&offset=0

                     {
                          "upcoming_birthdays": {
                            "total": 34,
                            "items": [{
                               "user": {"id": "52313245_52f7g0"},
                               "day": 20,
                               "month": 10,
                               "year": 1980
                            }, {
                               "user": {"id": "78787878_12h4g2"},
                               "day": 22,
                               "month": 10,
                               "year": 1965
                            }, {
                               "user": {"id": "3453245_h190cx"},
                               "day": 23,
                               "month": 10,
                               "year": null
                            }]
                          }
                     }
Status-Codes
200, 201, 204
400, 401, 403, 404, 405
(500, ) 503
∀ > 400 : {JSON,XML}
{
    "error_name": "INVALID_OAUTH_TOKEN",
    "message": "Invalid OAuth token",
    "revoke_reason": "PASSWORD_CHANGED"
}
API-Domäne != Produkt-Domäne
intern:                    Module	
  namespace



/rest/newsfeed/activitystream/:user_id
REST	
  API	
  namespace                         Module	
  Resources




extern:
/v1/users/:user_id/network_feed
Versionierung
GET api.xing.com/users/123?version=1
                    vs.
     GET api.xing.com/v1/users/123
                    vs.
      GET api.xing.com/users/123
Accept: application/vnd.xing.user-v1+json
Hinzufügen neuer Calls? Kein
     Problem, aber...
Call-Lifecycle
Eingabe




       ⤻
    Ausgabe
KISS
module WebService
  class CommentsController < WebService::ServiceController

    add_call :name => 'Get comments of an activity',
      :description => "Returns a list of all comments which have been made for an activity.",
      :status => :experimental,
      :experimental_since => '2011-05-02',
      :action => 'index',
      :permission => :activity_stream,
      :required_parameters => {
         "activity_id" => "Activity ID"
      },
      :optional_parameters => {
         'limit' => "How many comments to return. Must be a positive number. Default: 10",
         "offset" => "Offset. Must be a positive number. Default: 0",
         "user_fields" => "Comma separated list of user attributes to return..."
      },
      :returns => {
         :success            => {:code => 200, :message => 'The call was completed successfully'},
         :invalid_parameters => {:code => 403, :message => '...', :error => 'INVALID_PARAMETERS'},
         :access_denied      => {:code => 403, :message => '...', :error => 'ACCESS_DENIED'},
         :activity_not_found => {:code => 404, :message => '...', :error => 'ACTIVITY_NOT_FOUND'}
      },
      :response_example => "..."

  end
end
module WebService::Handlers
  class CommentsHandler < WebService::Handlers::Base
    include WebService::Handlers::Helpers

    def index(params)
      activity = find_activity!(params[:activity_id], :rid => User.current.id)
      limit, offset = pagination_params!(params[:limit], params[:offset])
      result = { :comments => [] }

      if activity[:comments].any? && activity[:comments].size > offset
        user_fields = filter_user_fields(params[:user_fields])
        result[:comments] = ActivityStream::Comment.build(activity[:comments],
                                    :user_fields => user_fields)[offset, limit]
      end

      result
    rescue ResourceNotFoundError
      :activity_not_found
    rescue InvalidParameterError => e
      [:invalid_parameters, {:message => e.message}]
    rescue AccessDeniedError
      :access_denied
    end
  end
end
ActionController::Routing::Routes.draw do |map|
  map.namespace(:web_service, :path_prefix => 'v1') do |v1|
    v1.resources :activities do |activities|
      activities.resources :comments, :only => [:index]
    end
  end
end
Oauth für Partnerintegrationen?
Wie geht‘s weiter?
Noch 2 Punkte in eigener Sache:
api@xing.com
Product Owner
            Ruby Developer
             Perl Developer
Quality Assurance Manager
        Frontend Developer
       Interaction Designer
                         ...

          XING sucht
       neue Kollegen!
API-Entwicklung bei XING

More Related Content

Similar to API-Entwicklung bei XING

SH 1 - SES 8 - Stitch_Overview_TLV.pptx
SH 1 - SES 8 - Stitch_Overview_TLV.pptxSH 1 - SES 8 - Stitch_Overview_TLV.pptx
SH 1 - SES 8 - Stitch_Overview_TLV.pptx
MongoDB
 
Evolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB StitchEvolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB Stitch
MongoDB
 

Similar to API-Entwicklung bei XING (20)

Serverless - Developers.IO 2019
Serverless - Developers.IO 2019Serverless - Developers.IO 2019
Serverless - Developers.IO 2019
 
MongoDB Stich Overview
MongoDB Stich OverviewMongoDB Stich Overview
MongoDB Stich Overview
 
Exploring Relay land
Exploring Relay landExploring Relay land
Exploring Relay land
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
 
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB.local Sydney: Evolving your Data Access with MongoDB StitchMongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
 
SH 1 - SES 8 - Stitch_Overview_TLV.pptx
SH 1 - SES 8 - Stitch_Overview_TLV.pptxSH 1 - SES 8 - Stitch_Overview_TLV.pptx
SH 1 - SES 8 - Stitch_Overview_TLV.pptx
 
Evolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB StitchEvolving your Data Access with MongoDB Stitch
Evolving your Data Access with MongoDB Stitch
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needs
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needs
 
Medium TechTalk — iOS
Medium TechTalk — iOSMedium TechTalk — iOS
Medium TechTalk — iOS
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Again
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDB
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
MongoDB Stitch Introduction
MongoDB Stitch IntroductionMongoDB Stitch Introduction
MongoDB Stitch Introduction
 
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di PalmaEvolving your Data Access with MongoDB Stitch - Drew Di Palma
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
 
IOOF IT System Modernisation
IOOF IT System ModernisationIOOF IT System Modernisation
IOOF IT System Modernisation
 
Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
 
Introducing MongoDB Stitch, Backend-as-a-Service from MongoDB
Introducing MongoDB Stitch, Backend-as-a-Service from MongoDBIntroducing MongoDB Stitch, Backend-as-a-Service from MongoDB
Introducing MongoDB Stitch, Backend-as-a-Service from MongoDB
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

API-Entwicklung bei XING