Step 1: Resource description (API reference tutorial)
I'm giving an API documentation workshop in Los Angeles, California, on January 23, 2020. Check it out on EventBrite and register today to receive a $100 early bird discount.
“Resources” refers to the information returned by an API. Most APIs have various categories of information, or various resources, that can be returned.
The resource description is brief (1-3 sentences) and usually starts with a verb. Resources usually have various endpoints to access the resource and multiple methods for each endpoint. On the same page, you usually have a general resource described along with a number of endpoints for accessing the resource, also described.
- Examples of resource descriptions
- Terminology for describing the resource
- Recognize the difference between reference docs versus user guides
- Resource description for the surfreport endpoint
- Next steps
Examples of resource descriptions
Here’s an example of a resource description from the Mailchimp API’s Campaigns resource:
Typically, an API will have a number of endpoints grouped under the same resource. In this case, you describe both the general resource and the individual endpoints. For example, the Campaigns resource has various endpoints that are also described:
Here’s a resource description for the Membership resource in the Box API:
For the Membership resource (or “object,” as they call it), there are 7 different endpoints or methods you can call. The Box API describes the Membership resource and each of the endpoints that lets you access the resource.
Sometimes the general resource isn’t described; instead, it just groups the endpoints. The bulk of the description appears in each endpoint. For example, in the Eventbrite API, here’s the Events resource:
Although the Events resource isn’t described here, descriptions are added for each of the Events endpoints. The Events resource contains all of these endpoints:
And so on.
When developers create APIs, they have a design question to consider: Use many variants of endpoints (as with Eventbrite’s API), or provide lots of parameters to configure the same endpoint. Often there’s a balance between the two. The trend seems to be toward providing separate endpoints rather than supplying a host of potentially confusing parameters within the same endpoint. On the other hand, GraphQL APIs (which I don’t cover in this course) provide one endpoint with different ways to query the information the endpoint contains. See GraphQL And REST Differences Explained With Burgers for a good explanation about GraphQL versus REST.
As another example, here’s the Relationships resource in the Instagram API.
The Relationships resource isn’t described but rather acts as a container for relationship endpoints. Descriptions are added for each of the resources grouped within the Relationships resource:
For another example of an API with resources and endpoints, check out the Trello API.
The description of the resource is likely something you’ll re-use in different places — product overviews, tutorials, code samples, quick references, etc. As a result, put a lot of effort into crafting it. Consider storing the description in a re-usable snippet in your authoring tool so that you can list it without resorting to copy/paste methods in your quick start guide.
Terminology for describing the resource
The exact terminology for referring to resources varies. The “things” that you access using a URL can be referred to in a variety of ways, but “resource” is the most common term because you access them through a URL, or uniform resource locator. Other than “resources,” you might see terms such as API calls, endpoints, API methods, calls, objects, services, and requests. Some docs get around the situation by not calling them anything explicitly except “Reference.”
Despite the variety with terminology, generally an API has various “resources” that you access through “endpoints.” The endpoints give you access to the resource. (But terminology isn’t standard, so expect variety.)
For more on how API terminology varies, see The difference between resources, endpoints, objects, and items in the bunq API documentation.
Recognize the difference between reference docs versus user guides
Resource descriptions (as well as endpoint descriptions) are typically short, usually 1-3 sentences. What if you have a lot more detail to add? In these situations, keep in mind the difference between reference documentation and user guides/tutorials:
- Reference documentation: Concise, bare-bones information that developers can quickly reference.
- User guides/tutorials: More elaborate detail about how to use the API, including step-by-step instructions, code samples, concepts, and procedures. I go into much more detail about this content in Documenting concepts sections.
Although the description in an API reference topic provides a 1-3 sentence summary of the information that the resource contains, you might expand on this with much greater detail in the user guide. (You could link the reference description to the places in the guide where you provide more detail.)
Resource description for the surfreport endpoint
Let’s review the surf report wiki page (which contains the information about the resource) and try to describe the resource in 1-3 sentences. Here’s my approach:
Contains information about surfing conditions, including the surf height, water temperature, wind, and tide. Also provides an overall recommendation about whether to go surfing.
Now it’s time to list out the endpoints and methods for the resource.
53/150 pages complete. Only 97 more pages to go.
Want to buy me lunch? Click the Donate button below to donate any amount through Paypal.