Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
sunaurus
Feb 13, 2012

Oh great, another bookah.

Ither posted:

AI client?

Don't get me wrong, REST is great and dumb REST clients are used every day (browsers for example), but they need an actual human to click on links and stuff to actually get anywhere. Without a human, REST APIs don't make any sense. When people say "we have a REST API", they generally mean "we have an HTTP API that may or may not look similar to REST in some ways, but probably isn't really REST".

Imagine a world where people actually use REST APIs for machine clients:

You need to create an app for letting your users manage ads on a sweet social network. They have a REST API, so all you get is the root endpoint - https://socialnetworkapi.com. You ask for more documentation, but they tell you that it's a proper REST API, just follow the trail of crumbs from the root URL. You start making requests to figure out what the resource tree looks like and what operations you can do on each resource. You write down all the requests you'll need for creating ads and adding pictures to them and getting stats and so on. As you submit your first pull request, the senior developer reviewing your code asks you if you're mad. "Why did you hardcode all these endpoints? It's a REST API! The endpoints can change at any time!". You go back to the drawing board and start thinking of ways to automatically navigate the API using just the root URL and HATEOAS. 50 years of hard coding go by and you finally manage to create a client that can successfully create ads on social network using a REST API. Sadly, it turns out the client is self-aware and it murders all humans. The End.

sunaurus fucked around with this message at 13:04 on Apr 4, 2019

Adbot
ADBOT LOVES YOU

Pollyanna
Mar 5, 2005

Milk's on them.


I don’t recall what the point of REST was. Resource manipulation, sure, but not everything is simple CRUD.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

sunaurus posted:

Sadly, it turns out the client is self-aware and it murders all humans. The End.

Weird place to put "Sadly" but you do you

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



https://twitter.com/brittanybefort/status/920160913847500800

New (to me) career goal

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

spiritual bypass
Feb 19, 2008

Grimey Drawer

Pollyanna posted:

I don’t recall what the point of REST was. Resource manipulation, sure, but not everything is simple CRUD.

Seems like it's a good candidate for auto generation to get basic CRUD handled to allow the programmer more space to write the interesting parts

Nomnom Cookie
Aug 30, 2009



Pollyanna posted:

I don’t recall what the point of REST was. Resource manipulation, sure, but not everything is simple CRUD.

I don't either, so I went back to Fielding's dissertation:

quote:

REST emphasizes scalability of component interactions, generality of interfaces, independent deployment of components, and intermediary components to reduce interaction latency, enforce security, and encapsulate legacy systems.

I dunno. REST is about doing good design and benefiting from it, I guess.

CPColin
Sep 9, 2003

Big ol' smile.
Maybe it's like the Blood Type Diet where the philosophy mostly boils down to, "Just think about what you're doing/eating literally at all and you'll feel better."

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Has something happened with spacebar in the past ~2 years or so? It seems like people just kind of willy-nilly started omitting spaces where they could have used them and then just dumped a few extra in other places--including between words in comments.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Rocko Bonaparte posted:

Has something happened with spacebar in the past ~2 years or so? It seems like people just kind of willy-nilly started omitting spaces where they could have used them and then just dumped a few extra in other places--including between words in comments.

Until the most recent rev, a lot of recent MBPs had lovely fragile keyboards and the space bar was the most frequent victim.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
For me, REST means having an intuitive API that follows the standards that everyone understands. I constantly hit the facebook/twitter/github API as examples of good RESTful endpoints.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
You could argue the Facebook API works so well the data ends up literally everywhere

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Sagacity posted:

You could argue the Facebook API works so well the data ends up literally everywhere

Data just wants to be free.

Pollyanna
Mar 5, 2005

Milk's on them.


poemdexter posted:

For me, REST means having an intuitive API that follows the standards that everyone understands. I constantly hit the facebook/twitter/github API as examples of good RESTful endpoints.

What are the standards that everybody understands?

Volguus
Mar 3, 2009

Pollyanna posted:

What are the standards that everybody understands?

Depends how do you define "everybody" and "understands".

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

Subjunctive posted:

Until the most recent rev, a lot of recent MBPs had lovely fragile keyboards and the space bar was the most frequent victim.
Now it's the j key

Pollyanna posted:

What are the standards that everybody understands?
That everything is terrible all the time

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Pollyanna posted:

What are the standards that everybody understands?

Do what github/facebook/twitter does with respect to endpoint definitions and response codes. That's really all that matters to me.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

Pollyanna posted:

I don’t recall what the point of REST was. Resource manipulation, sure, but not everything is simple CRUD.

Its easier to talk to than SOAP

What I get out of REST: you can test with a simple html client. That's about it.

Hughlander
May 11, 2005

Zaphod42 posted:

Its easier to talk to than SOAP

What I get out of REST: you can test with a simple html client. That's about it.

You mean http client like curl? I can’t think of an html client that makes PATCH or DELETE easy.

beuges
Jul 4, 2005
fluffy bunny butterfly broomstick

poemdexter posted:

For me, REST means having an intuitive API that follows the standards that everyone understands. I constantly hit the facebook/twitter/github API as examples of good RESTful endpoints.

All our APIs follow the same structure: every request is a POST, request body is some object specific to the type of request, and response body has a Succeeded, ErrorCode, ErrorMessage and Result field, which contains the actual response data.
Want to create a Foo? POST to api/V1/CreateFoo with a CreateFooRequest json body, get back Succeeded=1, ErrorMessage=null, Result = { CreatedFooId = 1 }
Want to get a Foo? POST to api/V1/GetFoo with a GetFooRequest body { FooId = 1 }, get back a GetFooResponse in the Result field
Want to frobnicate a Foo? POST to api/V1/FrobnicateFoo with a FrobnicateFooRequest body, e.g. { FooId = 1, FrobnicateType = … }, get back your result.

Every request should always get back a 200 response, so you don't need to know if your error code was because the service broke or it was trying to return you a logical error via HTTP status codes. If you get a 404, your request is broken, anything else means the server barfed. Nobody needs to think about which HTTP verb to use for a particular request, and nobody needs to think about what each HTTP status code might mean.

Not entirely sure if this belongs in the coding horrors thread instead

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
You've essentially reinvented a worse version of gRPC then

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

Hughlander posted:

You mean http client like curl? I can’t think of an html client that makes PATCH or DELETE easy.

Yeah http. Curl or postman.

redleader
Aug 18, 2005

Engage according to operational parameters

Sagacity posted:

You've essentially reinvented a worse version of gRPC then

Nothing wrong with a little RPC.

Volguus
Mar 3, 2009

redleader posted:

Nothing wrong with a little RPC.

Everything's wrong with a little reinvention though.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

Hughlander posted:

You mean http client like curl? I can’t think of an html client that makes PATCH or DELETE easy.
https://addons.mozilla.org/en-US/firefox/addon/rested/

Seat Safety Switch
May 27, 2008

MY RELIGION IS THE SMALL BLOCK V8 AND COMMANDMENTS ONE THROUGH TEN ARE NEVER LIFT.

Pillbug

This happened at one of my previous gigs. "I QUIT" on a cake. She had to keep trying to keep her coworkers (self included) from eating it until her boss arrived to read it.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Jeez, just flip it onto the scanner bed so that you can print a copy.

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost
Just arrive late to work, what are they going to do, fire you?

Wibla
Feb 16, 2011

Seat Safety Switch posted:

This happened at one of my previous gigs. "I QUIT" on a cake. She had to keep trying to keep her coworkers (self included) from eating it until her boss arrived to read it.

That's epic. I'm stealing that idea.

Keetron
Sep 26, 2008

Check out my enormous testicles in my TFLC log!

Zaphod42 posted:

Yeah http. Curl or postman.

I have an unreasonable hate for postman which stems from the time as a tester. Like Cyprus it gives people another tool to do a specific thing and then locks them in this really weird interface that allows very incompetent people to build very complex things that are unmaintainable by modern standards defeating the entire purpose of tooling to begin with.
However, since I discovered it to do some simple calls to check if my service is running properly deployed with everything connected, I like it more. And it spits out and accepts Curl commands for easy sharing.

So yeah, postman, sounds like a plan.

Macichne Leainig
Jul 26, 2012

by VG
I get your point, but GUI or not incompetent people will gently caress something up inevitably anyway.

That's why we're all lucky enough to be able to afford booze.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

beuges posted:

All our APIs follow the same structure: every request is a POST, request body is some object specific to the type of request, and response body has a Succeeded, ErrorCode, ErrorMessage and Result field, which contains the actual response data.
Want to create a Foo? POST to api/V1/CreateFoo with a CreateFooRequest json body, get back Succeeded=1, ErrorMessage=null, Result = { CreatedFooId = 1 }
Want to get a Foo? POST to api/V1/GetFoo with a GetFooRequest body { FooId = 1 }, get back a GetFooResponse in the Result field
Want to frobnicate a Foo? POST to api/V1/FrobnicateFoo with a FrobnicateFooRequest body, e.g. { FooId = 1, FrobnicateType = … }, get back your result.

Every request should always get back a 200 response, so you don't need to know if your error code was because the service broke or it was trying to return you a logical error via HTTP status codes. If you get a 404, your request is broken, anything else means the server barfed. Nobody needs to think about which HTTP verb to use for a particular request, and nobody needs to think about what each HTTP status code might mean.

