Skip to content

Commit e1d0739

Browse files
authored
move over intro: api lifecycle (#109)
* move over intro: api lifecycle * removed some artifacts from markdown
1 parent d8c5521 commit e1d0739

4 files changed

Lines changed: 56 additions & 36 deletions

File tree

src/1-introduction-to-apis/3-different-paradigms.adoc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
[#theory-paradigms]
21
= Understanding Different Paradigms
32

43
If APIs are the interface for some sort of service, it should not come as a surprise that not all the interfaces in the world are going to have the same needs and requirements. Most of them are a case of "execute a command", "interact with data", or a combination of both.
54

6-
There are three distinct types of Web API which handles these common needs, and these different types are known as paradigms. To oversimplify things a bit, its reasonably fair to say that all APIs conform to one of these paradigms:
5+
There are three distinct types of Web API which handles these common needs, and these different types are known as paradigms. To oversimplify things a bit, it's reasonably fair to say that all APIs conform to one of these paradigms:
76

87
- RPC (Remote Procedure Call)
98
- REST (Representational State Transfer)
@@ -13,7 +12,7 @@ These paradigms are general approaches to building APIs, not a specific tool or
1312

1413
*Implementations* are something you can actually download, install, and use to build an API, that conforms to whatever rules the implementors picked, from whichever paradigm (or paradigms) they were interested in at the time.
1514

16-
*Specifications* (or standards, recommendations, etc.) are often drafted up by various working groups, to help implementations share functionality in the same way. An API and a client in different languages can work together perfectly if theyre all following the specification correctly. The difference between a standard and a specification is usually just down to who made it. When a working group like the IETF or W3C create something, it's a standard, but when Google knock something out on their own, it's a specification.
15+
*Specifications* (or standards, recommendations, etc.) are often drafted up by various working groups, to help implementations share functionality in the same way. An API and a client in different languages can work together perfectly if they're all following the specification correctly. The difference between a standard and a specification is usually just down to who made it. When a working group like the IETF or W3C create something, it's a standard, but when Google knock something out on their own, it's a specification.
1716

1817
For example:
1918

@@ -126,15 +125,15 @@ REST, however, presents you with the next available options:
126125

127126
*Client:* Hi, I would like to speak to Dr Watson, is he there?
128127

129-
*REST:* Doctor Watson is not currently in the office, hell be back tomorrow, but you have a few options. If its not urgent you could leave a message and Ill get it to him tomorrow, or I can book you with another doctor, would you like to hear who is available today?
128+
*REST:* Doctor Watson is not currently in the office, he'll be back tomorrow, but you have a few options. If it's not urgent you could leave a message and I'll get it to him tomorrow, or I can book you with another doctor, would you like to hear who is available today?
130129

131130
*Client:* Yes, please let me know who is there!
132131

133132
*REST:* Doctors Smith and Jones, here are links to their profiles.
134133

135-
*Client:* Ok, Doctor Jones looks like my sort of Doctor, I would like to see them, lets make that appointment.
134+
*Client:* Ok, Doctor Jones looks like my sort of Doctor, I would like to see them, let's make that appointment.
136135

137-
*REST:* Appointment created, heres a link to the appointment details.
136+
*REST:* Appointment created, here's a link to the appointment details.
138137

139138
REST provided all of the relevant information with the response, and the client was able to pick through the options to resolve the situation.
140139

@@ -146,7 +145,7 @@ This book will get more in-depth on hypermedia controls later. There are a few o
146145

147146
- REST must be stateless: not persisting sessions between requests
148147
- Responses should declare cacheablility: helps your API scale if clients respect the rules
149-
- REST focuses on uniformity: if youre using HTTP you should utilize HTTP features whenever possible, instead of inventing conventions
148+
- REST focuses on uniformity: if you're using HTTP you should utilize HTTP features whenever possible, instead of inventing conventions
150149

151150
These constraints of REST when applied to HTTP APIs can help the API last for decades, which is a whole lot more complex without these concepts. What does that mean? Well, REST is often described as a series of layers of abstraction on top of RPC, with all relevant instructions related to the handling of that message being baked into the message itself, to avoid having to tell a human about specific ways to handle things. As things change throughout the entire ecosystem, a well trained REST API and client should be able to handle those changes seamlessly, because the REST API is describing itself well and the client is listening. This loosens the coupling found in other paradigms, where a lot of that is baked into the client itself.
152151

@@ -236,7 +235,7 @@ All of this has the advertised benefit of making GraphQL portable enough that it
236235

237236
GraphQL has many fantastic features and benefits, which are all bundled in one package, with a nice marketing site. If you are trying to learn how to make calls to a GraphQL API, the http://graphql.org/learn/[Learn GraphQL] documentation will help, and their site has a bunch of other resources.
238237

239-
Seeing as GraphQL was built by Facebook, who had previously built a REST__ish__ API, theyre familiar with various REST/HTTP API concepts. Many of those existing concepts were used as inspiration for GraphQL functionality, or carbon copied straight into GraphQL.
238+
Seeing as GraphQL was built by Facebook, who had previously built a REST__ish__ API, they're familiar with various REST/HTTP API concepts. Many of those existing concepts were used as inspiration for GraphQL functionality, or carbon copied straight into GraphQL.
240239

241240
The main selling point of GraphQL is that it defaults to providing the very smallest response from an API, as you are requesting only the specific bits of data that you want, which minimizes the Content Download portion of the HTTP request.
242241

old-adoc/src/1-theory/3-api-lifecycle.adoc renamed to src/1-introduction-to-apis/4-api-lifecycle.adoc

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ and could include people from marketing, sales, customer support, and more. The
2525
worst APIs are built in a vacuum, where the developers were told to build
2626
something and then left to their own devices.
2727

28-
- "Marketing said we need to tack an API on." - "The CEO said we need to open up
29-
our data to third-party developers." - "A major partner wants to integrate our
30-
services into their platform."
28+
- "Marketing said we need to tack an API on."
29+
- "The CEO said we need to open up our data to third-party developers."
30+
- "A major partner wants to integrate our services into their platform."
3131

3232
If one one of these requests is being used as the entirety of the strategy input
3333
then the API will likely be very specific to that purpose. Maybe that's ok,
@@ -36,12 +36,13 @@ of potential stakeholders can help flesh out what the needs really are.
3636

3737
Start by asking:
3838

39-
- Who are your target users? Internal teams, third-party developers, or both? -
40-
What are the business goals this API will help achieve? - What existing systems
41-
or data will the API interact with? - Which customers will be using this, and
42-
what are their needs? - If there is only one customer right now, can I find some
43-
other potential customers to talk to? - What sort of traffic can be expected?
44-
Will this be a few dozen users or millions worldwide?
39+
- Who are your target users? Internal teams, third-party developers, or both?
40+
- What are the business goals this API will help achieve?
41+
- What existing systems or data will the API interact with?
42+
- Which customers will be using this, and
43+
what are their needs?
44+
- If there is only one customer right now, can I find some other potential customers to talk to?
45+
- What sort of traffic can be expected? Will this be a few dozen users or millions worldwide?
4546

4647
All of this can drastically shape the decisions made throughout the planning and
4748
development of the API, and could even suggest that you don't need a real-time
@@ -236,3 +237,28 @@ encourage adoption while generating revenue.
236237

237238
With these steps, your API can evolve from an idea to a well-managed,
238239
developer-loved product that generates real value.
240+
241+
== Summary
242+
243+
Building an API is not just writing a bunch of code and hoping for the best, it's
244+
an ongoing process that requires careful planning, design, testing, and management.
245+
This is a continuous cycle that adapts to changing requirements, technologies, and
246+
user needs over time.
247+
248+
Some phases of the lifecycle will involve teams and stakeholders from other
249+
parts of the business, all of whom have different needs and expectations, so
250+
things can get a bit political. That's all very different skills required to
251+
more technical phases which are handled by developers, testers, and operations,
252+
but all are equally important to the success of the API.
253+
254+
Of course people will try to skip a bunch of this and just get on with their one
255+
favourite step: Code. That's a bit like trying to build a house without a
256+
plan, or a recipe without ingredients. It might work, but it's not going to be
257+
pretty. You'll end up wasting a lot more time and money building useless things
258+
than you do building the right thing, but building the right thing requires a
259+
lot of work, and some decision makers "cut cost" by "reducing investment" like a
260+
UK Labour/Conservative government.
261+
262+
We'll go through most of this in more detail in the following chapters, but
263+
hopefully this gives you a good overview of what to expect when building an API,
264+
and sets expectations for the challenge ahead.

src/1-introduction-to-apis/part.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
include::1-history-of-apis.adoc[]
55
include::2-apis-services-microservices.adoc[]
66
include::3-different-paradigms.adoc[]
7+
include::4-api-lifecycle.adoc[]

src/4-api-design-first/2-the-perfect-workflow.adoc

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,6 @@ jobs:
419419
bundle exec rspec
420420
----
421421

422-
____
423-
For a more in depth example, see xref:_guides/openapi/design-first-rails.adoc[how to contract test in
424-
Rails], or see xref:_guides/openapi/design-first-laravel-php.adoc[how to do the same with
425-
Laravel PHP]. If you'd like to
426-
see a similar guide for your favorite language/framework please link:mailto:hello@bump.sh[get in
427-
touch].
428-
____
429-
430422
If an API does not have an existing integration test suite this might seem like
431423
a bigger push, but an API without a test suite should absolutely add one.
432424
Working with a generic test suite and adding in some OpenAPI assertions can be a
@@ -439,10 +431,9 @@ To avoid having to train a tool to know what the expected contract is, why not
439431
use a tool which already knows what the latest OpenAPI is meant to be at
440432
anytime: Microcks again!
441433

442-
Microcks handles xref:_guides/bump-sh-tutorials/testing-with-microcks.adoc[contract
443-
testing] as well as mock
444-
servers, and it does this by taking a URL to a server for comparison. This could
445-
be staging, pre-production, or even production if you're careful.
434+
Microcks handles contract testing as well as mock servers, and it does this by
435+
taking a URL to a server for comparison. This could be staging, pre-production,
436+
or even production if you're careful.
446437

447438
It works by going through all the operations in the OpenAPI document, and uses
448439
the examples and schemas defined there to send a request that should work, to an
@@ -490,7 +481,7 @@ jobs:
490481
waitFor: '10sec'
491482
----
492483

493-
_Learn more about xref:_guides/bump-sh-tutorials/testing-with-microcks.adoc[contract testing with Microcks]._
484+
_Learn more about https://docs.bump.sh/guides/bump-sh-tutorials/testing-with-microcks/[contract testing with Microcks]._
494485

495486
== Phase 3: Deploying Artifacts
496487

@@ -584,7 +575,7 @@ workflow like this for clarity. Either way, whenever a change is made to the
584575
`main` branch the mock servers will be updated and instantly reflect the latest
585576
OpenAPI.
586577

587-
_Learn more about xref:_guides/bump-sh-tutorials/mocking-with-microcks.adoc[API mocking with Microcks]._
578+
_Learn more about https://docs.bump.sh/guides/bump-sh-tutorials/mocking-with-microcks/[API mocking with Microcks]._
588579

589580
=== Publish SDKs
590581

@@ -601,8 +592,8 @@ over HTTP directly.
601592
SDK generation tools have been around for a long time, but in the past the best
602593
offering was a cumbersome Java-based open-source tool where you generally had to
603594
develop your own templates. Modern tooling like
604-
xref:_guides/bump-sh-tutorials/generate-sdks-with-speakeasy.adoc[Speakeasy] and
605-
xref:_guides/bump-sh-tutorials/stainless-integration.adoc[Stainless] allow API
595+
https://www.speakeasy.com/[Speakeasy] and
596+
https://www.stainless.com/[Stainless] allow API
606597
providers to point to an OpenAPI document, and produce type-safe SDKs that your
607598
team will be proud of. These will handle tricky functionality like OAuth 2,
608599
retries, pagination, and even allow for adding custom code to the generated
@@ -650,8 +641,6 @@ or rudimentary code samples like using `fetch()` or other low-level HTTP code.
650641

651642
image::images/bump-sdks.png[The Train Travel API documentation example on Bump.sh with a TypeScript SDK generated by Speakeasy showing in the documentation.]
652643

653-
_Learn more about xref:_guides/bump-sh-tutorials/generate-sdks-with-speakeasy.adoc[SDK generation with Speakeasy]._
654-
655644
=== API Catalog
656645

657646
Another key part of API governance is discoverability, which usually takes the
@@ -666,7 +655,12 @@ Alternatively, Hubs could be used to group APIs by team or department.
666655

667656
image::images/bump-hubs.png[A list of APIs, descriptions, and last updated times, for a sample Hub on Bump.sh]
668657

669-
_Learn more about xref:_guides/bump-sh-tutorials/api-discovery-using-bump-sh-hubs.adoc[API discovery with Bump.sh Hubs]._
658+
Making sure API catalogs are up to date and contain 100% of APIs can be tricky,
659+
but there are various ways to do it. One could be using an API Gateway that also
660+
happens to support API catalogs like [Kong
661+
Gateway](https://konghq.com/products/kong-gateway) and the [Service
662+
Catalog](https://konghq.com/products/kong-konnect/features/api-service-catalog).
663+
670664

671665
=== Try it Now
672666

0 commit comments

Comments
 (0)