-
8 votes
-
Apple and Google launch exposure notification API, enabling public health authorities to release apps
8 votes -
Automating Safeway's coupon API
6 votes -
This video has 16,905 likes (that's 689,333 fewer than Tom's!)
7 votes -
Apple and Google’s COVID-19 exposure notification API: Questions and answers
4 votes -
Ask Tildes: Design practices for retrieving dozens (or hundreds) of related records over a RESTful API
I'm looking for some feedback on a feasible mechanism for structuring a few API endpoints where a purely RFC-spec compliant REST API wouldn't suffice. I have an endpoint which returns $child...
I'm looking for some feedback on a feasible mechanism for structuring a few API endpoints where a purely RFC-spec compliant REST API wouldn't suffice.
I have an endpoint which returns $child entries for a $parent resource, let's call it:
/api/parent/:parentId/children
. There could be anywhere from a dozen to several hundred children returned from this call. From here, achild
entity is related to a singleuserOrganization
, which itself is a pivoting entity on a singleuser
. The relationship between achild
anduser
is not strictly transitive, but can eachchild
only has oneuserOrganization
which only has oneuser
, so it is trivial to reach auser
from achild
resource.Given this, the data I need for the particular request involves retrieving all
user
's for aparent
. The obvious, and incorrect solution to the problem is to make the request mentioned above, and then iterate through and make an API request to retrieve eachuser
. This is less than very good as this would obviously be up to several hundred API calls.There's a few more scalable solutions that could solve this problem, so any input on these ideas is great; but if you have a better proposal that also works, I'm keen to explore that!
Include
user
relationships in the call by default.This certainly does solve the problem, but it's also pumping down a load of data I don't necessarily need. This would probably 2x the amount of bytes travelling along the wire, and in 8 out of 10 calls, that extra data isn't needed.
Have a separate
/api/parent/:parentId/users
call.Another option that partially solves the issue: I need data from both the
child
and theuser
to format this view, so I'd still need to make the initial call I documented earlier. Semantically, it feels a bit odd to have this as a resource because I don't consider auser
to be nested under aparent
in terms of database topology.Keep the original call, but add a query parameter to fetch the extra data
This comes across as the 'least worst' idea objectively, in terms of flexibility and design. Through the addition of the query parameter, you could optionally retrieve the relationship's data. This seems brittle and doesn't scale well to other endpoints where it could be useful though.
Utilize a Stripe
expands
-style query parameter.Stripe implements the ability to retrieve all related records from an API endpoint by specifying the relations as strings. This is essentially the same as the above answer, but is scaled to all available API endpoints. I love this idea, but implementing it in a secure way seems fraught with disaster. For example, this is a multi-tenancied application, and it would be trivial to request
userOrganization.user.organizations.users
. This would retrieve all other organisations for the user, and their users! This is because my implementation ofexpands
simply utilises the ORM of my choice to perform a database join, and of course the database has no knowledge about application tenancy!
Now, I do realise this problem could easily be solved by implementing a GraphQL API server, which I have done in the past, but unfortunately time and workload constraints dictate implementing a GraphQL-based solution is infeasible. As much as I like GraphQL, I'm not as proficient in that area as compared to implementing high quality traditional APIs, and the applications I'm working on at the moment are focusing on choosing boring technology, and not using excessive innovation tokens.
Furthermore, I do consider the conceptuals around REST APIs to be more of an aspirational sliding scale, rather than a well defined physical entity, because let's face it, the majority of popular APIs today aren't REST-compliant, even Stripe's isn't, and it's usually both financially healthier and feature-rich to choose a development path that results in a rough product that can be refined later, than aiming for a perfect initial release. All this said, I don't mind proposals or solutions to my problem that are "good enough". As long as they aren't too hacky! :)
10 votes -
A new tracking technique using CNAME aliases to circumvent third-party cookie restrictions is blockable using a Firefox DNS API, but not in Chrome
18 votes -
The Supreme Court will hear Google’s appeal in the long-running copyright/API dispute with Oracle
24 votes -
Safeway coupons, automation, and reversing private APIs
9 votes -
The data transfer project
7 votes -
Popular licenses in OpenAPI
5 votes -
Reddit's redesign has been down all day, however mobile apps work, and old reddit works. Does reddit not use the same public API for the redesign?
I'm not sure if this is the case for everyone but the new reddit can't load any data, at least for me. However, old.reddit.com works, and all mobile apps seem to work which obviously use the...
I'm not sure if this is the case for everyone but the new reddit can't load any data, at least for me. However, old.reddit.com works, and all mobile apps seem to work which obviously use the reddit API. I am curious, does reddit have a different version of their API for the redesign, and that's what's been down for hours?
edit: I know that reddit must allow their own product to do things that other products don't.. Like it seems the chat api is not open to 3rd parties.. but I assumed that they would have just blocked certain api endpoints from public exposure. But based on my blind troubleshooting of this case, it seems that they must be using a totally different interface all together for the redesign?
edit2: Copy paste of my down-thread comment in case you don't read the whole thread, the context is that I realize that this must not be a global issue.Hmm, so I've heard reddit is super-cached... is this possibly a caching fault then?
reddit uses redis, correct? And it must be sharded, right? So maybe some redis cluster nodes are down?
I'm trying to learn here, and I am likely asking the wrong questions.. The goal of my post was to understand this type of failure, as I realize that it must be partial as in if all of reddit resign was down, it would be news. If anyone could correct any of my statements or assumptions I would really appreciate it.
13 votes -
Oracle taps blockchain to introduce new revenue streams for startups
7 votes -
Google is shutting down the "Works with Nest" API on August 31, 2019
5 votes -
Nine APIs for the geekiest of programmers
7 votes -
Microsoft, Facebook, trust and privacy
3 votes -
Experiments, growth engineering, and the perils of not disguising your API routes: Part 1
7 votes -
To Create An Evolvable API, Stop Thinking About URLs
5 votes -
Reverse engineering Apple's CoreDisplay API
3 votes -
Looks like Steam’s getting dedicated servers for non-Valve games
20 votes -
Google asks Supreme Court to overrule disastrous ruling on API copyrights
16 votes -
These 299 macOS apps are so buggy, Apple had to fix them in AppKit
11 votes -
Venmo's public API exposes millions of transactions, startling users
10 votes -
Google, Facebook, Microsoft, and Twitter partner for ambitious new data project
7 votes -
Twitter 'Smytes' customers
13 votes -
Request: API to fetch all comments including hierarchy relationship
Hello, I saw in another thread being mentioned that there is no use for API for real users other than bots. So wanted to voice some real API uses that I would be interested in: When I post a new...
Hello,
I saw in another thread being mentioned that there is no use for API for real users other than bots. So wanted to voice some real API uses that I would be interested in:
- When I post a new blog post, if I find it worthy of sharing here, it would be nice to mirror the comments I get here back on my blog post. I can imagine using API to fetch all the comments from a tildes thread, including the hierarchy relationship. The API would return a JSON with Markdown and/or HTML like the XML that Disqus exports (but JSON). When people want to comment on that post, they can come to tildes to do so, or if they don't want to create an account here, or if they don't have an invite, they can comment via other means that I have (Webmentions, Twitter, email).
- Second use is make something like hnrss possible.
4 votes -
Source and API
If it's too early in development for these questions, let me know. Is the source available yet? If so, where is it hosted? If not, when will it be dropped? Third party API: I know the docs say...
If it's too early in development for these questions, let me know.
- Is the source available yet? If so, where is it hosted? If not, when will it be dropped?
- Third party API: I know the docs say that the browser should be the client. However, after using tildes for awhile on mobile, it's quite... interesting. The site does really well on mobile, don't get me wrong, but it's missing the system feel that makes the experience pleasant. Honestly, one of the big reasons I was drawn to reddit was the ample support (by the third party) for mobile clients. I'd love to get started on a client for ~.
14 votes