API: взгляд потребителя

  • View
    98

  • Download
    0

Embed Size (px)

Transcript

  1. 1. API: WebCamp 2015,
  2. 2. 2
  3. 3. 3
  4. 4. 4 JSON-RPC REST XML-RPC SOAP WSDL, WSCL, WSFL CORBA Java RMI Apache Thrift AMF Microsoft RPC
  5. 5. 5
  6. 6. 6 XML Protocol Buffers JSON YAML SDXF CSV Sereal
  7. 7. 7 http://api.example.org/method?output=xml
  8. 8. 8
  9. 9. 9 api.example.org/v1/ api.example.org/v1.0/ api.example.org/v1.0.0/ Semantic Versioning: semver.org
  10. 10. 10 api.example.org/v1/ api.example.org/v1.x.x/ api.example.org/v1.0/ api.example.org/v1.0.x/
  11. 11. 11
  12. 12. 12 POST /get_status?n=2 HTTP/1.1 Content-type:application/x-www-form- urlencoded;charset=utf-8 Host: example.org Content-length: 22 Action=GetStatus&Id=42
  13. 13. 13 { "method": "get_status", "params": { "n":42 }, "id":1 }
  14. 14. 14
  15. 15. 15
  16. 16. 16 { "alpha": 2, "beta": "2.0", "gamma": "3,0", "delta": "4.0 ", "epsilon": null }
  17. 17. 17 5 c 2014 . ? 2014-09-05T00:00:00+02
  18. 18. 18 http://api.example.org/" + /method"
  19. 19. 19 ,
  20. 20. 20 [ {"jsonrpc": "2.0", "method": "sum", "params": [1,2,4], "id": "1"}, {"jsonrpc": "2.0", "method": "notify_hello", "params": [7]}, {"jsonrpc": "2.0", "method": "subtract", "params": [42,23], "id": "2"} ]
  21. 21. 21
  22. 22. 22 Request no-cache no-store max-age max-stale min-fresh no-transform only-if-cached Response public private no-cache no-store no-transform must-revalidate proxy-revalidate max-age s-maxage
  23. 23. 23 no cache 5 seconds 1 minute 15 minute 1 hour 6 hours 24 hours never expires
  24. 24. 24
  25. 25. 25 https://api.example.org/v1/method OAuth
  26. 26. 26
  27. 27. 27 API / API / $0 500 10 $100 5000 100 $200 100 000 1000
  28. 28. wmute@yandex-team.ru