10.1 C
New York
Wednesday, November 22, 2023

You have heard of ‘Docs as code’ — Now prepare for ‘Code as docs’: Q&A with Speakeasy

by Tom Johnson on Nov 9, 2023



Speakeasy is a platform aimed toward simplifying the creation and consumption of APIs. Its main product is the creation of SDKs (consumer libraries), however its new providing (and most related to technical writers) is the ‘Code as Docs’ product. Their Code as Docs product embeds SDKs into the normal API reference, offering customers with code snippets in 8+ languages and bridging the hole between documentation and real-world functions. This submit is a Q&A with Sagar Batchu, CEO and co-founder of Speakeasy.

Notice: This can be a sponsored submit.

Background about SDKs

Earlier than we leap into the Q&A, let me first present a primary intro to software program improvement kits (SDKs). If you write API documentation, the record of deliverables typically consists of documentation for an SDK as effectively. Whereas internet APIs are language agnostic, the SDK is a language-specific implementation of the API, akin to a Java, Node, or Python library, that gives language-specific courses/capabilities for implementing and calling the API.

Historically, SDKs have both been maintained by hand or auto-generated from an OpenAPI specification utilizing open-source software program (OSS), akin to OpenAPI Generator, Swagger Codegen, or Bazel. Each of those choices (hand-maintained, OSS-generated), have had main downsides which have stymied the expansion of SDKs.

On the one hand, builders typically lack experience in all of the languages offered by the varied SDKs. For instance, a group may not have experience with Go however nonetheless must generate and keep a Go SDK to assist customers programming in Go. That makes sustaining them by hand unrealistic.

On the opposite facet, the standard of the OSS-generated SDKs is usually problematic and liable to bugs or different points. There are sometimes gaps that should be crammed for them to be usable by enterprises. This may be arduous for engineers to handle because of the language selection and experience wanted.

With Speakeasy, you may create enterprise-grade SDKs from an OpenAPI spec. They’re marrying the standard of hand maintained SDKs with the benefit of use of the OSS mills. Most related to technical writers, Speakeasy can also be launching a brand new device known as “Code as Docs” (at the moment in alpha stage) Their Code-as-Docs platform generates code samples from the SDK that technical writers can simply pull into their documentation, offering the type of hands-on, copy-and-paste code customers must stand up and operating shortly with an SDK.

The next is a Q&A with Sagar Batchu, co-founder and CEO of Speakeasy.

[Tom]: Sagar, inform us concerning the second you first conceived the concept for Speakeasy. What sparked the concept? What led to the inception of Speakeasy as an organization?

[Sagar]: Whereas I used to be at LiveRamp we invested in constructing out an inner DSL (domain-specific language) and API platform to offer a constant developer expertise and end-to-end sort security in your APIs. This was a typical sample we had noticed within the trade, be it AWS Smithy, Palantir’s Conjure, or Microsoft’s Typespec.

That mission was targeted on making it straightforward for devs within the firm to ship enterprise APIs. It included tooling for end-to-end sort security and in flip helped generate API artifacts: an OpenAPI spec, consumer SDKs, server stubs, and even gave you the config you wanted to deploy our authentication proxy and numerous different infrastructure and so forth.

I got here away with an amazing feeling that constructing nice REST APIs shouldn’t be so arduous and there must be one thing extra for the ecosystem than duct taping OpenAPI specs collectively to make an API work. That lit the fireplace in me to need to take this and go a lot additional and make an API platform expertise accessible to the 99% of builders.

That’s why we began Speakeasy, to make it straightforward to create and eat any API.

[Tom]: Making nice APIs is a broad matter. What introduced you to deal with SDKs particularly?

[Sagar]: We needed to have most affect for our clients. Nice SDKs (consumer libraries) could be transformational for API organizations and an effective way to enhance the developer expertise of each new and present APIs. Providing SDKs has a number of advantages:

  • Quicker and constant integrations – SDKs allow your customers to entry your API utilizing a language they’re conversant in and spare them from needing to jot down tedious boilerplate code to deal with auth, networking, serialization, and so forth.
  • Larger conversion charges & utilization – the sooner customers get to their first 200 (profitable API response), the extra seemingly they’re to transform into paying clients and the higher utilization you’ll get in the long run. “Time to 200” is a helpful KPI for API groups to measure
  • Developer loyalty – Sadly, the typical API’s developer expertise is poor. Providing instruments (like SDKs) reveals your customers that you simply perceive what’s vital to them. You’ll earn their loyalty and remodel customers into advocates.

[Tom]: Why would an organization use Speakeasy to create SDKs? Why not construct SDKs in-house or use an open supply generator?

[Sagar]: We see a number of corporations that strive constructing SDKs by hand. In the long term, they practically all change to utilizing a generator. This boils down to some causes:

  • Expertise hole — Most orgs don’t have the vary of language experience to construct SDKs in each language they want. Oftentimes, we encounter corporations the place one group member had a selected language experience, then left the corporate, and now the remainder of the group is scrambling to assist a C# SDK.

  • Ongoing upkeep price – Inevitably, your API modifications. When it does, updating all of your SDKs by hand is painful and thankless. It bleeds your group of engineering time and is a continuing drag on velocity.

So why do corporations ever attempt to construct SDKs by hand? It’s as a result of many builders have had dangerous experiences utilizing open-source SDK mills.

OSS instruments are actually nice when you’re a hobbyist engaged on a private mission, however relating to an enterprise API expertise, their high quality is inadequate. As well as, you continue to must construct out a CI/CD upkeep course of to handle ongoing updates.

And that’s why folks select to make use of Speakeasy:

  • Enterprise-ready – We’ve invested so much of time into guaranteeing our SDKs have enterprise-grade high quality DevEx.
  • Sturdy and customisable – We’ve gone the space on supporting OpenAPI idiosyncrasies like polymorphism, nulls, optionals and given you the instruments to customise the output to suit your firm’s opinionation.
  • Absolutely automated – We additionally handle the whole upkeep workflow in order that updates to SDKs are as straightforward as reviewing & approving a PR. Our clients spend a mean of 30 minutes a month on SDK upkeep.

[Tom]: When engineers begin producing SDKs for his or her APIs, what roadblocks or challenges are likely to floor probably the most?

[Sagar]: I’ll cut up this into two solutions: OpenAPI spec errors and learn how to keep away from them and API design errors and learn how to keep away from them.

OpenAPI specs – The massive downside right here is that OpenAPI is a really forgiving normal. It’s not arduous to make a legitimate OpenAPI spec, however it’s arduous to make a correct OpenAPI spec. A few widespread issues we see:

  • Code-first specs: A whole lot of the API frameworks can generate an OpenAPI spec, however they’re not nice. Fortuitously, there are some straightforward tweaks you can also make to the default technology to enhance this vastly. See our framework guides.
  • Design-first specs: The largest downside for design-first corporations is inconsistency within the spec. To assist design-first spec builders, we’ve constructed an OpenAPI LLM agent to behave as your co-pilot.

API design is a extra complicated matter. There’s much more variation relying on what the aim of the API is, who the customers are, and so forth. That stated, I feel there are some vital issues to remember:

  • Don’t ship your org chart – you need your API to be constant. We typically see circumstances the place completely different groups have completely different design philosophies, and the API habits varies wildly from endpoint to endpoint. That results in a reasonably horrible consumer expertise since you don’t know what to anticipate.
  • Does what it says on the tin – Individuals shouldn’t want to look at your API reference minutely to know what endpoints do. Path names ought to assist folks simply perceive the assets they’re manipulating.
  • Don’t be too versatile – This can be a bit extra opinionated, however I desire APIs which can be strongly typed. We’ve seen APIs the place folks make it forgiving to keep away from customers getting a 4xx response code. I perceive the sentiment, however normally, you simply find yourself with sudden habits and customers scratching their heads. Make your API strongly-typed and return good, clear error codes when somebody makes a mistake.

[Tom]: SDKs could be intimidating for tech writers because of the want for language-specific experience. How does Speakeasy assist technical writers create SDK docs?

[Sagar]: Because it occurs, we simply launched the alpha of our new “Code as Docs” product to create an built-in expertise between docs and SDKs.

The foremost distinction between our docs product and others is that we place an emphasis on offering the consumer with code snippets that can be utilized for precise manufacturing use circumstances. A whole lot of the docs with code snippets you see at this time are simply primary fetch instructions or the equal. It’s helpful if you wish to check one thing, however not helpful for really constructing a usable integration.

“Code as Docs” provides your customers compilable, production-ready code for each API endpoint. Finally, the purpose of documentation is to assist builders construct, and nothing is more practical than ⌘c, ⌘p.

[Tom] How can tech writers combine Speakeasy’s SDK documentation with the opposite API documentation?

[Sagar]: Our documentation is solely MDX-based markdown. So long as your web site helps MDX & Markdown, you have to be good to go. We offer web site internet hosting at a customized area for purchasers who need it.

In any other case, the docs are piped right into a standalone GitHub repo in our clients’ org. From there, they will take the docs and incorporate them as they see match. Right here’s a sneak peak at how they appear and feel. They’re fully sort native, which implies once you seek for an API useful resource and its supported operation you get working SDK code instantly. Not only a curl or requests library snippet. Devs love one-click copy/paste experiences. That is precisely that.

Code as Docs, Speakeasy

[Tom]: Trying on the screenshot, it looks like Code as Docs gives a full documentation expertise of the API, much like a Swagger output. Is that proper? Does Speakeasy generate internet recordsdata (HTML, CSS, and JS) that you’d add someplace?

[Sagar]: It mirrors the three pane view individuals are conversant in, however we might argue that there’s a basic distinction when it comes to the content material. Our documentation product is “code-based”, not the normal “json-based” documentation. All the things proven is sort native to the languages supported by our clients.

The code-samples that you simply see aren’t easy calls utilizing an http consumer. They’re fully-compilable usage-snippets which can be native to the corporate’s SDK. The sort data within the center pane matches the precise information sorts utilized in that language.

As a lot as attainable, we’re attempting to copy the sensation of in-IDE sort hints inside our clients’ docsite.

