SlideShare una empresa de Scribd logo
1 de 70
Survival Strategies for API
Documentation
By Tom Johnson
www.idratherbewriting.com
Feb 2, 2015
Southwestern Ontario STC Chapter Webinar
"Complete and accurate documentation" is most important factor in APIs, according to
a survey by @programmableweb. 250 respondents.
Important factors in API doc
Presentation by John Musser, founder of programmableweb.com,
which has directory of 12,000+ APIs
Says, “The client wants to
find someone who'll emulate
Dropbox's developer
documentation”
Docs are how users
navigate an API product.
With APIs, docs are the interface
More
info
needed
About me
• Started doing API/SDK documentation
a couple of years ago.
• Am still learning a ton, but enjoy
this type of documentation a lot.
• English major / writing background.
Not a programmer, but I do like code.
• Blog and podcast at
idratherbewriting.com
Disclaimer:
There’s a lot
of things I
simply do not
know.
Some basics about the API landscape
System B
System A
An API is an interface
between two systems.
Lots of different types
of APIs – for example:
1. Platform APIs that
you download and
add to your project
before compiling.
2. REST APIs that you
access through
HTTP web requests.
SDK versus API
• API (application programming interface): An
interface that provides endpoints, classes, or
other functions.
• SDK (software development kit): A set of
implementation tools to make it easier to work
with an API.
SDK example: A JavaScript SDK that allows you to
work with a particular REST API using JavaScript
syntax as your implementation format.
Reference and User Guides
API docs usually
have at least two
deliverables.
Auto-doc with Platform APIs
/**
* Reverses the order of the elements in the specified list.<p>
*
* This method runs in linear time.
*
*
* @param list the list whose elements are to be reversed.
* @throws UnsupportedOperationException if the specified list or
* its list-iterator does not support the <tt>set</tt>
operation.
*/
public static void reverse(List<?> list) {
int size = list.size()
if (size < REVERSE_THRESHOLD || list instanceof
RandomAccess) {
for (int i=0, mid=size>>1, j=size-1; i<mid;
i++, j--)
swap(list, i, j);
} else {
…
Add documentation in the
source code, structuring it with
specific syntax that a
documentation generator can
read.
Comments get rendered into Javadoc
- Commonly used.
- Works only for Java.
- Run it from your IDE.
- Automate into builds.
- Explore other doclets.
- Has frame-based -
output.
- Can skin with CSS.
- Looks professional.
Doxygen
- Commonly used.
- Works with Java, C++,
C#, and others.
- Has easy front-end GUI.
- Point it at your source
files.
- Automate into builds.
- Can include non-source
files (Markdown).
- Frame-based output.
- Skinnable.
Good example of source-gen. doc
https://www.dropbox.com/developers/core
Each language
uses a doc
generator for
that language.
https://www.dropbox.com/developers/core
Pros of in-source documentation
- Avoids documentation
drift
- Allows the person who
creates the code (and
so best understands it)
to also document it
- Includes tooltips when
others incorporate the
library into their
projects
- Integrates into
developer’s IDE
Doc
SrcDoc Src
Continental drift
Pros/cons with Platform APIs
Pros
Performance: Performance is faster. (REST APIs struggle
with latency for web calls.)
Security: More secure.
Cons
Language coverage: Harder for devs to create APIs for
each language (C++, Java, etc.). As prog. languages
proliferate, it’s harder to keep up.
Upgrades: Once clients install, it’s hard to encourage
upgrades to latest versions.
REST API basics
URLs requests return specific data HTTP Request
Response
Responses in JSON or XML
Configuration
parameters
ResponseinJSONformat
Add parameters to endpoints
https://api.flickr.com/services/rest/?method=flic
kr.activity.userPhotos&api_key=1712c56e30dbad
5ef736245cda0d1cb9&per_page=10&format=js
on&nojsoncallback=1
Knowing what parameters
you can include with an
endpoint is a huge part of the
REST API documentation.
cURL calls
HTTP requests are often demonstrated through
cURL calls, with different HTTP methods:
GET – retrieve
POST – edit
PUT – create
DELETE – remove
You can use a command line to pass cURL calls, and
you can specify different HTTP methods.
Many sample REST calls
are demonstrated in cURL.
Flickr Example: Get gallery photos
Get flickr photo gallery
Endpoint:
flickr.galleries.getPhotos
Endpoint with values:
https://api.flickr.com/services/rest/?method=fl
ickr.galleries.getPhotos&api_key=c962d7440cbbf3
81785c09999ba8032e&gallery_id=66911286-
72157647277042064&format=json&nojsoncallback=1
Response:
{
"score": 92.2655186160279,
"scoreDelta": {
"dayChange": 0.00044535591406713593,
… }
Flickr Response
$("#flickr").append('<img src="https://farm' +
farmId + '.staticflickr.com/' + serverId + '/'
+ id + '_' + secret + '.jpg"/>');
API reference docs don’t
tell you how to actually do
a real task. To construct
the img URL, you need to
combine 4 different parts
from the response.
Flickr Result
More details on the API calls
Go here for details:
http://bit.ly/restapiexamples
Convert your help into an API
The Jekyll Pages
API plugin
converts your
Jekyll pages into a
JSON file.
http://idratherbewriting.com/wp-content/apidemos/docasapi/api/v1/pages.json
Call the API
<script>
var url = "http://idratherbewriting.com/wp-
content/apidemos/docasapi/api/v1/pages.json";
$.getJSON(url, function(data) {
console.log(data);
$.each(data.entries, function(i, page) {
if (page.url == "/wp-content/apidemos/docasapi/mynameistom/") {
$("#tomsmyname").append(page.body);
}
});
});
</script>
<div id="tomsmyname"></div>
Sample Responses
http://idratherbewriting.com/wp-content/apidemos/sampledocapicall.html
More details
http://bit.ly/jekylljsonapi
With REST APIs, auto-doc not as
common b/c source lang. varies
“The beauty of Web APIs is that they can be written in
whatever language you like and in whatever manner you
like. As long as when an HTTP request comes in, the proper
HTTP response goes out, it doesn't matter how it actually
happens on the server. But this very flexibility makes
automated documentation nearly impossible, since there's
no standard mapping between what an API request is and
what the code is that generates its response.”
-- Kin Lane, APIevangelist.com
Autodoc possibility: Swagger spec
RAML (REST API modeling language)
Swagger UI can parse the Swagger
syntax and render an output
Generates an endpoint
based on values you
enter
Mashery with Klout
Doc becomes
interactive
when you’re
signed in.
http://developer.klout.com/io-docs
Mashery.io
This is an API for
USA Today. The
Swagger and
RAML parsers
essentially create
an API explorer
experience with
some doc mixed
in.
http://developer.usatoday.com/io-docs
Swagger spec can be in source code or
in separate YML file
• Swagger spec syntax can be separate yml file
or integrated in code using a specific Swagger
library
• Swagger has various libraries for different
languages.
• Swagger spec is different from Swagger UI
• RAML is a competing spec to Swagger
Information survey on my blog
• 42 respondents working in API documentation
• Many people polled from API Documentation
group on Linkedin + blogosphere
Types of APIs that writers document
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
Are you automating REST API docs?
No Yes N/A
0%
10%
20%
30%
40%
50%
60%
70%
Percent
How are you automating REST API
docs?
• - custom scripts
• - custom tooling
• - homegrown framework
• - homegrown Python scripts
• - custom tooling
• - Swagger
• - Swagger
• - Swagger
• - Corilla.co
• - code responses auto-generated
• - some code samples auto-generated
Authoring tools used by API doc
writers
0
10
20
30
40
50
60
70
80
Do you test out the API calls used in
your doc yourself?
Yes No Sometimes
0%
10%
20%
30%
40%
50%
60%
What IDE do you use?
Eclipse None Visual Studio IntelliJ IDEA Xcode Other
0%
5%
10%
15%
20%
25%
30%
35%
40%
45%
50%
Most common programming
languages tech writers know
0
5
10
15
20
25
Do developers write the initial API
documentation in the source code?
Yes No Sometimes
28%
29%
30%
31%
32%
33%
34%
35%
36%
37%
Do you write doc by looking in the
source code?
Yes No
0%
10%
20%
30%
40%
50%
60%
70%
How do you access the source code?
Git Perforce No access to
code
SVN Other Mercurial
0%
5%
10%
15%
20%
25%
30%
35%
40%
Most difficult part of API doc?
Understand
code
Get info from
engineers
Create non-ref
docs
Understand
audience
Identify
dependencies
0%
5%
10%
15%
20%
25%
30%
35%
40%
45%
50%
Percent
How did you learn what you needed to
know?
0%
5%
10%
15%
20%
25%
30%
35%
40%
45%
50%
Takeaways from survey
• Java, Eclipse, Git are popular
• Become familiar with getting info from both
source code and developers
• Become a self-learner but also interact heavily
with engineers
• REST APIs are by far most common
• Automating REST API doc isn’t all that
common
Programmableweb.com: API Directory
12,000 + web APIs
What design
trends or patterns
do we see among
popular API doc
sites?
Stripe API
Code responses
next to doc.
https://stripe.com/docs/api
Single page scroll w/ TOC highlight
Third column to show
responses or code samples.
http://crimson-cormorant.cloudvent.net/
Jekyll API doc theme from
CloudCannon
Bootstrap scollspy demo
Yelp API
One seamless website
matching product
branding.
http://www.yelp.com/developers/documentation
Twilio API
One output, with
nav tabs to show
different
languages
Twitter API
Interactive, real-
time requests
based on your
auth key
Dynamically
inserted API keys
into code samples.
https://stripe.com/docs/api
Foursquare API
Often begin with
Getting Started section,
providing a sample
“Hello World” tutorial
https://developer.foursquare.com/start
Youtube API
Lots of code samples,
usually with syntax
highlighting and
surrounding commentary.
https://developers.google.com/youtube/v3/code_samples/apps-script
8 design trends with API doc
1. Third column to show responses & code
2. Single page scroll with scrollspy TOC highlight
and floating sidebar
3. Seamless website matching product branding
4. Nav tabs to show different code samples
5. Code syntax highlighting
6. Hello World getting started section
7. Interactive, personalized API explorer
8. Static site generators that process Markdown
syntax
Some non-trends
1. PDF output
2. Short pages
3. Multiple (highly duplicate) outputs of content
for different audiences
4. DITA or XML authoring models
5. EPUB formats
6. Comments on pages
7. Wikis
8. Video tutorials
Slides + recording + code samples are
freely downloadable
Tom Johnson
http://idratherbewriting.com
@tomjohnson
Image credits
• slide 2: "API consumers want reliability, documentation and community."
Programmableweb.com. http://bit.ly/progwebsurvey
• slide 3: “10 Reasons Developers Hate Your API” (and what to do about it).
By John Musser. Slideshare. http://slidesha.re/1pnnDRf
• slide 4: Mars, once. By Kevin Dooley. http://bit.ly/ZFYI0T
• slide 15: Spinning gears. By Brent 2.0. Flickr. http://bit.ly/1DexWM0
• slide 21: Continental Drift. Wikipedia.
http://en.wikipedia.org/wiki/Continental_drift
• slide 24: Programmableweb Research Center.
http://www.programmableweb.com/api-research

Más contenido relacionado

La actualidad más candente

STC Summit 2015: API Documentation, an Example-Based Approach
STC Summit 2015: API Documentation, an Example-Based ApproachSTC Summit 2015: API Documentation, an Example-Based Approach
STC Summit 2015: API Documentation, an Example-Based Approach
Lois Patterson
 
Play framework: lessons learned
Play framework: lessons learnedPlay framework: lessons learned
Play framework: lessons learned
Peter Hilton
 
Rowdy Rabouw - Unleash your web skills on native
Rowdy Rabouw - Unleash your web skills on nativeRowdy Rabouw - Unleash your web skills on native
Rowdy Rabouw - Unleash your web skills on native
OdessaJS Conf
 

La actualidad más candente (18)

Publishing API documentation -- Presentation
Publishing API documentation -- PresentationPublishing API documentation -- Presentation
Publishing API documentation -- Presentation
 
STC Summit 2015: API Documentation, an Example-Based Approach
STC Summit 2015: API Documentation, an Example-Based ApproachSTC Summit 2015: API Documentation, an Example-Based Approach
STC Summit 2015: API Documentation, an Example-Based Approach
 
Publishing strategies for API documentation
Publishing strategies for API documentationPublishing strategies for API documentation
Publishing strategies for API documentation
 
API Documentation -- Presentation to East Bay STC Chapter
API Documentation -- Presentation to East Bay STC ChapterAPI Documentation -- Presentation to East Bay STC Chapter
API Documentation -- Presentation to East Bay STC Chapter
 
Microservices with Swagger, Flask and Docker
Microservices with Swagger, Flask and DockerMicroservices with Swagger, Flask and Docker
Microservices with Swagger, Flask and Docker
 
Play framework: lessons learned
Play framework: lessons learnedPlay framework: lessons learned
Play framework: lessons learned
 
Process-oriented reactive service architecture
Process-oriented reactive service architectureProcess-oriented reactive service architecture
Process-oriented reactive service architecture
 
Rowdy Rabouw - Unleash your web skills on native
Rowdy Rabouw - Unleash your web skills on nativeRowdy Rabouw - Unleash your web skills on native
Rowdy Rabouw - Unleash your web skills on native
 
HTTP demystified for web developers
HTTP demystified for web developersHTTP demystified for web developers
HTTP demystified for web developers
 
Web components - The Future is Here
Web components - The Future is HereWeb components - The Future is Here
Web components - The Future is Here
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students
 
.NET Recommended Resources
.NET Recommended Resources.NET Recommended Resources
.NET Recommended Resources
 
Developing an Ember Test Strategy - EmberConf 2019
Developing an Ember Test Strategy - EmberConf 2019Developing an Ember Test Strategy - EmberConf 2019
Developing an Ember Test Strategy - EmberConf 2019
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)
 
How to Create a Custom WordPress Plugin
How to Create a Custom WordPress PluginHow to Create a Custom WordPress Plugin
How to Create a Custom WordPress Plugin
 
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift ApplicationsHack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
 
Cordova: APIs and instruments
Cordova: APIs and instrumentsCordova: APIs and instruments
Cordova: APIs and instruments
 
DevNet 1056 WIT Spark API and Chat Bot Workshop
DevNet 1056 WIT Spark API and Chat Bot WorkshopDevNet 1056 WIT Spark API and Chat Bot Workshop
DevNet 1056 WIT Spark API and Chat Bot Workshop
 

Similar a Survival Strategies for API Documentation: Presentation to Southwestern Ontario STC chapter

Practices and tools for building better APIs
Practices and tools for building better APIsPractices and tools for building better APIs
Practices and tools for building better APIs
NLJUG
 

Similar a Survival Strategies for API Documentation: Presentation to Southwestern Ontario STC chapter (20)

API Documentation presentation to East Bay STC Chapter
API Documentation presentation to East Bay STC ChapterAPI Documentation presentation to East Bay STC Chapter
API Documentation presentation to East Bay STC Chapter
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
 
I Love APIs - Oct 2015
I Love APIs - Oct 2015I Love APIs - Oct 2015
I Love APIs - Oct 2015
 
flask.pptx
flask.pptxflask.pptx
flask.pptx
 
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
 
Getting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumGetting started with Appcelerator Titanium
Getting started with Appcelerator Titanium
 
API Design Workflows
API Design WorkflowsAPI Design Workflows
API Design Workflows
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic Framework
 
Developing Brilliant and Powerful APIs in Ruby & Python
Developing Brilliant and Powerful APIs in Ruby & PythonDeveloping Brilliant and Powerful APIs in Ruby & Python
Developing Brilliant and Powerful APIs in Ruby & Python
 
Apache Cordova 4.x
Apache Cordova 4.xApache Cordova 4.x
Apache Cordova 4.x
 
Getting started with titanium
Getting started with titaniumGetting started with titanium
Getting started with titanium
 
Practices and tools for building better APIs
Practices and tools for building better APIsPractices and tools for building better APIs
Practices and tools for building better APIs
 
Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
Developing Apps with Azure AD
Developing Apps with Azure ADDeveloping Apps with Azure AD
Developing Apps with Azure AD
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to Apigility
 
Javascript mynotes
Javascript mynotesJavascript mynotes
Javascript mynotes
 
2.28.17 Introducing DSpace 7 Webinar Slides
2.28.17 Introducing DSpace 7 Webinar Slides2.28.17 Introducing DSpace 7 Webinar Slides
2.28.17 Introducing DSpace 7 Webinar Slides
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

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
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
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
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Survival Strategies for API Documentation: Presentation to Southwestern Ontario STC chapter

  • 1. Survival Strategies for API Documentation By Tom Johnson www.idratherbewriting.com Feb 2, 2015 Southwestern Ontario STC Chapter Webinar
  • 2. "Complete and accurate documentation" is most important factor in APIs, according to a survey by @programmableweb. 250 respondents. Important factors in API doc
  • 3. Presentation by John Musser, founder of programmableweb.com, which has directory of 12,000+ APIs
  • 4.
  • 5. Says, “The client wants to find someone who'll emulate Dropbox's developer documentation”
  • 6. Docs are how users navigate an API product. With APIs, docs are the interface
  • 8. About me • Started doing API/SDK documentation a couple of years ago. • Am still learning a ton, but enjoy this type of documentation a lot. • English major / writing background. Not a programmer, but I do like code. • Blog and podcast at idratherbewriting.com Disclaimer: There’s a lot of things I simply do not know.
  • 9. Some basics about the API landscape System B System A An API is an interface between two systems. Lots of different types of APIs – for example: 1. Platform APIs that you download and add to your project before compiling. 2. REST APIs that you access through HTTP web requests.
  • 10. SDK versus API • API (application programming interface): An interface that provides endpoints, classes, or other functions. • SDK (software development kit): A set of implementation tools to make it easier to work with an API. SDK example: A JavaScript SDK that allows you to work with a particular REST API using JavaScript syntax as your implementation format.
  • 11. Reference and User Guides API docs usually have at least two deliverables.
  • 12. Auto-doc with Platform APIs /** * Reverses the order of the elements in the specified list.<p> * * This method runs in linear time. * * * @param list the list whose elements are to be reversed. * @throws UnsupportedOperationException if the specified list or * its list-iterator does not support the <tt>set</tt> operation. */ public static void reverse(List<?> list) { int size = list.size() if (size < REVERSE_THRESHOLD || list instanceof RandomAccess) { for (int i=0, mid=size>>1, j=size-1; i<mid; i++, j--) swap(list, i, j); } else { … Add documentation in the source code, structuring it with specific syntax that a documentation generator can read.
  • 13. Comments get rendered into Javadoc - Commonly used. - Works only for Java. - Run it from your IDE. - Automate into builds. - Explore other doclets. - Has frame-based - output. - Can skin with CSS. - Looks professional.
  • 14. Doxygen - Commonly used. - Works with Java, C++, C#, and others. - Has easy front-end GUI. - Point it at your source files. - Automate into builds. - Can include non-source files (Markdown). - Frame-based output. - Skinnable.
  • 15. Good example of source-gen. doc https://www.dropbox.com/developers/core Each language uses a doc generator for that language. https://www.dropbox.com/developers/core
  • 16. Pros of in-source documentation - Avoids documentation drift - Allows the person who creates the code (and so best understands it) to also document it - Includes tooltips when others incorporate the library into their projects - Integrates into developer’s IDE Doc SrcDoc Src Continental drift
  • 17. Pros/cons with Platform APIs Pros Performance: Performance is faster. (REST APIs struggle with latency for web calls.) Security: More secure. Cons Language coverage: Harder for devs to create APIs for each language (C++, Java, etc.). As prog. languages proliferate, it’s harder to keep up. Upgrades: Once clients install, it’s hard to encourage upgrades to latest versions.
  • 18.
  • 19. REST API basics URLs requests return specific data HTTP Request Response
  • 20. Responses in JSON or XML Configuration parameters ResponseinJSONformat
  • 21. Add parameters to endpoints https://api.flickr.com/services/rest/?method=flic kr.activity.userPhotos&api_key=1712c56e30dbad 5ef736245cda0d1cb9&per_page=10&format=js on&nojsoncallback=1 Knowing what parameters you can include with an endpoint is a huge part of the REST API documentation.
  • 22. cURL calls HTTP requests are often demonstrated through cURL calls, with different HTTP methods: GET – retrieve POST – edit PUT – create DELETE – remove You can use a command line to pass cURL calls, and you can specify different HTTP methods. Many sample REST calls are demonstrated in cURL.
  • 23. Flickr Example: Get gallery photos
  • 24. Get flickr photo gallery Endpoint: flickr.galleries.getPhotos Endpoint with values: https://api.flickr.com/services/rest/?method=fl ickr.galleries.getPhotos&api_key=c962d7440cbbf3 81785c09999ba8032e&gallery_id=66911286- 72157647277042064&format=json&nojsoncallback=1 Response: { "score": 92.2655186160279, "scoreDelta": { "dayChange": 0.00044535591406713593, … }
  • 26. $("#flickr").append('<img src="https://farm' + farmId + '.staticflickr.com/' + serverId + '/' + id + '_' + secret + '.jpg"/>'); API reference docs don’t tell you how to actually do a real task. To construct the img URL, you need to combine 4 different parts from the response.
  • 28. More details on the API calls Go here for details: http://bit.ly/restapiexamples
  • 29. Convert your help into an API The Jekyll Pages API plugin converts your Jekyll pages into a JSON file. http://idratherbewriting.com/wp-content/apidemos/docasapi/api/v1/pages.json
  • 30. Call the API <script> var url = "http://idratherbewriting.com/wp- content/apidemos/docasapi/api/v1/pages.json"; $.getJSON(url, function(data) { console.log(data); $.each(data.entries, function(i, page) { if (page.url == "/wp-content/apidemos/docasapi/mynameistom/") { $("#tomsmyname").append(page.body); } }); }); </script> <div id="tomsmyname"></div>
  • 33. With REST APIs, auto-doc not as common b/c source lang. varies “The beauty of Web APIs is that they can be written in whatever language you like and in whatever manner you like. As long as when an HTTP request comes in, the proper HTTP response goes out, it doesn't matter how it actually happens on the server. But this very flexibility makes automated documentation nearly impossible, since there's no standard mapping between what an API request is and what the code is that generates its response.” -- Kin Lane, APIevangelist.com
  • 35. RAML (REST API modeling language)
  • 36. Swagger UI can parse the Swagger syntax and render an output Generates an endpoint based on values you enter
  • 37. Mashery with Klout Doc becomes interactive when you’re signed in. http://developer.klout.com/io-docs
  • 38. Mashery.io This is an API for USA Today. The Swagger and RAML parsers essentially create an API explorer experience with some doc mixed in. http://developer.usatoday.com/io-docs
  • 39. Swagger spec can be in source code or in separate YML file • Swagger spec syntax can be separate yml file or integrated in code using a specific Swagger library • Swagger has various libraries for different languages. • Swagger spec is different from Swagger UI • RAML is a competing spec to Swagger
  • 40. Information survey on my blog • 42 respondents working in API documentation • Many people polled from API Documentation group on Linkedin + blogosphere
  • 41. Types of APIs that writers document 0% 10% 20% 30% 40% 50% 60% 70% 80% 90%
  • 42. Are you automating REST API docs? No Yes N/A 0% 10% 20% 30% 40% 50% 60% 70% Percent
  • 43. How are you automating REST API docs? • - custom scripts • - custom tooling • - homegrown framework • - homegrown Python scripts • - custom tooling • - Swagger • - Swagger • - Swagger • - Corilla.co • - code responses auto-generated • - some code samples auto-generated
  • 44. Authoring tools used by API doc writers 0 10 20 30 40 50 60 70 80
  • 45. Do you test out the API calls used in your doc yourself? Yes No Sometimes 0% 10% 20% 30% 40% 50% 60%
  • 46. What IDE do you use? Eclipse None Visual Studio IntelliJ IDEA Xcode Other 0% 5% 10% 15% 20% 25% 30% 35% 40% 45% 50%
  • 47. Most common programming languages tech writers know 0 5 10 15 20 25
  • 48. Do developers write the initial API documentation in the source code? Yes No Sometimes 28% 29% 30% 31% 32% 33% 34% 35% 36% 37%
  • 49. Do you write doc by looking in the source code? Yes No 0% 10% 20% 30% 40% 50% 60% 70%
  • 50. How do you access the source code? Git Perforce No access to code SVN Other Mercurial 0% 5% 10% 15% 20% 25% 30% 35% 40%
  • 51. Most difficult part of API doc? Understand code Get info from engineers Create non-ref docs Understand audience Identify dependencies 0% 5% 10% 15% 20% 25% 30% 35% 40% 45% 50% Percent
  • 52. How did you learn what you needed to know? 0% 5% 10% 15% 20% 25% 30% 35% 40% 45% 50%
  • 53. Takeaways from survey • Java, Eclipse, Git are popular • Become familiar with getting info from both source code and developers • Become a self-learner but also interact heavily with engineers • REST APIs are by far most common • Automating REST API doc isn’t all that common
  • 55. What design trends or patterns do we see among popular API doc sites?
  • 56. Stripe API Code responses next to doc. https://stripe.com/docs/api
  • 57. Single page scroll w/ TOC highlight Third column to show responses or code samples. http://crimson-cormorant.cloudvent.net/
  • 58. Jekyll API doc theme from CloudCannon
  • 60. Yelp API One seamless website matching product branding. http://www.yelp.com/developers/documentation
  • 61. Twilio API One output, with nav tabs to show different languages
  • 62. Twitter API Interactive, real- time requests based on your auth key
  • 63. Dynamically inserted API keys into code samples. https://stripe.com/docs/api
  • 64. Foursquare API Often begin with Getting Started section, providing a sample “Hello World” tutorial https://developer.foursquare.com/start
  • 65. Youtube API Lots of code samples, usually with syntax highlighting and surrounding commentary. https://developers.google.com/youtube/v3/code_samples/apps-script
  • 66. 8 design trends with API doc 1. Third column to show responses & code 2. Single page scroll with scrollspy TOC highlight and floating sidebar 3. Seamless website matching product branding 4. Nav tabs to show different code samples 5. Code syntax highlighting 6. Hello World getting started section 7. Interactive, personalized API explorer 8. Static site generators that process Markdown syntax
  • 67. Some non-trends 1. PDF output 2. Short pages 3. Multiple (highly duplicate) outputs of content for different audiences 4. DITA or XML authoring models 5. EPUB formats 6. Comments on pages 7. Wikis 8. Video tutorials
  • 68. Slides + recording + code samples are freely downloadable
  • 70. Image credits • slide 2: "API consumers want reliability, documentation and community." Programmableweb.com. http://bit.ly/progwebsurvey • slide 3: “10 Reasons Developers Hate Your API” (and what to do about it). By John Musser. Slideshare. http://slidesha.re/1pnnDRf • slide 4: Mars, once. By Kevin Dooley. http://bit.ly/ZFYI0T • slide 15: Spinning gears. By Brent 2.0. Flickr. http://bit.ly/1DexWM0 • slide 21: Continental Drift. Wikipedia. http://en.wikipedia.org/wiki/Continental_drift • slide 24: Programmableweb Research Center. http://www.programmableweb.com/api-research

Notas del editor

  1. http://www.programmableweb.com/news/api-consumers-want-reliability-documentation-and-community/2013/01/07
  2. ttp://www.slideshare.net/jmusser/ten-reasons-developershateyourapi Point out Bob Watson’s point – your API has to have the right functionality to begin with or it’s irrelevant to the programmer.
  3. Mars, once. By Kevin Dooley. http://bit.ly/ZFYI0T
  4. http://www.indeed.com/viewjob?jk=ebb2a2403d062299&from=tellafriend&utm_source=jobseeker_emails&utm_medium=email&cd%20-=tell_a_friend
  5. In this sense, you become the UI designer for your product!
  6. This is an area we need a lot more information about in tech comm, but it’s also an area that tech comm can apply its expertise to.
  7. Not a veteran tech writer for developer doc, but it's interesting to me. It's almost another field that is parallel to tech comm. Hard for tech writers to really excel in this field without some dev background, so there's not a lot of info on this topic. Recently asked to do an issue on tech comm trends; I said an issue on API doc would be better, b/c API doc is itself a trend.
  8. Spinning gears. By Brent 2.0. Flickr. http://bit.ly/1DexWM0
  9. Source code: http://www.docjar.net/html/api/java/util/Collections.java.html
  10. https://www.dropbox.com/developers/core
  11. From Programmableweb Research Center: http://www.programmableweb.com/api-research
  12. JSON is more popular because it’s lighter and faster.
  13. Demonstrate the variety of parameters you can add to the URL like this.
  14. https://api.flickr.com/services/rest/?method=flickr.galleries.getPhotos&api_key=c962d7440cbbfd61785c0952cba8032e&gallery_id=66911286-72157647277042064&format=json&nojsoncallback=1
  15. http://idratherbewriting.com/2015/02/01/creating-context-sensitive-help-by-converting-your-help-into-a-json-api/
  16. Also enunciate http://enunciate.codehaus.org/ and https://github.com/mashery/iodocs
  17. http://developer.klout.com/io-docs
  18. http://developer.usatoday.com/io-docs
  19. For details, see http://idratherbewriting.com/2014/12/17/the-most-popular-type-of-apis-that-technical-writers-document/.
  20. For more details, see http://idratherbewriting.com/2014/12/24/authoring-tools-preferred-by-api-doc-writers-in-my-survey/.
  21. For more details, see http://idratherbewriting.com/2015/01/02/api-doc-survey-do-you-test-out-the-api-calls-used-in-your-doc-yourself/.
  22. For more details, see http://idratherbewriting.com/2015/01/02/api-doc-survey-what-ide-do-you-use/.
  23. For more details, see http://idratherbewriting.com/2014/12/21/most-common-programming-languages-tech-writers-in-my-survey-know/.
  24. For more details, see http://idratherbewriting.com/2015/01/15/api-doc-survey-do-engineers-write-api-doc-in-the-source-code/.
  25. For more details, see http://idratherbewriting.com/2015/01/02/api-doc-survey-do-you-create-doc-by-looking-at-source-code/.
  26. For details, see http://idratherbewriting.com/2015/01/12/api-doc-survey-most-challenging-aspect-of-api-documentation/.
  27. For more details, see http://idratherbewriting.com/2015/01/06/api-doc-survey-result-how-to-learn-what-you-need-to-know/.
  28. Also http://ricostacruz.com/jquery.transit/source/ for docco sidebar style Slate patterned after it, and docco
  29. http://www.twilio.com/docs/api/rest/conference
  30. https://dev.twitter.com/rest/reference/get/statuses/user_timeline
  31. https://developer.foursquare.com/start
  32. https://developers.google.com/youtube/v3/code_samples/apps-script
  33. Splunk’s documentation is an exception to the non-wiki trend.