版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
APIDesign3rdEditionKevinSwiber@kevinswiberApigee@apigeeBrianMulloy@landlessness
/group/api-craft/apigee/apigee@landlessness@kevinswiber“Therealissueisaboutdesign:designingthingsthathavethepowerrequiredforthejobwhilemaintainingunderstandability,thefeelingofcontrol,andthepleasureofaccomplishment.-DonaldNorman/photos/mattharvey1/5712604622/AgendaRecapPreviousEditionAPIModelingSecurityMessageDesignHypermediaTransactions/web-api-design-ebook/URLDesignPluralnounsforcollections/dogsIDforentity/dogs/1234Associations/owners/5678/dogs4HTTPMethodsPOST
GETPUTDELETEBiastowardconcretenames/dogs(notanimals)MultipleformatsinURL/dogs.json/dogs.xmlPaginatewithlimitandoffset?limit=10&offset=0Queryparams?color=red&state=runningPartialselection?fields=name,stateUsemedialcapitalization
"createdAt":1320296464myObject.createdAt;Useverbsfornon-resourcerequests/convert?from=EUR&to=CNY&amount=100Search/search?q=happy%2BlabradorDNSErrors8
StatusCodes200201304400401403404500Verbosemessages{"msg":
"verbose,plainlanguagehints"}VersioningIncludeversioninURL/v1/dogsKeepone
previousversionlongenoughfordeveloperstomigrate
/v1/dogs/v2/dogsClientConsiderationsClientdoesnotsupportHTTPstatuscodes?suppress_response_codes=trueClientdoesnotsupportHTTPmethodsGET/dogs?method=postGET/dogsGET/dogs?method=putGET/dogs?method=deleteComplementAPIwithSDKandcodelibraries1.JavaScript2.…3.…HowdowegetstartedwithourAPI?BuildanAPIModel/photos/brent_nashville/2156695472/in/photostream/Don’tGoCowboy/photos/theory/3364213389/in/photostream/HowdowesecureourAPI?Authorization:BasicaWhlYXJ0OmFwaXM=TwitterStreamingAPIAuthorization:AWSAKIAIOSFODNN7EXAMPLE:frJIUNo//yllqDzg=AmazonWebServicesAPIAuthorization:Bearer1/fFBGRNJru1FQd44AzqT3ZgGoogleAPI PreferredAuthorizationAuthorization:Bearer1/fFBGRNJru1FQd44AzqT3ZgOAuth2Howdoapproachmessagedesign?SupportmultipleformatsJSONandXMLMakeJSONthedefaultHowdowerepresentsingleitems?21TwitterFoursquare{
"meta":{…},"data":{}}
Instagram{
"meta":{…},
"notifications":
[…],
"response":{}}{"created_at":"ThuJan1008:44:59+00002013","id":289291736440791040,"id_str":"289291736440791040","text":"@landlessnesshere'soneforyou:50-yearplantofixDetroit\n\nhttp://t.co/kJ2l1FZv","source":"<ahref="/download/android"rel="nofollow">TwitterforAndroid</a>","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":41020312,"in_reply_to_user_id_str":"41020312","in_reply_to_screen_name":"landlessness","user":{…},"geo":{…},"coordinates":{…},"place":{…},"contributors”:{…},"retweet_count":0,"entities":{…},"favorited":false,"retweeted":false,"possibly_sensitive":false}22TwitterFoursquare{
"meta":{…},"data":{
"attribution":
{…},
"type":"image",
"location":
{…},
"comments":
{…},
"filter":"Sierra",
"created_time":
"1357826573",
"link":"http://instagr.am/p/UTk5Xut3gN/",
"likes":
{…},
"images":{…},
"caption":{…},
"user_has_liked":false,
"id":"365798266911553549_3573549",
"user":
{…}}}
Instagram{
"meta":{…},
"notifications":
[…],
"response":{
"checkin":{"id":"50eeff78e4b0f8e9624ea5f8",
"createdAt":1357840248,
"type":"checkin",
"shout":"Pharmacy#DRUGS!!!#ToothPulled:(",
"timeZone":"America/Detroit",
"timeZoneOffset":-300,
"user":{…},
"venue":{…},
"source":{…}
}
}}{"created_at":"ThuJan1008:44:59+00002013","id":289291736440791040,"id_str":"289291736440791040","text":"@landlessnesshere'soneforyou:50-yearplantofixDetroit\n\nhttp://t.co/kJ2l1FZv","source":"<ahref="/download/android"rel="nofollow">TwitterforAndroid</a>","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":41020312,"in_reply_to_user_id_str":"41020312","in_reply_to_screen_name":"landlessness","user":{…},"geo":{…},"coordinates":{…},"place":{…},"contributors”:{…},"retweet_count":0,"entities":{…},"favorited":false,"retweeted":false,"possibly_sensitive":false}23TakethebestofFoursquareandInstagram{
"meta":{…},
"dog":{…}"notifications":
[…],}Howdowerepresentcollections?25TwitterFoursquare{
"meta":{…},"data":[
{
"attribution":{…},
"type":"image",
"location":{…},
"comments":{…},
"filter":"Sierra",
"created_time":"1357826573",
"link":"http://instagr.am/p/UTk5Xut3gN/",
"likes":{…},
"images":{…},
"caption":{…},
"user_has_liked":false,
"id":"365798266911553549_3573549",
"user":{…}
},
{…},
{…}]}}
Instagram{
"meta":{…},
"notifications":
[…],
"response":{
"recent":[
{
"id":"50eeff78e4b0f8e9624ea5f8",
"createdAt":1357840248,
"type":"checkin",
"shout":"Pharmacy#DRUGS!!!#ToothPulled:(",
"timeZone":"America/Detroit",
"timeZoneOffset":-300,
"user":{…},
"venue":{…}
},
{…},
{…},]
}}[
{"created_at":"ThuJan1008:44:59+00002013","id":289291736440791040,"id_str":"289291736440791040","text":"@landlessnesshere'soneforyou:50-yearplantofixDetroit\n\nhttp://t.co/kJ2l1FZv","source":"<ahref="/download/android"rel="nofollow">TwitterforAndroid</a>","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":41020312,"in_reply_to_user_id_str":"41020312","in_reply_to_screen_name":"landlessness","user":{…},"geo":{…},"coordinates":{…},"place":{…},"contributors”:{…},"retweet_count":0,"entities":{…},"favorited":false,"retweeted":false,"possibly_sensitive":false},
{…},
{…}]26TakethebestofFoursquareandInstagram{
"meta":{…},"dogs":{…}/*includesameinfoassingle*/"notifications":
[…],}Howdowerepresentsearchresults?“Selectingresultsisnotthesameassearching.-FacebookAPI29BingSearchGoogleCustomSearch{"kind":"Listing","data":{"after":"t3_qy342","before":null,"children":[{"data":{"id":"f605o","num_comments":943,"score":1146,"ups":3110,"downs":1964,"created":1295553753.0,"url":"/r/AskReddit/comments/f605o/this_is_a_long_shot_any_sushi_chefs_need_a_job_in/","author":"jining",}},{"data":{"id":"c9eng”,"num_comments":308,"score":59,"ups":128,"downs":69,"created":1275155900.0,"url":"/r/IAmA/comments/c9eng/i_am_a_sushi_man_ama/","saved":false,"is_self":true,"permalink":"/r/IAmA/comments/c9eng/i_am_a_sushi_man_ama/","author":"IAmASushiMan”}}]}}
RedditSearch{"kind":"customsearch#search","url":{"type":"application/json","template":"/customsearch/v1?q={searchTerms}…},"queries":{"request":[{"title":"GoogleCustomSearch-sushi","totalResults":"15000000","searchTerms":"sushi","count":10,"startIndex":1,}]},"context":{"title":"CustomSearch"},"searchInformation":{"searchTime":0.314942,"formattedSearchTime":"0.31","totalResults":"15000000","formattedTotalResults":"15,000,000"},"items":[{"kind":"customsearch#result","title":"StandardizedUsageStatisticsHarvestingInitiative(SUSHI...-NISO","htmlTitle":"\u003cb\u003eStandardizedUsageStatisticsHarvestingInitiative\u003c/b\u003e(\u003cb\u003eSUSHI\u003c/b\u003e\u003cb\u003e...\u003c/b\u003e-NISO","link":"/workrooms/sushi","displayLink":"","snippet":"TheStandardizedUsageStatisticsHarvestingInitiative(SUSHI)Protocolstandard(ANSI/NISOZ39.93-2007)definesanautomatedrequestandresponsemodel...”,{
"SearchResponse":{"Version":"2.2","Query":{"SearchTerms":"sushi"},"Web":{"Total":95200000,"Offset":0,"Results":[{"Title":"TheSushiFAQ-Theultimateguidetosushiandsashimiandhowto...","Description":"Whatissushi?..","Url":"/","CacheUrl":"/cache.aspx?q=sushi&d=4855190808495712&w=yU8fJS-YPT-f4svREMW2xSa75OoBUAZR","DisplayUrl":"","DateTime":"2013-01-08T15:12:00Z"},{"Title":"WhatIsSushi?-SushiGuide-E","Description":"E...","Url":"/whatsushi.asp","CacheUrl":"/cache.aspx?q=sushi&d=5013249854931333&w=ihBzI9k9WbrnwxKcV3n8mOoV97M89K-b","DisplayUrl":"/whatsushi.asp","DateTime":"2013-01-07T13:51:00Z"}]}}}30(Mostly)FollowGoogleCustomSearch{"meta":{"limit":1,
"offset":10,
"totalResults":15000000,
"query":"sushi","searchTime":0.314942},
"results":[
{},{},
{}]}Howdowerepresentlinks?LinkingExamples<link
href=“http:///catalog/people/100637”rel=“http:///catalog/person.actor”title="ElijahWood”></link>NetflixAPI"organization":{
"login":"octocat",
"id":1,
"url":"https:///users/octocat",
"type":"Organization”}GitHubAPIPreferredLinking<link
href=“http:///catalog/people/100637”rel=“http:///catalog/person.actor”title="ElijahWood”></link>FollowNetflixandtheWebLinkingspecHowdowerepresentactions?ActionExamplesGitHub”actions":[{
“name”:“edit-repo”,
“method”:“PATCH”,
“href”:“/repos/kevinswiber/siren”,”fields”:[{“name”:“name”,“type”:“text”},
{“name”:“description”,“type”:“text”}}]Form-basedAPIPreferredAction"actions":[{
"name":"edit-repo",
“method”:“PATCH”,
“href”:“/repos/kevinswiber/siren”,”fields”:[{“name”:“name”,“type”:“text”},
{“name”:“description”,“type”:“text”}}]Form-basedAPIHowdowerepresentmetadata?PreferredMetadata<item
type="photo”
id="10289”server="2”views="47”
faves="0”
more="0">FlickrAPI(inline){
"size":"225.4KB”,
"rev":"35e97029684fe”,"bytes":230783,
"modified":"Tue,19Jul201121:55:38+0000”,
"path":"/Getting_Started.pdf”,
"is_dir":false,
"icon":"page_white_acrobat”,
"root":"dropbox”,
"mime_type":"application/pdf”,
"revision":220823}DropboxAPI(/metadata)Metadata
Examples39Includeametadatainresponsesandconsideradedicated/metaresource{
"meta":{
"size":"225.4KB”,"rev":"35e97029684fe”,"bytes":230783,"modified":"Tue,19Jul201121:55:38+0000”,"path":"/Getting_Started.pdf”,"is_dir":false,"icon":"page_white_acrobat”,"root":"dropbox”,"mime_type":"application/pdf”,"revision":220823
}}Whatcanwelearnfromhypermediatypes?Atom/AtomPub<?xmlversion="1.0"?><entryxmlns="http:///2005/Atom">
<title>MyNewCollection</title>
<id>urn:uuid:de46e3a1-e489-41a6-88a6-21e7f0e8e2d8</id>
<updated>2009-06-12T12:13:46Z</updated>
<author>
<name>Daffy</name>
</author>
<summarytype="text"/>
<contenttype="application/atom+xml;type=feed"
src="/my-new-collection"/><linkrel="edit”
href="/my-new-collection.atom"/></entry>XHTML<ulclass=“searchuser-list”>
<liclass=“user”>
<divclass="avatar">
<ahref="/users/@kevin">
<imgclass=”user-image"src=”/img/avatar.png"/>
</a>
</div>
<div>
<ahref=“/users/@kevin”rel=“usermessages”>
<spanclass=“user-name”>@kevin</span>
(<spanclass="user-text">@kevin</span>)
</a></div>
</li></ul>HAL{
“currentlyProcessing”:14“shippedToday”:20,
“_links”:{
“self”:{“href”:“/orders?page=2”},
“next”:{“href”:“/orders?page=3”},
“prev”:{“href”:“/orders?page=1”}
}}Collection+JSON{“collection”:
{
“version”:“1.0”,
“href”:“/friends”,“items”:[
“href”:“/friends/kevin”,
“data”:[
{“name”:“full-name”,“value”:“KevinSwiber”}
]],
“queries”:[
{“rel”:“search”,“href”:“./search”,“data”:[
{“name”:“search”,“value”:“”}
]
}}Siren{
“class”:[“owner”,“vip”],
“properties”:{
“name”:“Kevin”},
“entities”:[
{
“rel”:[“https://rels.x.io/dog”],
“href”:“https://api.x.io/dogs/1”}
],
“actions”:[
{
“name”:“adopt”,
“method”:“POST”,
“href”:“https://api.x.io/owners/1/dogs”,
“fields”:[{“name”:“dog-name”,“type”:“text”}]
}],
“links”:[
{“rel”:[“self”],“href”:“https://api.x.io/owners/1”}
]}Howdoweacceptbinarydata?multipart/form-dataContent-Type:multipart/form-data;boundary=AaB03x--AaB03xContent-Disposition:form-data;name=“caption”Coolpictureofmycat.--AaB03xContent-Disposition:form-data;name=“photo”;filename=“catpajamas.jpg”Content-Type:image/jpegContent-Transfer-Encoding:binary…contentsofcatpajamas.jpg…--AaB03xInlineBase64EncodingPOST/photos{
“caption”:“Coolpictureofmycat.”“photo”:“RHVkZSwgbXkgY2F0IGhhcyB0aGUgYmVzdCBwYWphbWFzLg==”}2-StepProcessPOST/photos{
“caption”:“Coolpicture
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年度教育机构合作经营合同纲要
- 浸制药液项目可行性实施报告
- 引擎用摇臂项目可行性实施报告
- 日式木屐制造设备相关项目实施方案
- 教育机构合作伙伴关系改进方案
- 工业园区安全生产管理规范
- 六年级英语下册Unit 1单元话题写作“寓言故事”译林版三起
- Unit2语法(复习讲义)-2023-2024学年六年级英语上册单元速记·巧练(人教PEP版)
- 区块链云存储服务数据备份计划
- 电影放映机相关项目建议书
- 少儿美术课件国家宝藏系列《云肩》
- 教师业务考试试题
- 2024年环磷酰胺原料药项目发展计划
- 国开(河北)2024年《商务谈判实务》形成性考核1-4答案
- 2024年统编版新教材语文小学二年级上册第四、第五单元检测题附答案(各一套)
- 2024年公路养护工技师考试试题及答案
- 人教PEP五年级上册英语说课稿 Unit 1 What's he like 第二课时
- 2024年专属石斛采购与销售合作协议
- 2024-2030年中医理疗行业市场发展分析及前景趋势与投资研究报告
- 服装采购合同电子版
- 2024-2025学年新教材高中化学 第二章 海水中的重要元素-钠和氯 1 钠及其化合物教案 新人教版必修1
评论
0/150
提交评论