Before I left Square earlier this year, I lead our design efforts on the developer API. https://docs.connect.squareup.com/ It was really interesting work and the team was quite committed once we found the right team. People always asked what does a designer do on an API. It turns out that if the team cares, quite a lot. Documentation is the obvious one but lots of other things like structuring the actual information,…
Square has excellent developer documentation! Hopefully it's in good hands after you've left. It would suck if the quality degraded.
User experience design for APIs
11–20 of 44 posts
Re: User experience design for APIs
#12Really good tip! Going to spend a little more time reworking my onboarding workflow with this in mind.
Re: User experience design for APIs
#13> (in general, always use ValueError and avoid assert).
ValueError is for when,
> an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception
(the docs explicitly note only for builtins, but I'm frankly okay w/ people using it in their code.)
You should not be raising this when you should be raising AssertionError, however, the two conditions are very different; the latter is for conditions that should be true but for some reason aren't. I find these usually crop up when running through a bunch of ifs:
if a:
elif b:
elif c:
else:
# *One* of the above should always match, in this case.
# This branch should never be taken, and it wasn't any fault of the user we're here.
raise AssertionError('good description of the situation')
Attempts to restructure the above are usually fairly bad: you can omit the `else`, but then execution will never take any branch, and if the branches do something like initialize a variable that the code following the branches will make use of, you're doomed anyways, and it's better to bail in an informative manner. You can meld the last elif and else together (i.e., the else just handles case C above), but then it also inadvertently handles unexpected states D, E, etc. too.IMO, AssertionErrors should indicate bugs in the called API. ValueErrors indicate bugs in the caller's use of the API.
(You may choose a less "destructive" method of asserting, such as logging, but in my experience, these get lost, and if you're in an undefined state then you still need to find some way to repair that state, and in my experience most attempts to do so are more trouble than they're worth. It's better to fail earlier and harder and louder, s.t. bugs are discovered and swiftly fixed.)
Re: User experience design for APIs
#14Great, except for this… > (in general, always use ValueError and avoid assert). ValueError is for when, > an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception (the docs explicitly note only for builtins, but I'm frankly okay w/ people using it in their code.) You should not be raising this when you should be raising AssertionError, however, the…
Yes, I agree with this stance. `ValueError` should be used for user-provided input validation (as well as `TypeError` in some cases). But as it happens, many Python developers use `assert` statements to do input validation, and generally don't provide any error messages in their `assert` statements. I'm suggesting going with `ValueError` (and a nice message) instead.
Re: User experience design for APIs
#15A similar guidance is pop-ups in games (e.g. when next to car, "F to enter").
Re: User experience design for APIs
#16pytorch with a keras like functional/layers API would be amazing. I'm guessing we might see that in tensorflow when keras adds support for the new eager mode.
Re: User experience design for APIs
#17Nit: Really verbose error messages like the last example are at risk of being brittle. If the API changes, there may be a failure to update the error message. This is because the messages may concern things at a distance, and may have arbitrary prose that no longer makes sense. For example, imagine if all your error messages were basically documentation style prose. That would be a nightmare, and would set you up to…
bad request type, see http://company.com/API/ce32h
except that it always seems the company forgets and removes the page.maybe that could be fixed to some degree in a build step
Re: User experience design for APIs
#18Folks interested in this would probably also be interested in: * this talk by Jesse Noeller from PyTexas a few years ago: https://www.youtube.com/watch?v=-vZ_E1OO_PY * the WriteTheDocs community, which is sortof a mashup of traditional technical writers and software engineers. http://www.writethedocs.org/meetups/ * the mailing list GET PUT POST (shameless plug): https://getputpost.co/overhauling-api-docs-with-gocardl…
There's also a Django-specific version called "Your Django app is a User Interface": https://www.youtube.com/watch?v=Mnzvjn1v1CY
Re: User experience design for APIs
#19Nit: Really verbose error messages like the last example are at risk of being brittle. If the API changes, there may be a failure to update the error message. This is because the messages may concern things at a distance, and may have arbitrary prose that no longer makes sense. For example, imagine if all your error messages were basically documentation style prose. That would be a nightmare, and would set you up to…
When building API end points, I take a different approach by including both messages and message codes, as well as a general "result" code (to make it easy to determine if it's a basic success/error result (also including the right HTTP code)).
An example that I'm working on right at the moment:
{
"result": {
"code": "error",
"message_code": "too_many_user_agents",
"message": "You have sent %s user agents; this is more than the maximum allowed per batch (%s user agents). Please send fewer in each batch."
}
}
The message describes the problem; what they did wrong, what the limit is and how they can fix it so it doesn't happen again.As well as this, the developer can easily check that the response code was an error, and there's the message_code - this will NEVER EVER change for this problem, so a developer could write code to specifically deal with that scenario.
However there's also a human readable message, which may potentially change (perhaps a grammar or punctuation fix, or if it included a URL it might change one day...)
I've found this approach is the best sort of middle ground.
Re: User experience design for APIs
#20Before I left Square earlier this year, I lead our design efforts on the developer API. https://docs.connect.squareup.com/ It was really interesting work and the team was quite committed once we found the right team. People always asked what does a designer do on an API. It turns out that if the team cares, quite a lot. Documentation is the obvious one but lots of other things like structuring the actual information,…
Did you use a third party documentation CMS for that, or roll your own internally for all the formatting etc.?