• Stars
    star
    165
  • Rank 228,906 (Top 5 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 11 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An open-source, community-maintained database of Web standards & related references.

Specref API

Specref is an open-source, community-maintained database of Web standards & related references.

Table of Contents

API

The API to the service is very simple. It supports three operations which are:

Get a set of bibliographic references

GET https://api.specref.org/bibrefs?refs=FileAPI,rfc2119

parameters:

refs=comma-separated,list,of,reference,IDs
callback=nameOfCallbackFunction

returns: a JSON object indexed by IDs

{
    "FileAPI": {
        "authors": [
            "Arun Ranganathan",
            "Jonas Sicking"
        ],
        "date": "12 September 2013",
        "deliveredBy": [
            {
                "shortname": "webapps",
                "url": "http://www.w3.org/2008/webapps/"
            }
        ],
        "edDraft": "http://dev.w3.org/2006/webapi/FileAPI/",
        "href": "http://www.w3.org/TR/FileAPI/",
        "id": "FileAPI",
        "publisher": "W3C",
        "status": "LCWD",
        "title": "File API"
    },
    "rfc2119": {
        "authors": [
            "S. Bradner"
        ],
        "date": "March 1997",
        "href": "http://www.ietf.org/rfc/rfc2119.txt",
        "id": "rfc2119",
        "publisher": "IETF",
        "status": "Best Current Practice",
        "title": "Key words for use in RFCs to Indicate Requirement Levels"
    }
}

Search bibliographic references

GET https://api.specref.org/search-refs?q=coffee

parameters:

q=search%20term
callback=nameOfCallbackFunction

returns: a JSON object indexed by IDs

{
    "rfc2324": {
        "authors": [
            "L. Masinter"
        ],
        "date": "1 April 1998",
        "href": "http://www.ietf.org/rfc/rfc2324.txt",
        "id": "rfc2324",
        "publisher": "IETF",
        "status": "Informational",
        "title": "Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)"
    },
    "rfc7168": {
        "authors": [
            "I. Nazar"
        ],
        "date": "1 April 2014",
        "href": "http://www.ietf.org/rfc/rfc7168.txt",
        "id": "rfc7168",
        "publisher": "IETF",
        "status": "Informational",
        "title": "The Hyper Text Coffee Pot Control Protocol for Tea Efflux Appliances (HTCPCP-TEA)"
    }
}

Used to get a set of bibliographic references that include the search term in any of their attributes. This is useful to find specs related to a given area of study, specs by a given editor, etc.

Reverse lookup

GET https://api.specref.org/reverse-lookup?urls=http://www.w3.org/TR/2012/WD-FileAPI-20121025/

parameters:

urls=comma-separated,list,of,reference,URLs.
callback=nameOfCallbackFunction

returns: a JSON object indexed by URLs

{
    "http://www.w3.org/TR/2012/WD-FileAPI-20121025/": {
        "authors": [
            "Arun Ranganathan",
            "Jonas Sicking"
        ],
        "date": "12 September 2013",
        "deliveredBy": [
            {
                "shortname": "webapps",
                "url": "http://www.w3.org/2008/webapps/"
            }
        ],
        "edDraft": "http://dev.w3.org/2006/webapi/FileAPI/",
        "href": "http://www.w3.org/TR/FileAPI/",
        "id": "FileAPI",
        "publisher": "W3C",
        "status": "LCWD",
        "title": "File API"
    }
}

Notice this finds you the canonical version of a spec and not the precise version the URL points to. This is by design.

Aliases

Because of legacy references, case sensitivity issues and taste, many entries have multiple identifiers. Thus an aliasing system was put in place. It isn't that complicated really: an identifier either points directly to the reference object or to another identifier (through the aliasOf property), recursively. All aliases are resolved (there are tests for that) and when you query the API for a reference you always get all the objects necessary to resolve it in the same response. So for example, https://api.specref.org/bibrefs?refs=rfc7230 responds with:

{
    "rfc7230": {
        "authors": [
            "R. Fielding, Ed.",
            "J. Reschke, Ed."
        ],
        "date": "June 2014",
        "href": "https://tools.ietf.org/html/rfc7230",
        "id": "rfc7230",
        "publisher": "IETF",
        "status": "Proposed Standard",
        "title": "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing"
    }
}

while https://api.specref.org/bibrefs?refs=HTTP11 gives you:

{
    "HTTP11": {
        "aliasOf": "RFC7230",
        "id": "HTTP11"
    },
    "RFC7230": {
        "aliasOf": "rfc7230",
        "id": "RFC7230"
    },
    "rfc7230": {
        "authors": [
            "R. Fielding, Ed.",
            "J. Reschke, Ed."
        ],
        "date": "June 2014",
        "href": "https://tools.ietf.org/html/rfc7230",
        "id": "rfc7230",
        "publisher": "IETF",
        "status": "Proposed Standard",
        "title": "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing"
    }
}

Which let's you get to the data by using a simple while loop over the response. The contract guaranteed by the API is to always let you resolve aliases.

Now whether you decide to display the result as [HTTP1], [rfc7230], [RFC7230], or even [1] is up to you. Of course, it's silly to reference both [HTTP1] and [rfc7230] in the same specification, but that's something for the editors and/or their tools to avoid.

Obsoleted references

Some entries have an obsoletedBy property which contains an array of identifiers. These identifiers reference specifications that replace this one and can be queried separately from the database.

Like aliases, these identifiers are resolved (there are tests for that), but, unlike aliases, they are not returned with the response to the initial query.

Note that these identifiers can themselves point to aliases or have their own obsoletedBy property, recursively.

CORS

CORS is enabled for all origins. By default the service returns JSON data, which is great but not convenient for browsers that do not support CORS yet. For those, simply adding the callback parameter with the name of the callback function you want will switch the response to JSON-P.

Examples

Some examples should help:

// get references for SVG, REX, and DAHUT
GET https://api.specref.org/bibrefs?refs=SVG,REX,DAHUT

// the same as JSON-P
GET https://api.specref.org/bibrefs?refs=SVG,REX,DAHUT&callback=yourFunctionName

If you need to find a reference ID (for either bibliographic or cross-references) you need to look for it on specref.org.

Updating & adding new references

Commit rights

Specref loosely follows the process described in The Pull Request Hack. Contributors are generally granted commit access to the repo after their first pull request is successfully merged.

It's expected contributors read-up on how to make manual changes and follow the review policy described below.

Review policy

The review policy has three key principles:

  1. Get non-trivial changes reviewed by someone.
  2. You can merge trivial changes yourself, but allow enough time for others to comment on them before you do.
  3. Never merge a pull request unless travis is green.

We trust contributors to be a good judge of what is trivial, what isn't, and how long to wait before merging a trivial fix. Generally, the more trivial the fix, the shorter the wait.

Similarly, the more a commit message explains the why of a slightly unexpected fix, the less it requires a review.

For example, for a fix that changes an existing HTTPS url to an HTTP one:

Bad:

Updating URL.

Good:

There now exists a Persistent URI Registry of EU Institutions and Bodies[1]
which is to be used when referencing such documents.
Unfortunately it doesn't use HTTPS yet.

[1]: http://data.europa.eu/

Hourly auto-updating

There are scripts that pull fresh data from IETF, W3C, WHATWG and WICG, and update their relevant files in the refs directory. These are now run hourly. Their output is tested, committed and deployed without human intervention. Content should now always be up to date.

Manual changes

Generally, manual changes should be limited to the refs/biblio.json file.

If you have commit rights, please don't commit to main directly. Commit to a separate branch (preferably to your fork) and send a pull request.

All changes are automatically tested using travis and automatically deployed within minutes if all tests pass. You can check that your changes have been properly deployed on www.specref.org, @-mention @tobie in a pull request comment if they haven't.

You can run the tests locally by installing node.js, project dependencies (by running $ npm install from the root of the repository) and running $ npm test. The test suite is quite large and can take a few minutes to run.

Some rules to observe when editing the refs/biblio.json file:

  • Don't remove entries unless you are 100% certain that no one is using it. Typically that only applies to cases in which you have just added a reference and want to remove it.
  • Don't duplicate entries. Make sure that what you want to add is not in the DB. If it is, add an alias.
  • Please use structured objects instead of raw strings.
  • Always favor HTTPS URLs.
  • The format for structured objects is described in JSON-schema. The schema is used to test new entries, so you better abide by it. :) (Note I'm still looking for a tool to turn the JSON schema into something more easily consumed by human beings. Let me know if you have an idea, or better yet, send a pull request.)
  • When you want to update an existing reference, if you see that it uses the old string style, please convert it to a structured object. Edit both refs/biblio.json and refs/legacy.json in the same pull request, or you won't pass validation.
  • References in this database are expected to be to the β€œlatest and greatest” version of a given specification. In some cases this may be the draft residing in the editor's repository, or it may be the latest snapshot as published by a Working Group into TR β€” this choice is left to your appreciation. If you really, really want to have a reference to a dated version, then use the versions property like so:
{
    "REFID": {
        "versions": {
            "YYYYMMDD": {
                "href": "http://..."
            }
        }
    }, //...
}

Licenses

More Repositories

1

ua-parser

A multi-language port of Browserscope's user agent parser.
Perl
1,970
star
2

pdoc

JavaScript inline documentation parser
Ruby
108
star
3

Evidence

JavaScript unit testing
JavaScript
87
star
4

modulr-node

Resolves and concatenates CommonJS module dependencies for use in the browser.
JavaScript
59
star
5

unittest_js

Ruby
35
star
6

pr-preview

Adds preview and diff to spec pull requests.
JavaScript
31
star
7

helvetictoc

A time-full tribute to a timeless typeface
JavaScript
14
star
8

modulr

A CommonJS module implementation in Ruby for client-side JavaScript
Ruby
12
star
9

module-grapher

Node library for resolving and graphing Common JS module dependencies.
JavaScript
11
star
10

async-it

Generic asynchronous iterators for node.js.
JavaScript
6
star
11

snippety

A collection of snippets for TextExpander
4
star
12

specs-on-github

This document simply describes how to use GitHub for spec work.
HTML
4
star
13

simple-github

A simple, request-inspired and promise-based wrapper around GitHub's API for node.js.
JavaScript
3
star
14

respec-issues

A small utility to turn ReSpec issues into GitHub issues and link these together via the data-number attribute.
JavaScript
3
star
15

unittest_js_caja_builder

JavaScript
3
star
16

2CV

JavaScript
2
star
17

w3c-testing-plan

Plan proposal for testing the Open Web Platform
2
star
18

datacanvas-viz

Quick d3.js-based visualization for the datacanvas project.
2
star
19

node-evidence-gatherer

JavaScript
2
star
20

async-memoizer

A memoizer for asynchronous methods obeying node.js conventions.
JavaScript
2
star
21

visit

Visits a URL using phantomjs, loads the page, runs the CJS scripts and collects the results.
JavaScript
2
star
22

respec-example

2
star
23

webidl-grammar-post-processor

WebIDL grammar post-processor
JavaScript
2
star
24

fncmp

Just function composition for JavaScript.
JavaScript
1
star
25

feedme

An irc bot that react to people's hunger by posting quotes in french.
JavaScript
1
star
26

smart-library

Joyent Smart Platform JavaScript Library
JavaScript
1
star
27

ORIENTATIONLOCK-UCR

Use cases and requirements for orientation lock in Web applications
1
star