Designing a Pragmatic RESTful API
21–30 of 139 posts
Re: Designing a Pragmatic RESTful API
#22Earlier quoted context omitted.
Doesn't this open you up to replay attacks though? Since you can't store that a token was already used..
Sure you can. Just include a timestamp, and expire the token, at, say, time + 90 seconds, or whatever makes sense for the application.
Re: Designing a Pragmatic RESTful API
#23I ask this because the API I'm building is for a B2B product and lot of the "actions" are not state change requests. In fact, they are a lot of verbs which fire off lots of business logic and don't really map well to a single entity. Some endpoints also need to return very large and deeply filled entities in a single call.
I've started to investigate JSON-RPC, is that a good option?
Re: Designing a Pragmatic RESTful API
#24I built a tool to use a third partys restful api for a when they should have built it using message queuing as that suited the application.
Re: Designing a Pragmatic RESTful API
#25Earlier quoted context omitted.
I did think that the criticism of XML for being hard to parse was a bit odd. Although I generally prefer JSON for simpler stuff XML is pretty easy to parse and sift through with XPath.
It has to do with the awful XML generated by automatic tooling (SOAP by WCF and JEE). Hand-generated XML can be just as nice as using hand-generated JSON, and on the other hand automatic domain-model-to-JSON mapping can be as ugly as any XML monstrosity.
Creating idiomatic XML, on the other hand, is a little more tricky. Should something be a tag or an attribute? What should it be named?
Re: Designing a Pragmatic RESTful API
#26"A RESTful API should be stateless. This means that request authentication should not depend on cookies or sessions. Instead, each request should come with some sort authentication credentials." Doesn't that mean you need to do a database lookup to verify the user with every request? Seems like a lot of overhead just for the sake of avoiding sessions.
Use an expiring token like mechanism. The API user first gets a token using credentials. Future requests use the token for authentication. A new token will be required periodically.
Is it because the authentication part is a lot of work for the server or client?
Is it for the negligible (in this context) security benefits of not using the same secret-key for all traffic?
Re: Designing a Pragmatic RESTful API
#27This is a well-written and informative article, kudos. That said, it reminds me how fucking overcomplicated REST HTTP API is for 99% of uses. As an API user, all I want is to call a function on a server, pass it some arguments and get a result. I want it to be dead simple, and REST is probably the opposite of that. Finally, it also occurs to me that most API calls may call one function which returns lots of data that…
Re: Designing a Pragmatic RESTful API
#28Earlier quoted context omitted.
It has to do with the awful XML generated by automatic tooling (SOAP by WCF and JEE). Hand-generated XML can be just as nice as using hand-generated JSON, and on the other hand automatic domain-model-to-JSON mapping can be as ugly as any XML monstrosity.
Though for the same dataset, XML will be slower to parse. For performance's sake use JSON.
Loading a huge JSON file is almost certainly slower than using a SAX parser for a huge XML file. Maybe there are SAX like approaches for JSON, too.
Re: Designing a Pragmatic RESTful API
#29This is a well-written and informative article, kudos. That said, it reminds me how fucking overcomplicated REST HTTP API is for 99% of uses. As an API user, all I want is to call a function on a server, pass it some arguments and get a result. I want it to be dead simple, and REST is probably the opposite of that. Finally, it also occurs to me that most API calls may call one function which returns lots of data that…
That said, this article isn't particularly faithful to REST.
Re: Designing a Pragmatic RESTful API
#30Earlier quoted context omitted.
Though for the same dataset, XML will be slower to parse. For performance's sake use JSON.
> Though for the same dataset, XML will be slower to parse. For performance's sake use JSON. Loading a huge JSON file is almost certainly slower than using a SAX parser for a huge XML file. Maybe there are SAX like approaches for JSON, too.