Not entirely sure if this belongs in the coding horrors thread instead

Dear god that's so close to what some people are designing here. I'm so triggered.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

beuges posted:

All our APIs follow the same structure: every request is a POST, request body is some object specific to the type of request, and response body has a Succeeded, ErrorCode, ErrorMessage and Result field, which contains the actual response data.
Want to create a Foo? POST to api/V1/CreateFoo with a CreateFooRequest json body, get back Succeeded=1, ErrorMessage=null, Result = { CreatedFooId = 1 }
Want to get a Foo? POST to api/V1/GetFoo with a GetFooRequest body { FooId = 1 }, get back a GetFooResponse in the Result field
Want to frobnicate a Foo? POST to api/V1/FrobnicateFoo with a FrobnicateFooRequest body, e.g. { FooId = 1, FrobnicateType = … }, get back your result.

Every request should always get back a 200 response, so you don't need to know if your error code was because the service broke or it was trying to return you a logical error via HTTP status codes. If you get a 404, your request is broken, anything else means the server barfed. Nobody needs to think about which HTTP verb to use for a particular request, and nobody needs to think about what each HTTP status code might mean.

Not entirely sure if this belongs in the coding horrors thread instead

It's all bad, but anyone who puts an HTTP verb in the name of an api (e.g. GetFoo instead of having Foo with a GET verb) should be loving stabbed. I hate that poo poo.

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost
GetFoo doesn't accept GET, sorry, you gotta HEAD

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

poemdexter posted:

Dear god that's so close to what some people are designing here. I'm so triggered.

I don't normally code in this kind of domain, but I feel like that example is more than half of how internally-facing web applications are probably implemented.

Nomnom Cookie
Aug 30, 2009



Things that matter, in order:

  1. Documentation
  2. Functionality
  3. Consistency
  4. Correctness

Things that don't matter:

  • URL structure
  • Signalling errors in the status code or response body
  • Content type
  • HTTP verbs lining up with semantics

beuges posted:

All our APIs follow the same structure: every request is a POST, request body is some object specific to the type of request, and response body has a Succeeded, ErrorCode, ErrorMessage and Result field, which contains the actual response data.
Want to create a Foo? POST to api/V1/CreateFoo with a CreateFooRequest json body, get back Succeeded=1, ErrorMessage=null, Result = { CreatedFooId = 1 }
Want to get a Foo? POST to api/V1/GetFoo with a GetFooRequest body { FooId = 1 }, get back a GetFooResponse in the Result field
Want to frobnicate a Foo? POST to api/V1/FrobnicateFoo with a FrobnicateFooRequest body, e.g. { FooId = 1, FrobnicateType = … }, get back your result.

Every request should always get back a 200 response, so you don't need to know if your error code was because the service broke or it was trying to return you a logical error via HTTP status codes. If you get a 404, your request is broken, anything else means the server barfed. Nobody needs to think about which HTTP verb to use for a particular request, and nobody needs to think about what each HTTP status code might mean.

Not entirely sure if this belongs in the coding horrors thread instead

Assuming the documentation is up to snuff, this is a good API.

Polio Vax Scene
Apr 5, 2009



Kevin Mitnick P.E. posted:

Things that matter, in order:

  1. Documentation
  2. Functionality
  3. Consistency
  4. Correctness


lol tell this to my company. The list is backward (also consistency isn't on the list)

spacebard
Jan 1, 2007

Football~

Kevin Mitnick P.E. posted:


  • HTTP verbs lining up with semantics

Thanks. Finally some validation to make my next api use only OPTIONS requests.

Good luck, browsers. :clint:

Xarn
Jun 26, 2015

Kevin Mitnick P.E. posted:

Things that matter, in order:

  1. Documentation
  2. Functionality
  3. Consistency
  4. Correctness

Things that don't matter:

  • URL structure
  • Signalling errors in the status code or response body
  • Content type
  • HTTP verbs lining up with semantics


Assuming the documentation is up to snuff, this is a good API.

How does it feel to be so wrong? :v:

Adbot
ADBOT LOVES YOU

CPColin
Sep 9, 2003

Big ol' smile.
I'm spending far too much time trying to figure out what URL a certain API endpoint should live on. The request is going to be "get me the permissions user X has on application Y," so both X and Y definitely need to be in the URL, but I'm not planning to allow "get me all permissions user X has" or "get me all users application Y has," so I'm probably overthinking it and should just use /permissions?user=X&application=Y instead of the typical RESTful hierarchical-ish style.

I'm Not Gonna Need It™

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply