laarctags | new | comments | ask | show | place | submitlogin
Laarc API (github.com)
2 points by shawn to meta laarc api programming 18 days ago | 3 comments




2 points by xojoc 18 days ago

Thanks Shawn. For context this API is very similar to the Hacker News one: https://github.com/HackerNews/API In fact it took minutes to add it to my own site (https://discu.eu).

@shawn: I just noticed that the API doesn't export the "tags" of a submission. For example the JSON for this submission https://laarrc.firebaseio.com/v0/item/2702.json?print=pretty missises the tags "meta,laarc,api,programming". Do you think it would be a lot of trouble to export them?

reply

2 points by shawn 17 days ago

A surprising oversight on my part. Let me look into it when I’m not juggling a job and a puppy.

Since it’s the first feature request in a year, I’d feel bad not doing it. So let’s see if it happens.

reply

2 points by shawn 17 days ago

I haven't updated the API docs yet, but items now export tags. And since it's 5am, I'd rather leave a quick note here on how to get them.

Here's what https://www.laarc.io/item?id=2545 looks like:

https://laarrc.firebaseio.com/v0/item/2545.json?print=pretty

  {
    "by" : "rain1",
    "descendants" : 0,
    "id" : 2545,
    "keys" : [ "nokill", "/l/electronics" ],
    "score" : 2,
    "text" : "",
    "time" : 1610283131,
    "title" : "Why three prongs?  Electrical ground, stray voltage",
    "type" : "story",
    "url" : "http://amasci.com/amateur/whygnd.html"
  }
To get the tags, use this algorithm:

1. Check whether there's a "keys" entry. If not, return an empty list.

2. Remove all keys that don't begin with a forward slash, then return the list.

I'll explain in more detail why I chose this approach. But for now, just know that you get more information this way. (e.g. you can see whether a story is flagged by checking for the "flagged" key.)

reply




Welcome | Guidelines | Bookmarklet | Feature Requests | Source | API | Contact | Twitter | Lists

RSS (stories) | RSS (comments)

Search: