sckott / mapurisapi

api for mapped uris
0 stars 0 forks source link

mapurisapi

This project was started at the PLOS article level metrics hackathon on 2014-12-06. The hackathon repo: https://github.com/articlemetrics/hackathon_2014

This repo contains a Ruby Sinatra API for serving versions of articles, based on a article DOI, or a query. Data is stored in, and search provided by, Elasticsearch.

Clone this repo

git clone git@github.com:sckott/mapurisapi.git
cd mapurisapi
bundle install

Install Elasticsearch

You can also install via Homebrew: brew install elasticsearch

Get data into Elasticsearch

Install elasticdump tool

sudo npm install elasticdump -g

Push data into ES via the bulk endpoint

cd mapurisapi
elasticdump --bulk=true --input=data.json --output=http://localhost:9200/

Then ping ES to make sure it's there

curl localhost:9200/mapuris

Start Sinatra

cd mapurisapi
ruby api.rb

Heartbeat

curl http://localhost::4567/heartbeat
{
  status: "ok"
}

The root redirects to /heartbeat (/heartbeat gives the same thing)

curl -L http://localhost:4567
{
  "status": "ok",
  "paths": [
    "/heartbeat",
    "/links/:doi",
    "/search"
  ]
}

Get links to other resources for a DOI.

curl http://localhost:4567/links/10.12688/f1000research.3817.1
{
    status: "ok",
    data: {
        _id: "10.12688/f1000research.3817.1",
        _rev: "1-16b4fe65ddc6be789c76761a8e7fb810",
        doi: "10.12688/f1000research.3817.1",
        url: "http://dx.doi.org/10.12688/f1000research.3817.1",
        pdf: "http://f1000research.com/articles/3817/1/pdf",
        xml: "http://f1000research.com/articles/3817/1/xml",
        cm_target_doi: { },
        cm_assertions: [
            "http://f1000research.com/articles/3-80/v1#article-reports",
            "http://f1000research.com/articles/3-80/v1#referee-response-4304",
            "http://f1000research.com/articles/3-80/v1#referee-response-5889"
        ],
        figs: "f1000research-3-4089-g0000.gif",
        media: { }
    }
}