2. "Complete and accurate documentation" is most important factor in APIs, according to
a survey by @programmableweb. 250 respondents. http://bit.ly/progwebsurvey
Important factors in API doc
3. Presentation by John Musser, founder of programmableweb.com,
which has directory of 12,000+ APIs. http://bit.ly/jmusserslideshare
8. About me
• Started doing API/SDK
documentation 2+ 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
9. Some basics about the API landscape
System B
System A
An API is an interface.
Lots of different types
of APIs – for example:
• Platform APIs
• REST APIs
Flickr:
http://bit.ly/1DexWM0
10. SDK versus API
• API (application programming interface):
Endpoints, classes, or other functions.
• SDK (software development kit):
Implementation tooling to support the API.
11. At least two deliverables
API Reference User Guides
12. Outline
1. Platform APIs
2. REST APIs
3. API documentation survey
4. API doc publishing trends
5. Questions to consider
14. 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.
17. Good example of source-gen. doc
https://www.dropbox.com/developers/core
Each language
uses a different
doc generator.
https://www.dropbox.com/developers/core
18. Who writes the Javadoc?
• Usually engineers write initial draft.
• Tech writers edit.
• Tech writers might work in a doc branch.
Doc
branch
Main
branch
mergeCode
repo
19. Pros of in-source documentation
- Avoids doc drift
- Allows engineers to
document
- Includes tooltips in
IDE
Doc
SrcDoc Src
Continental drift
Wikipedia: http://bit.ly/contdriftwiki
20. Problem: Gives illusion of real doc
“… auto-generated
documentation is worse than
useless: it lets maintainers fool
themselves into thinking they
have documentation, thus
putting off actually writing good
reference by hand. If you don’t
have documentation just admit
to it. Maybe a volunteer will
offer to write some! But don’t
lie and give me that auto-
documentation crap”. – Jacob
Kaplan Moss
Looks real but
isn’t.
Flickr. http://bit.ly/1F1et36.
30. Sample endpoints
api_site.com/{apikey}/users
// gets all users
api_site.com/{apikey}/users/{userId}
// gets a specific user
api_site.com/{apikey}/rewards
// gets all rewards
api_site.com/{apikey}/rewards/{rewardId}
// gets a specific reward
api_site.com/{apikey}/users/{userId}/rewards
// gets all rewards for a specific user
api_site.com/{apikey}/users/{userId}/rewards/{rewardId}
// gets a specific reward for a specific user
A “RESTful web service”
has “endpoints” that
return “resources.”
31. Responses (JSON or XML)
{
"user”:"1234",
"userName":"Tom",
"userCreatedDate":"09021975",
”userStatus: "active"
}
A JSON object consists
of key: value pairs.
36. EventBrite API example
Let’s get some event
details using the events
endpoint from the
EventBrite API.
https://developer.eventbrite.com/docs/event-details/
37. Get eventbrite event details
Endpoint:
eventbrite.api.com/v3/events/{event_id}
Endpoint with values:
https://www.eventbriteapi.com/v3/events/14635401881/
?token=C4QTJZP64YS5ITN4JSPM
Response:
{
"resource_uri":
"https://www.eventbriteapi.com/v3/events/14635401881/",
"name": {
"text": "API Workshop with Sarah Maddox",
},
"description": {
"text": "This is a practical course on API technical writing, consisting of…
39. Accessing JSON using dot notation
To get the values from
the JSON, use dot
notation. If our object is
named data, then
data.name.text gets
that value.
40. Activity: View payload values
1. In Chrome, open the JavaScript Console by
going to View > Developer > JavaScript
Console.
2. Now go to http://idratherbewriting.com/wp-
content/apidemos/eventbrite.html.
3. Expand the description and name sections in
the payload logged to the console.
41. Common sections in REST API doc
• Endpoint
• Description
• Parameters
• Methods
• Success response
• Error response
• Sample call
Cover these details for
each resource in your
REST API docs. Click
thumbnail for example.
44. Activity: Explore payload values
1. With the JavaScript Console open, go to
http://idratherbewriting.com/wp-
content/apidemos/flickr.html.
2. Inspect the payload logged to the console.
3. Try to find the image source URLs.
4. View the source code of the page to see how
the image URLs are constructed.
45. $("#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.
56. Do developers write the initial API
documentation in the source code?
Yes No Sometimes
28%
29%
30%
31%
32%
33%
34%
35%
36%
37%
57. Do you write doc by looking in the
source code?
Yes No
0%
10%
20%
30%
40%
50%
60%
70%
58. 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%
59. 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
60. How did you learn what you needed to
know?
0%
5%
10%
15%
20%
25%
30%
35%
40%
45%
50%
68. Foursquare API
Getting Started section,
providing a sample
“Hello World” tutorial
https://developer.foursquare.com/start
69. Youtube API
Lots of code samples,
usually with syntax
highlighting and
surrounding commentary.
https://developers.google.com/youtube/v3/code_samples/apps-script
70. Single page scroll w/ TOC highlight
Third column to show
responses or code samples.
http://crimson-cormorant.cloudvent.net/
72. Automating API docs
• Swagger: 600+ repos
• RAML: 180+ repos
• API Blueprint: 120+ repos
– slide notes from Jennifer Rondeau presentation on
REST API Doc
73. Use Swagger Editor to create YML file
for Swagger
http://editor.swagger.io/#/edit
Swagger is just a
standard way of
describing your API
using a particular
schema.
http://www.slideshare.net/jmusser/ten-reasons-developershateyourapi
http://bit.ly/jmusserslideshare
Point out Bob Watson’s point – your API has to have the right functionality to begin with or it’s irrelevant to the programmer.
In this sense, you become the UI designer for your product!
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.
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.
Spinning gears. By Brent 2.0. Flickr. http://bit.ly/1DexWM0
Often engineers write reference documentation, but the Javadoc is often incomplete, unclear, inconsistent, or otherwise problematic.
Some power API writers/developers might look at the source code and create documentation from scratch, but this is less common.
The false. By Cristopher Cotrell. Flickr. http://bit.ly/1F1et36. Quote from Jacob Kaplan Moss here: http://jacobian.org/writing/what-to-write/
Another source: “Auto-generated documentation that documents each API end-point directly from source code have their place (e.g., its great for team that built the API and its great for a reference document) but hand-crafted quality documentation that walks you through a use case for the API is invaluable. It should tell you about the key end-points that are needed for solving a particular problem and it should provide you with code samples.” https://communities.cisco.com/community/developer/blog/2014/09/03/introducing-devnet-slate
The Source of Bad Writing. Wall Street Journal. http://online.wsj.com/articles/the-cause-of-bad-writing-1411660188
http://bit.ly/wsjpinker
Flickr: http://bit.ly/serverroomflickr. Tom Raftery, Server room with grass
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.
From Programmableweb Research Center: http://www.programmableweb.com/api-research
Demonstrate the variety of parameters you can add to the URL like this.
Client-server architecture: You send a request and get a response back. REST is the model of the web. REST APIs also called “web APIs.”
REST = “representational state transfer” – data transfer modeled after the web.
Protocol transfer is HTTP. Requests are made through URLs.
Can see the response in the browser.
Responses are stateless -- not remembered.