REST API #15

Closed
opened 2014-11-27 20:04:39 +01:00 by kjetil · 10 comments
kjetil commented 2014-11-27 20:04:39 +01:00 (Migrated from gitlab.lallis.org)

To enable third party use of the data generated within Predi, there should be a REST API.

This API should at least give access to current predictions and an overview of prices over time.

This article explains how to do this: http://www.meteorpedia.com/read/REST_API I haven't read it yet.

To enable third party use of the data generated within Predi, there should be a REST API. This API should at least give access to current predictions and an overview of prices over time. This article explains how to do this: http://www.meteorpedia.com/read/REST_API I haven't read it yet.
robert commented 2014-11-30 23:23:17 +01:00 (Migrated from gitlab.lallis.org)

Reassigned to @robert

Reassigned to @robert
robert commented 2014-11-30 23:24:54 +01:00 (Migrated from gitlab.lallis.org)

Using iron:router to create simple read REST API that reflects Mongo Collections!

Using iron:router to create simple read REST API that reflects Mongo Collections!
kjetil commented 2014-11-30 23:26:35 +01:00 (Migrated from gitlab.lallis.org)

Love it! Remember writing hours :)

Love it! Remember writing hours :)
kjetil commented 2014-12-08 22:21:15 +01:00 (Migrated from gitlab.lallis.org)

Note that I've introduced an extra level of collections and moved some fields (according to #5). There is now Markets, Contractsets and Contracts. Most fields that used to live in the Market collection now lives in Contractsets.

Also, there is tags on users and markets indicating which markets each user will have access to. I think these tags might be of interest to users of the REST API.

These changes still live only in the adminui branch. I could merge them into the develop branch if you want. I think everything is working about as good as it used to now, but the design is totally messed up.

mockdata.coffee is a good place to look to get an idea on the available fields en each collection.

Another change that has been committed is translations. I guess that could be part of the REST API also. If no language is given TAPi18n insists on defaulting to English, which I suspect the Swiss will not like.

Note that I've introduced an extra level of collections and moved some fields (according to #5). There is now Markets, Contractsets and Contracts. Most fields that used to live in the Market collection now lives in Contractsets. Also, there is tags on users and markets indicating which markets each user will have access to. I think these tags might be of interest to users of the REST API. These changes still live only in the adminui branch. I could merge them into the develop branch if you want. I think everything is working about as good as it used to now, but the design is totally messed up. [mockdata.coffee](../feature/adminui/server/mockdata.coffee) is a good place to look to get an idea on the available fields en each collection. Another change that has been committed is translations. I guess that could be part of the REST API also. If no language is given TAPi18n insists on defaulting to English, which I suspect the Swiss will not like.
kjetil commented 2015-01-08 21:36:17 +01:00 (Migrated from gitlab.lallis.org)

Fra nerdouten

  • Liste av marked

    • Filtrer på tag
  • Kontrakter.

    • Filtrert på kontraktsettid
    • Regn ut priser pr kontakt
    • Filtrer på tag fra foreldremarked?
  • Prishistorikk på kontrakter i kontraktsett

    • Fra/til/interval
    • Rådata
  • Nåværende pris og historikk kjørt gjennom magisk omregningsalgoritme som samfunnsviterne har laget

    • Den tar et kontraktsett og returnerer et vektet snitt for kontraktene.
  • Brukerrangering

Fra nerdouten * Liste av marked * Filtrer på tag * Kontrakter. * Filtrert på kontraktsettid * Regn ut priser pr kontakt * Filtrer på tag fra foreldremarked? * Prishistorikk på kontrakter i kontraktsett * Fra/til/interval * Rådata * Nåværende pris og historikk kjørt gjennom magisk omregningsalgoritme som samfunnsviterne har laget * Den tar et kontraktsett og returnerer et vektet snitt for kontraktene. * Brukerrangering
kjetil commented 2015-02-02 01:11:57 +01:00 (Migrated from gitlab.lallis.org)

Reassigned to @kjetil

Reassigned to @kjetil
kjetil commented 2015-02-03 00:49:58 +01:00 (Migrated from gitlab.lallis.org)

Status changed to closed by commit 5077b6

Status changed to closed by commit 5077b6
kjetil commented 2015-02-03 01:07:05 +01:00 (Migrated from gitlab.lallis.org)

Status changed to reopened

Status changed to reopened
kjetil commented 2015-02-03 01:12:31 +01:00 (Migrated from gitlab.lallis.org)

ach. reopening. Still some weirdness. Remember to filter out mirror contracts.

As an example, this request:

https://predi.lallis.org/api/pricehistory/sdnXz8o7mbShGHdhk/6

Right now produces this:

{
    "market_id": "9oLWoBkw4uTcW58JP",
    "title": "Ernst Stocker (SVP) to be elected into the Regierungsrat",
    "description": "The contract pays 100 if Ernst Stocker (SVP) is elected in the 2015 Election for the Regierungsrat. Otherwise the contract pays 0.",
    "voteshare": false,
    "contractset_id": "sdnXz8o7mbShGHdhk",
    "open_at": 1422748848000,
    "close_at": 1423396848000,
    "contracts": [
        {
            "title": "",
            "contract_id": "4Dxv464bnkRjxaRok"
        },
        {
            "title": "Ernst Stocker (SVP) to be elected into the Regierungsrat",
            "color": "#006633",
            "contract_id": "48JhJmaZP34XRSyu5"
        }
    ],
    "price_history": [
        {
            "contract_id": "4Dxv464bnkRjxaRok",
            "values": [
                {
                    "timestamp": 1422702741600,
                    "price": 50
                },
                {
                    "timestamp": 1422724341600
                },
                {
                    "timestamp": 1422745941600
                },
                {
                    "timestamp": 1422767541600,
                    "price": 0.4
                },
                {
                    "timestamp": 1422789141600,
                    "price": 0.4
                },
                {
                    "timestamp": 1422810741600,
                    "price": 0.4
                },
                {
                    "timestamp": 1422832341600,
                    "price": 0.4
                },
                {
                    "timestamp": 1422853941600,
                    "price": 0.4
                }
            ]
        },
        {
            "contract_id": "48JhJmaZP34XRSyu5",
            "values": [
                {
                    "timestamp": 1422702741600,
                    "price": 0.4
                },
                {
                    "timestamp": 1422724341600
                },
                {
                    "timestamp": 1422745941600
                },
                {
                    "timestamp": 1422767541600,
                    "price": 99.6
                },
                {
                    "timestamp": 1422789141600,
                    "price": 99.6
                },
                {
                    "timestamp": 1422810741600,
                    "price": 99.6
                },
                {
                    "timestamp": 1422832341600,
                    "price": 99.6
                },
                {
                    "timestamp": 1422853941600,
                    "price": 99.6
                }
            ]
        }
    ]
}
ach. reopening. Still some weirdness. Remember to filter out mirror contracts. As an example, this request: ``` https://predi.lallis.org/api/pricehistory/sdnXz8o7mbShGHdhk/6 ``` Right now produces this: ```javascript { "market_id": "9oLWoBkw4uTcW58JP", "title": "Ernst Stocker (SVP) to be elected into the Regierungsrat", "description": "The contract pays 100 if Ernst Stocker (SVP) is elected in the 2015 Election for the Regierungsrat. Otherwise the contract pays 0.", "voteshare": false, "contractset_id": "sdnXz8o7mbShGHdhk", "open_at": 1422748848000, "close_at": 1423396848000, "contracts": [ { "title": "", "contract_id": "4Dxv464bnkRjxaRok" }, { "title": "Ernst Stocker (SVP) to be elected into the Regierungsrat", "color": "#006633", "contract_id": "48JhJmaZP34XRSyu5" } ], "price_history": [ { "contract_id": "4Dxv464bnkRjxaRok", "values": [ { "timestamp": 1422702741600, "price": 50 }, { "timestamp": 1422724341600 }, { "timestamp": 1422745941600 }, { "timestamp": 1422767541600, "price": 0.4 }, { "timestamp": 1422789141600, "price": 0.4 }, { "timestamp": 1422810741600, "price": 0.4 }, { "timestamp": 1422832341600, "price": 0.4 }, { "timestamp": 1422853941600, "price": 0.4 } ] }, { "contract_id": "48JhJmaZP34XRSyu5", "values": [ { "timestamp": 1422702741600, "price": 0.4 }, { "timestamp": 1422724341600 }, { "timestamp": 1422745941600 }, { "timestamp": 1422767541600, "price": 99.6 }, { "timestamp": 1422789141600, "price": 99.6 }, { "timestamp": 1422810741600, "price": 99.6 }, { "timestamp": 1422832341600, "price": 99.6 }, { "timestamp": 1422853941600, "price": 99.6 } ] } ] } ```
kjetil commented 2015-02-03 21:11:36 +01:00 (Migrated from gitlab.lallis.org)

Status changed to closed by commit d7b02c

Status changed to closed by commit d7b02c
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kjetil/predi#15
No description provided.