[Tom]: What if technical writers simply need to get the code samples and combine them into a distinct documentation platform? Is that attainable? Are you able to converse extra about learn how to combine the output into an present developer portal?

[Sagar]: In the event that they’re utilizing Speakeasy to construct their SDKs, that will surely be attainable. The way in which it at the moment works, we ship the entire output to a GitHub repo specified by our buyer. The documentation that we generate is MDX-based. In case your docsite helps MDX, then it is possible for you to to include the output from our platform nonetheless you want.

Should you solely needed code snippets, our CLI does have the power to create snippets for specified strategies, in order that can also be an possibility.

[Tom]: Past what’s auto-generated with the Speakeasy documentation, what else would engineers and tech writers want so as to add or do?

[Sagar]: Our documentation covers each side of the SDK: courses, strategies, fields. We even produce docs that specify how authentication, retries, and pagination are carried out. The intention is for it to be absolutely able to exit of the field.

That stated, we all know we will’t do every little thing. Tech writers can go into the generated docs and add customized narratives. Our platform will solely overwrite generated docs; any customized sections might be preserved throughout subsequent regenerations.

[Tom]: Are you able to clarify extra about how tech writers would add customized narratives to the generated doc? If these narratives aren’t within the OpenAPI spec, and the Speakeasy output is a totally packaged web site, how would one get the customized narratives within the output?

[Sagar]: It’s a absolutely packaged web site, however it’s additionally pretty straightforward to edit. The location will reside totally inside a GitHub repo inside our clients org. The repo construction is easy: every part of the docs is a file within the repository.

If a author needs so as to add extra narrative, they merely create a brand new file, add their content material, and specify the place they need it to look in data hierarchies. And that’s actually it, the location will redeploy, and the brand new content material might be included.

[Tom]: As APIs endure modifications and upgrades, sustaining up-to-date documentation could be difficult. How does Speakeasy be sure that documentation stays updated with evolving APIs?

[Sagar]: All it is advisable do is be sure that your manufacturing OpenAPI spec is hosted at a static URL and that any API modifications are pushed to the spec. The way in which it really works is:

  1. Our platform is consistently checking to see if there are any updates. When a change is noticed, that kicks off the regeneration course of.
  2. The SDKs might be recreated, as will the documentation.
  3. All of your group must do is assessment & approve the PR.
  4. We care for publishing the brand new packages.

[Tom]: Are you able to clarify the AI-powered options of Speakeasy?

[Sagar]: I can provide an summary. If folks need an inside look, I extremely suggest this weblog submit written by considered one of our founding engineers.

Our agent is named “Speakeasy Recommend.” Given an OpenAPI doc, it routinely suggests fixes, applies them, and outputs a modified spec. Utilizing AI, we’re in a position to offload the burden of spec administration from API producers. Recommend could be invoked by way of each the Speakeasy CLI (outputs modified spec to the native filesystem) and our GitHub Motion (creates PR) at this time. The AI agent is guided by Speakeasy validation, which might level out errors and spots for enchancment in folks’s specs.

[Tom]: May you share some insights into Speakeasy’s development and acceptance available in the market to date?

[Sagar]: It’s been superior to date. It took a couple of months to persuade those who automated SDK creation could possibly be as top quality as hand-built SDKs, however we’ve now bought sufficient proof factors that folks perceive what we’ve made attainable.

One other milestone that’s loopy is that we’re as much as 10 supported technology targets (languages). It’s not even been 12 months since we began constructing SDKs, which implies we’ve mainly added one goal each month. It’s a testomony to the pliability and extensibility of the code technology platform the group has constructed.

And whereas I’m excited by all of the latest milestones, what I’m much more enthusiastic about is all the brand new options we’ve bought rolling out.

[Tom]: What’s the longer term imaginative and prescient for Speakeasy? You talked about new options, what’s on the horizon?

[Sagar]: I’ve already talked about “Code as docs”, however the group has additionally been arduous at work ensuring the SDKs we create are the perfect they will probably be. We’ve bought a number of work coming earlier than the tip of the 12 months to be sure that all 8 of the languages we assist are top of the range.

Then, in 2024, we’re going to be focusing our consideration on some new areas. I’m actually concerned about how we will make it straightforward for machines to interface with APIs in addition to people, in order that’s positively one thing we’re taking a look at. Keep tuned!

You may be taught extra at speakeasyapi.dev.

About Tom Johnson

Tom Johnson

I am an API technical author based mostly within the Seattle space. On this weblog, I write about subjects associated to technical writing and communication — akin to software program documentation, API documentation, AI, data structure, content material technique, writing processes, plain language, tech comm careers, and extra. Take a look at my API documentation course when you’re searching for extra data about documenting APIs. Or see my posts on AI and AI course part for extra on the most recent in AI and tech comm.

Should you’re a technical author and need to carry on prime of the most recent tendencies within the tech comm, remember to subscribe to e-mail updates beneath. It’s also possible to be taught extra about me or contact me. Lastly, observe that the opinions I specific on my weblog are my very own factors of view, not that of my employer.

Supply hyperlink

Related Articles


Please enter your comment!
Please enter your name here

Latest Articles